new (temporary) html view and bug fixication
2001-01-24 jacob berkman <jacob@ximian.com> * new-control-center/*.[ch]: new (temporary) html view and bug fixication * root-manager/*.[ch]: gnomeify dialogs and other cleanups * configure.in: flags for root-manager-helper 2001-01-17 jacob berkman <jacob@ximian.com> * root-manager/Makefile.am * root-manager/root-manager.h: fix finding the root-manager
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2001-01-24 jacob berkman <jacob@ximian.com>
|
||||||
|
|
||||||
|
* new-control-center/*.[ch]: new (temporary) html view and bug
|
||||||
|
fixication
|
||||||
|
|
||||||
|
* root-manager/*.[ch]: gnomeify dialogs and other cleanups
|
||||||
|
|
||||||
|
* configure.in: flags for root-manager-helper
|
||||||
|
|
||||||
|
2001-01-17 jacob berkman <jacob@ximian.com>
|
||||||
|
|
||||||
|
* root-manager/Makefile.am
|
||||||
|
* root-manager/root-manager.h: fix finding the root-manager
|
||||||
|
|
||||||
2001-01-24 Bradford Hovinen <hovinen@ximian.com>
|
2001-01-24 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
* configure.in: Added ROLLBACK_CAPPLET_{CFLAGS|LIBS} for the
|
* configure.in: Added ROLLBACK_CAPPLET_{CFLAGS|LIBS} for the
|
||||||
|
|
|
@ -105,6 +105,9 @@ ROLLBACK_CAPPLET_LIBS=`gnome-config --libs libglade capplet gdk_pixbuf ximian_ar
|
||||||
GNOMECC_CFLAGS=`gnome-config --cflags gnomeui libglade xml gdk_pixbuf capplet gnomecanvaspixbuf gtkhtml`
|
GNOMECC_CFLAGS=`gnome-config --cflags gnomeui libglade xml gdk_pixbuf capplet gnomecanvaspixbuf gtkhtml`
|
||||||
GNOMECC_LIBS=`gnome-config --libs gnomeui libglade xml gdk_pixbuf capplet gnomecanvaspixbuf gtkhtml`
|
GNOMECC_LIBS=`gnome-config --libs gnomeui libglade xml gdk_pixbuf capplet gnomecanvaspixbuf gtkhtml`
|
||||||
|
|
||||||
|
RMHELPER_CFLAGS=`gnome-config --cflags gnomeui gnomecanvaspixbuf`
|
||||||
|
RMHELPER_LIBS=`gnome-config --libs gnomeui gnomecanvaspixbuf`
|
||||||
|
|
||||||
AC_SUBST(CAPPLET_CFLAGS)
|
AC_SUBST(CAPPLET_CFLAGS)
|
||||||
AC_SUBST(CAPPLET_LIBS)
|
AC_SUBST(CAPPLET_LIBS)
|
||||||
|
|
||||||
|
@ -117,6 +120,9 @@ AC_SUBST(ROLLBACK_CAPPLET_LIBS)
|
||||||
AC_SUBST(GNOMECC_CFLAGS)
|
AC_SUBST(GNOMECC_CFLAGS)
|
||||||
AC_SUBST(GNOMECC_LIBS)
|
AC_SUBST(GNOMECC_LIBS)
|
||||||
|
|
||||||
|
AC_SUBST(RMHELPER_CFLAGS)
|
||||||
|
AC_SUBST(RMHELPER_LIBS)
|
||||||
|
|
||||||
AC_SUBST(CFLAGS)
|
AC_SUBST(CFLAGS)
|
||||||
AC_SUBST(LDFLAGS)
|
AC_SUBST(LDFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
appicondir = $(datadir)/pixmaps
|
appicondir = $(datadir)/pixmaps
|
||||||
appicon_DATA = control-center.png
|
appicon_DATA = control-center.png
|
||||||
|
|
||||||
splashdir = $(datadir)/pixmaps
|
splashdir = $(datadir)/pixmaps/gnomecc
|
||||||
splash_DATA = ccsplash.png
|
splash_DATA = \
|
||||||
|
ccsplash.png \
|
||||||
|
bgtop.png \
|
||||||
|
bg.png \
|
||||||
|
empty.png \
|
||||||
|
foot.png \
|
||||||
|
left_top.png \
|
||||||
|
left.png
|
||||||
|
|
||||||
sysdir = $(datadir)/gnome/apps/Settings
|
sysdir = $(datadir)/gnome/apps/Settings
|
||||||
sys_DATA = gnomecc.desktop
|
sys_DATA = gnomecc.desktop
|
||||||
|
@ -23,8 +30,9 @@ INCLUDES = \
|
||||||
-DVERSION=\""$(VERSION)"\" \
|
-DVERSION=\""$(VERSION)"\" \
|
||||||
-DSETTINGS_DIR=\""$(datadir)/control-center"\" \
|
-DSETTINGS_DIR=\""$(datadir)/control-center"\" \
|
||||||
-DPIXMAPS_DIR=\""$(appicondir)"\" \
|
-DPIXMAPS_DIR=\""$(appicondir)"\" \
|
||||||
-DGNOME_SBINDIR=\""$(sbindir)"\" \
|
-DART_DIR=\""$(splashdir)"\" \
|
||||||
$(GNOEMCC_CFLAGS)
|
-DGNOME_SBINDIR=\""$(sbindir)"\"
|
||||||
|
$(GNOMECC_CFLAGS)
|
||||||
|
|
||||||
bin_PROGRAMS = gnomecc
|
bin_PROGRAMS = gnomecc
|
||||||
|
|
||||||
|
|
BIN
control-center/bg.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
control-center/bgtop.png
Normal file
After Width: | Height: | Size: 396 B |
|
@ -31,20 +31,28 @@
|
||||||
|
|
||||||
#include "capplet-dir-view.h"
|
#include "capplet-dir-view.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GtkHTML *top;
|
||||||
|
GtkHTML *main;
|
||||||
|
} HtmlViewData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
html_clear (CappletDirView *view)
|
html_clear (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_HTML (view->view));
|
HtmlViewData *data;
|
||||||
|
|
||||||
gtk_html_load_empty (GTK_HTML (view->view));
|
data = view->view_data;
|
||||||
|
|
||||||
|
gtk_html_load_empty (data->top);
|
||||||
|
gtk_html_load_empty (data->main);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
html_clean (CappletDirView *view)
|
html_clean (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_HTML (view->view));
|
/* gtk_widget_unparent (view->view); */
|
||||||
|
g_free (view->view_data);
|
||||||
gtk_object_destroy (GTK_OBJECT (view->view));
|
view->view_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUFLEN 4096
|
#define BUFLEN 4096
|
||||||
|
@ -113,18 +121,52 @@ write_parent_html (CappletDir *dir, GtkHTML *html, GtkHTMLStream *stream)
|
||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
header_populate (CappletDirView *view)
|
||||||
|
{
|
||||||
|
GtkHTMLStream *stream;
|
||||||
|
HtmlViewData *data;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
data = view->view_data;
|
||||||
|
stream = gtk_html_begin (data->top);
|
||||||
|
|
||||||
|
#warning this should probably be loaded from a file yo
|
||||||
|
s =
|
||||||
|
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
|
||||||
|
"<html>\n"
|
||||||
|
"<head></head>\n"
|
||||||
|
"<body marginwidth=\"0\" marginheight=\"0\" background=\""ART_DIR"/bgtop.png\">\n"
|
||||||
|
"<img src=\""ART_DIR"/left_top.png\" alt=\"\" width=\"47\" height=\"139\" />\n"
|
||||||
|
"<img src=\""ART_DIR"/empty.png\" alt=\"\" width=\"5\" height=\"110\" />\n"
|
||||||
|
"<img src=\""ART_DIR"/foot.png\" alt=\"Gnome\" />\n"
|
||||||
|
"<img src=\""ART_DIR"/empty.png\" alt=\"\" width=\"5\" height=\"110\" />\n"
|
||||||
|
"<FONT face=\"Trebuchet MS CE,Trebuchet MS, Verdana CE, Verdana, Sans-Serif CE, Sans-Serif\" size=\"6\" color=\"white\">Your Gnome</font>\n"
|
||||||
|
#if 0
|
||||||
|
"<img src=\""ART_DIR"/yourgnome.png\" alt=\"\" />\n"
|
||||||
|
#endif
|
||||||
|
"</body>\n"
|
||||||
|
"</html>";
|
||||||
|
|
||||||
|
gtk_html_write (data->top, stream, s, strlen (s));
|
||||||
|
gtk_html_end (data->top, stream, GTK_HTML_STREAM_OK);
|
||||||
|
gtk_widget_set_usize (GTK_WIDGET (data->top), 0, 139);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
html_populate (CappletDirView *view)
|
html_populate (CappletDirView *view)
|
||||||
{
|
{
|
||||||
|
HtmlViewData *data;
|
||||||
GtkHTMLStream *stream;
|
GtkHTMLStream *stream;
|
||||||
CappletDirEntry *entry;
|
CappletDirEntry *entry;
|
||||||
GSList *item;
|
GSList *item;
|
||||||
int i;
|
int i;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_HTML (view->view));
|
header_populate (view);
|
||||||
|
|
||||||
stream = gtk_html_begin (GTK_HTML (view->view));
|
data = view->view_data;
|
||||||
|
stream = gtk_html_begin (data->main);
|
||||||
|
|
||||||
s =
|
s =
|
||||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
|
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
|
||||||
|
@ -132,8 +174,11 @@ html_populate (CappletDirView *view)
|
||||||
" <head>\n"
|
" <head>\n"
|
||||||
" <title>GNOME Control Center</title>\n"
|
" <title>GNOME Control Center</title>\n"
|
||||||
" </head>\n"
|
" </head>\n"
|
||||||
" <body marginheight=\"0\" marginwidth=\"0\">\n"
|
" <body marginheight=\"0\" marginwidth=\"0\" background=\""ART_DIR"/bg.png\">\n"
|
||||||
|
" <img src=\""ART_DIR"/left.png\" align=\"left\" alt=\"\">\n"
|
||||||
|
" <p align=\"center\">\n"
|
||||||
#if 0
|
#if 0
|
||||||
|
" <img src=\""ART_DIR"/empty.png\" alt=\"\" width=\"600\" height=\"30\" />\n"
|
||||||
" <table bgcolor=\"#292928\" width=\"100%%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" columns=\"2\">\n"
|
" <table bgcolor=\"#292928\" width=\"100%%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" columns=\"2\">\n"
|
||||||
" <tr>\n"
|
" <tr>\n"
|
||||||
" <td>\n"
|
" <td>\n"
|
||||||
|
@ -145,23 +190,25 @@ html_populate (CappletDirView *view)
|
||||||
" </table>\n"
|
" </table>\n"
|
||||||
#endif
|
#endif
|
||||||
" <table width=\"100%%\" columns=\"4\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n"
|
" <table width=\"100%%\" columns=\"4\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n"
|
||||||
|
#if 0
|
||||||
" <tr height=\"64\">\n"
|
" <tr height=\"64\">\n"
|
||||||
" <td colspan=\"4\">\n"
|
" <td colspan=\"4\">\n"
|
||||||
" Select something you want to customize.\n"
|
" Select something you want to customize.\n"
|
||||||
" </td>\n"
|
" </td>\n"
|
||||||
" <\tr>\n"
|
" <\tr>\n"
|
||||||
|
#endif
|
||||||
" <tr>\n"
|
" <tr>\n"
|
||||||
" <td colspan=\"4\">\n"
|
" <td colspan=\"4\">\n"
|
||||||
" \n";
|
" \n";
|
||||||
|
|
||||||
gtk_html_write (GTK_HTML (view->view), stream, s, strlen (s));
|
gtk_html_write (data->main, stream, s, strlen (s));
|
||||||
|
|
||||||
write_parent_html (view->capplet_dir->entry.dir, GTK_HTML (view->view), stream);
|
/* write_parent_html (view->capplet_dir->entry.dir, data->main, stream); */
|
||||||
|
|
||||||
for (i = 0, item = view->capplet_dir->entries; item; item = item->next, i++) {
|
for (i = 0, item = view->capplet_dir->entries; item; item = item->next, i++) {
|
||||||
if (!(i%2)) {
|
if (!(i%2)) {
|
||||||
s = " <tr>\n";
|
s = " <tr>\n";
|
||||||
gtk_html_write (GTK_HTML (view->view), stream, s, strlen (s));
|
gtk_html_write (data->main, stream, s, strlen (s));
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = CAPPLET_DIR_ENTRY (item->data);
|
entry = CAPPLET_DIR_ENTRY (item->data);
|
||||||
|
@ -174,36 +221,67 @@ html_populate (CappletDirView *view)
|
||||||
" </td>\n"
|
" </td>\n"
|
||||||
, entry->path, entry->icon, entry->path, entry->label, entry->entry->comment);
|
, entry->path, entry->icon, entry->path, entry->label, entry->entry->comment);
|
||||||
|
|
||||||
gtk_html_write (GTK_HTML (view->view), stream, s, strlen (s));
|
gtk_html_write (data->main, stream, s, strlen (s));
|
||||||
g_free (s);
|
g_free (s);
|
||||||
|
|
||||||
if (i%2 || !item->next) {
|
if (i%2 || !item->next) {
|
||||||
s = " </tr>\n";
|
s = " </tr>\n";
|
||||||
gtk_html_write (GTK_HTML (view->view), stream, s, strlen (s));
|
gtk_html_write (data->main, stream, s, strlen (s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s =
|
s =
|
||||||
" </table>\n"
|
" </table>\n"
|
||||||
|
" </p>\n"
|
||||||
" </body>\n"
|
" </body>\n"
|
||||||
"</html>\n";
|
"</html>\n";
|
||||||
gtk_html_write (GTK_HTML (view->view), stream, s, strlen (s));
|
gtk_html_write (data->main, stream, s, strlen (s));
|
||||||
|
|
||||||
gtk_html_end (GTK_HTML (view->view), stream, GTK_HTML_STREAM_OK);
|
gtk_html_end (data->main, stream, GTK_HTML_STREAM_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
html_create (CappletDirView *view)
|
html_create (CappletDirView *view)
|
||||||
{
|
{
|
||||||
GtkWidget *w = gtk_html_new ();
|
GtkWidget *vbox;
|
||||||
|
HtmlViewData *data;
|
||||||
|
GtkWidget *sw;
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "url_requested",
|
data = g_new (HtmlViewData, 1);
|
||||||
|
view->view_data = data;
|
||||||
|
|
||||||
|
vbox = gtk_vbox_new (FALSE, 0);
|
||||||
|
|
||||||
|
/* top widget */
|
||||||
|
data->top = GTK_HTML (gtk_html_new ());
|
||||||
|
|
||||||
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
|
GTK_POLICY_NEVER,
|
||||||
|
GTK_POLICY_NEVER);
|
||||||
|
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (data->top));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), sw, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
/* main widget */
|
||||||
|
data->main = GTK_HTML (gtk_html_new ());
|
||||||
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
|
GTK_POLICY_NEVER,
|
||||||
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (data->main));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (data->top), "url_requested",
|
||||||
GTK_SIGNAL_FUNC (handle_url_cb), view);
|
GTK_SIGNAL_FUNC (handle_url_cb), view);
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "link_clicked",
|
gtk_signal_connect (GTK_OBJECT (data->main), "url_requested",
|
||||||
|
GTK_SIGNAL_FUNC (handle_url_cb), view);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (data->main), "link_clicked",
|
||||||
GTK_SIGNAL_FUNC (handle_link_cb), view);
|
GTK_SIGNAL_FUNC (handle_link_cb), view);
|
||||||
|
|
||||||
return w;
|
gtk_widget_show_all (vbox);
|
||||||
|
return vbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
CappletDirViewImpl capplet_dir_view_html = {
|
CappletDirViewImpl capplet_dir_view_html = {
|
||||||
|
@ -212,4 +290,3 @@ CappletDirViewImpl capplet_dir_view_html = {
|
||||||
html_populate,
|
html_populate,
|
||||||
html_create
|
html_create
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,16 @@
|
||||||
static void
|
static void
|
||||||
list_clear (CappletDirView *view)
|
list_clear (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
g_return_if_fail (GNOME_IS_ICON_LIST (view->view_data));
|
||||||
|
|
||||||
gnome_icon_list_clear (GNOME_ICON_LIST (view->view));
|
gnome_icon_list_clear (GNOME_ICON_LIST (view->view_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_clean (CappletDirView *view)
|
list_clean (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
/* i think this can be a no-op now */
|
||||||
|
view->view_data = NULL;
|
||||||
gtk_object_destroy (GTK_OBJECT (view->view));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -103,23 +102,23 @@ list_populate (CappletDirView *view)
|
||||||
int i;
|
int i;
|
||||||
GnomeCanvasItem *item;
|
GnomeCanvasItem *item;
|
||||||
|
|
||||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
g_return_if_fail (GNOME_IS_ICON_LIST (view->view_data));
|
||||||
|
|
||||||
gnome_icon_list_freeze (GNOME_ICON_LIST (view->view));
|
gnome_icon_list_freeze (GNOME_ICON_LIST (view->view_data));
|
||||||
|
|
||||||
for (i = 0, list = view->capplet_dir->entries; list; list = list->next, i++) {
|
for (i = 0, list = view->capplet_dir->entries; list; list = list->next, i++) {
|
||||||
#if 0
|
#if 0
|
||||||
item = flatten_alpha (CAPPLET_DIR_ENTRY (list->data)->pb,
|
item = flatten_alpha (CAPPLET_DIR_ENTRY (list->data)->pb,
|
||||||
GNOME_CANVAS (view->view));
|
GNOME_CANVAS (view->view_data));
|
||||||
gnome_icon_list_insert_item (GNOME_ICON_LIST (view->view), i, item,
|
gnome_icon_list_insert_item (GNOME_ICON_LIST (view->view_data), i, item,
|
||||||
CAPPLET_DIR_ENTRY (list->data)->label);
|
CAPPLET_DIR_ENTRY (list->data)->label);
|
||||||
#else
|
#else
|
||||||
gnome_icon_list_insert (GNOME_ICON_LIST (view->view), i,
|
gnome_icon_list_insert (GNOME_ICON_LIST (view->view_data), i,
|
||||||
CAPPLET_DIR_ENTRY (list->data)->icon,
|
CAPPLET_DIR_ENTRY (list->data)->icon,
|
||||||
CAPPLET_DIR_ENTRY (list->data)->label);
|
CAPPLET_DIR_ENTRY (list->data)->label);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
gnome_icon_list_thaw (GNOME_ICON_LIST (view->view));
|
gnome_icon_list_thaw (GNOME_ICON_LIST (view->view_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -141,15 +140,18 @@ static GtkWidget *
|
||||||
list_create (CappletDirView *view)
|
list_create (CappletDirView *view)
|
||||||
{
|
{
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
GtkWidget *w;
|
GtkWidget *w, *sw;
|
||||||
GSList *list;
|
GSList *list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
adjustment = gtk_scrolled_window_get_vadjustment
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
(GTK_SCROLLED_WINDOW (view->scrolled_win));
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
|
GTK_POLICY_AUTOMATIC,
|
||||||
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
|
||||||
|
adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
|
||||||
|
|
||||||
w = gnome_icon_list_new (72, adjustment, 0);
|
view->view_data = w = gnome_icon_list_new (72, adjustment, 0);
|
||||||
|
|
||||||
if (view->selected)
|
if (view->selected)
|
||||||
view->capplet_dir = view->selected->dir;
|
view->capplet_dir = view->selected->dir;
|
||||||
|
@ -170,7 +172,11 @@ list_create (CappletDirView *view)
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "select-icon",
|
gtk_signal_connect (GTK_OBJECT (w), "select-icon",
|
||||||
GTK_SIGNAL_FUNC (select_icon_list_cb),
|
GTK_SIGNAL_FUNC (select_icon_list_cb),
|
||||||
view);
|
view);
|
||||||
return w;
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (sw), w);
|
||||||
|
gtk_widget_show_all (sw);
|
||||||
|
|
||||||
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
CappletDirViewImpl capplet_dir_view_list = {
|
CappletDirViewImpl capplet_dir_view_list = {
|
||||||
|
|
|
@ -29,17 +29,17 @@
|
||||||
static void
|
static void
|
||||||
tree_clear (CappletDirView *view)
|
tree_clear (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_CTREE (view->view));
|
g_return_if_fail (GTK_IS_CTREE (view->view_data));
|
||||||
|
|
||||||
gtk_clist_clear (GTK_CLIST (view->view));
|
gtk_clist_clear (GTK_CLIST (view->view_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tree_clean (CappletDirView *view)
|
tree_clean (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_CTREE (view->view));
|
g_return_if_fail (GTK_IS_CTREE (view->view_data));
|
||||||
|
|
||||||
gtk_object_destroy (GTK_OBJECT (view->view));
|
view->view_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -80,11 +80,11 @@ populate_tree_branch (CappletDir *dir, GtkCTree *ctree, GtkCTreeNode *parent)
|
||||||
static void
|
static void
|
||||||
tree_populate (CappletDirView *view)
|
tree_populate (CappletDirView *view)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_CTREE (view->view));
|
g_return_if_fail (GTK_IS_CTREE (view->view_data));
|
||||||
|
|
||||||
gtk_clist_freeze (GTK_CLIST (view->view));
|
gtk_clist_freeze (GTK_CLIST (view->view_data));
|
||||||
populate_tree_branch (view->capplet_dir, GTK_CTREE (view->view), NULL);
|
populate_tree_branch (view->capplet_dir, GTK_CTREE (view->view_data), NULL);
|
||||||
gtk_clist_thaw (GTK_CLIST (view->view));
|
gtk_clist_thaw (GTK_CLIST (view->view_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -122,12 +122,14 @@ static GtkWidget *
|
||||||
tree_create (CappletDirView *view)
|
tree_create (CappletDirView *view)
|
||||||
{
|
{
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
GtkWidget *w;
|
GtkWidget *w, *sw;
|
||||||
|
|
||||||
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
|
GTK_POLICY_AUTOMATIC,
|
||||||
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
|
||||||
adjustment = gtk_scrolled_window_get_vadjustment
|
view->view_data = w = gtk_ctree_new (1, 0);
|
||||||
(GTK_SCROLLED_WINDOW (view->scrolled_win));
|
|
||||||
|
|
||||||
w = gtk_ctree_new (1, 0);
|
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (w), "tree-select-row",
|
gtk_signal_connect (GTK_OBJECT (w), "tree-select-row",
|
||||||
GTK_SIGNAL_FUNC (select_tree_cb),
|
GTK_SIGNAL_FUNC (select_tree_cb),
|
||||||
|
@ -136,7 +138,10 @@ tree_create (CappletDirView *view)
|
||||||
GTK_SIGNAL_FUNC (tree_event_cb),
|
GTK_SIGNAL_FUNC (tree_event_cb),
|
||||||
view);
|
view);
|
||||||
|
|
||||||
return w;
|
gtk_container_add (GTK_CONTAINER (sw), w);
|
||||||
|
gtk_widget_show_all (sw);
|
||||||
|
|
||||||
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -52,6 +52,26 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GList *window_list;
|
static GList *window_list;
|
||||||
|
static gboolean authed;
|
||||||
|
|
||||||
|
static void
|
||||||
|
capplet_dir_view_update_authenticated (CappletDirView *view, gpointer null)
|
||||||
|
{
|
||||||
|
if (authed) {
|
||||||
|
gtk_widget_hide (view->rootm_locked);
|
||||||
|
gtk_widget_show (view->rootm_unlocked);
|
||||||
|
} else {
|
||||||
|
gtk_widget_hide (view->rootm_unlocked);
|
||||||
|
gtk_widget_show (view->rootm_locked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
capplet_dir_views_set_authenticated (gboolean amiauthedornot)
|
||||||
|
{
|
||||||
|
authed = amiauthedornot;
|
||||||
|
g_list_foreach (window_list, (GFunc)capplet_dir_view_update_authenticated, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
capplet_dir_view_init (CappletDirView *view)
|
capplet_dir_view_init (CappletDirView *view)
|
||||||
|
@ -76,6 +96,11 @@ capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||||
if (layout == view->layout)
|
if (layout == view->layout)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
g_assert (!view->changing_layout);
|
||||||
|
view->changing_layout = TRUE;
|
||||||
|
|
||||||
|
g_print ("layout: %p, %d\n", view, layout);
|
||||||
|
|
||||||
if (view->impl && view->impl->clean)
|
if (view->impl && view->impl->clean)
|
||||||
view->impl->clean (view);
|
view->impl->clean (view);
|
||||||
|
|
||||||
|
@ -83,18 +108,23 @@ capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||||
view->impl = capplet_dir_view_impl[layout];
|
view->impl = capplet_dir_view_impl[layout];
|
||||||
|
|
||||||
if (view->impl && view->impl->create) {
|
if (view->impl && view->impl->create) {
|
||||||
|
g_print ("1. %p\n", view->view);
|
||||||
view->view = view->impl->create (view);
|
view->view = view->impl->create (view);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (view->scrolled_win),
|
g_print ("2. %p\n", view->view);
|
||||||
view->view);
|
gnome_app_set_contents (view->app, view->view);
|
||||||
|
|
||||||
|
g_print ("3. %p\n", view->view);
|
||||||
if (view->capplet_dir && view->impl->populate)
|
if (view->capplet_dir && view->impl->populate)
|
||||||
view->impl->populate (view);
|
view->impl->populate (view);
|
||||||
|
|
||||||
|
g_print ("4. %p\n", view->view);
|
||||||
|
#if 0
|
||||||
gtk_signal_connect (GTK_OBJECT (view->view), "destroy",
|
gtk_signal_connect (GTK_OBJECT (view->view), "destroy",
|
||||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||||
&view->view);
|
&view->view);
|
||||||
|
#endif
|
||||||
|
g_print ("5. %p\n\n\n\n", view->view);
|
||||||
gtk_widget_show (view->view);
|
gtk_widget_show (view->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +141,8 @@ capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||||
layout == LAYOUT_TREE);
|
layout == LAYOUT_TREE);
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->html_toggle),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->html_toggle),
|
||||||
layout == LAYOUT_HTML);
|
layout == LAYOUT_HTML);
|
||||||
|
|
||||||
|
view->changing_layout = FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -211,7 +243,7 @@ exit_cb (GtkWidget *w, gpointer data)
|
||||||
static void
|
static void
|
||||||
menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
||||||
{
|
{
|
||||||
if (!GTK_CHECK_MENU_ITEM (w)->active)
|
if (!GTK_CHECK_MENU_ITEM (w)->active || view->changing_layout)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
||||||
|
@ -238,7 +270,7 @@ tree_menu_cb (GtkWidget *w, CappletDirView *view)
|
||||||
static void
|
static void
|
||||||
button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
||||||
{
|
{
|
||||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
|
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)) || view->changing_layout)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
||||||
|
@ -273,8 +305,8 @@ about_menu_cb (GtkWidget *widget, CappletDirView *view)
|
||||||
{
|
{
|
||||||
static GtkWidget *about = NULL;
|
static GtkWidget *about = NULL;
|
||||||
static gchar *authors[] = {
|
static gchar *authors[] = {
|
||||||
"Bradford Hovinen <hovinen@helixcode.com>",
|
"Bradford Hovinen <hovinen@ximian.com>",
|
||||||
"Jacob Berkman <jacob@helixcode.com>",
|
"Jacob Berkman <jacob@ximian.com>",
|
||||||
"Johnathan Blandford <jrb@redhat.com>",
|
"Johnathan Blandford <jrb@redhat.com>",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -289,7 +321,7 @@ about_menu_cb (GtkWidget *widget, CappletDirView *view)
|
||||||
(_("GNOME Control Center"), VERSION,
|
(_("GNOME Control Center"), VERSION,
|
||||||
_("Desktop properties manager."),
|
_("Desktop properties manager."),
|
||||||
(const gchar **) authors,
|
(const gchar **) authors,
|
||||||
"Copyright (C) 2000 Helix Code, Inc.\n"
|
"Copyright (C) 2000, 20001 Ximian, Inc.\n"
|
||||||
"Copyright (C) 1999 Red Hat Software, Inc.",
|
"Copyright (C) 1999 Red Hat Software, Inc.",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -311,13 +343,7 @@ back_button_cb (GtkWidget *widget, CappletDirView *view)
|
||||||
static void
|
static void
|
||||||
rootm_button_cb (GtkWidget *w, CappletDirView *view)
|
rootm_button_cb (GtkWidget *w, CappletDirView *view)
|
||||||
{
|
{
|
||||||
if (GTK_WIDGET_VISIBLE (view->rootm_locked)) {
|
gdk_beep ();
|
||||||
gtk_widget_hide (view->rootm_locked);
|
|
||||||
gtk_widget_show (view->rootm_unlocked);
|
|
||||||
} else {
|
|
||||||
gtk_widget_hide (view->rootm_unlocked);
|
|
||||||
gtk_widget_show (view->rootm_locked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CappletDirView *
|
CappletDirView *
|
||||||
|
@ -335,8 +361,7 @@ capplet_dir_view_new (void)
|
||||||
|
|
||||||
window_list = g_list_append (window_list, view);
|
window_list = g_list_append (window_list, view);
|
||||||
|
|
||||||
view->app = glade_xml_get_widget (xml, "main_window");
|
view->app = GNOME_APP (glade_xml_get_widget (xml, "main_window"));
|
||||||
view->scrolled_win = glade_xml_get_widget (xml, "scrolled_window");
|
|
||||||
view->up_button = glade_xml_get_widget (xml, "back_button");
|
view->up_button = glade_xml_get_widget (xml, "back_button");
|
||||||
view->parents_option = glade_xml_get_widget (xml, "parents_option");
|
view->parents_option = glade_xml_get_widget (xml, "parents_option");
|
||||||
view->html_toggle = glade_xml_get_widget (xml, "html_toggle");
|
view->html_toggle = glade_xml_get_widget (xml, "html_toggle");
|
||||||
|
@ -383,6 +408,8 @@ capplet_dir_view_new (void)
|
||||||
|
|
||||||
gtk_object_set (GTK_OBJECT (view), "layout", prefs->layout, NULL);
|
gtk_object_set (GTK_OBJECT (view), "layout", prefs->layout, NULL);
|
||||||
|
|
||||||
|
capplet_dir_view_update_authenticated (view, NULL);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct _CappletDirViewImpl
|
||||||
/* remove entries from view */
|
/* remove entries from view */
|
||||||
CDVFunc clear;
|
CDVFunc clear;
|
||||||
|
|
||||||
/* clean up (destroy widgets */
|
/* clean up (destroy widgets) */
|
||||||
CDVFunc clean;
|
CDVFunc clean;
|
||||||
|
|
||||||
CDVFunc populate;
|
CDVFunc populate;
|
||||||
|
@ -66,12 +66,11 @@ struct _CappletDirView
|
||||||
CappletDirViewImpl *impl;
|
CappletDirViewImpl *impl;
|
||||||
|
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
|
gpointer view_data;
|
||||||
|
|
||||||
gboolean destroyed;
|
gboolean destroyed;
|
||||||
CappletDirViewLayout layout;
|
CappletDirViewLayout layout;
|
||||||
|
|
||||||
GtkScrolledWindow *scrolled_win;
|
|
||||||
|
|
||||||
GtkWidget *up_button;
|
GtkWidget *up_button;
|
||||||
GtkWidget *parents_option;
|
GtkWidget *parents_option;
|
||||||
|
|
||||||
|
@ -86,6 +85,8 @@ struct _CappletDirView
|
||||||
GtkWidget *rootm_button;
|
GtkWidget *rootm_button;
|
||||||
GtkWidget *rootm_locked;
|
GtkWidget *rootm_locked;
|
||||||
GtkWidget *rootm_unlocked;
|
GtkWidget *rootm_unlocked;
|
||||||
|
|
||||||
|
gboolean changing_layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CappletDirViewClass
|
struct _CappletDirViewClass
|
||||||
|
@ -101,6 +102,8 @@ void capplet_dir_view_destroy (CappletDirView *view);
|
||||||
void capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir);
|
void capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir);
|
||||||
void capplet_dir_view_show (CappletDirView *view);
|
void capplet_dir_view_show (CappletDirView *view);
|
||||||
|
|
||||||
|
void capplet_dir_views_set_authenticated (gboolean authed);
|
||||||
|
|
||||||
void gnomecc_init (void);
|
void gnomecc_init (void);
|
||||||
|
|
||||||
#endif /* __CAPPLET_DIR_VIEW */
|
#endif /* __CAPPLET_DIR_VIEW */
|
||||||
|
|
|
@ -325,8 +325,7 @@ start_capplet_through_root_manager (GnomeDesktopEntry *gde)
|
||||||
|
|
||||||
if (pid == (pid_t) -1) {
|
if (pid == (pid_t) -1) {
|
||||||
g_error ("%s", g_strerror (errno));
|
g_error ("%s", g_strerror (errno));
|
||||||
}
|
} else if (pid == 0) {
|
||||||
else if (pid == 0) {
|
|
||||||
char *arg[2];
|
char *arg[2];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -337,11 +336,11 @@ start_capplet_through_root_manager (GnomeDesktopEntry *gde)
|
||||||
arg[0] = gnome_is_program_in_path ("root-manager-helper");
|
arg[0] = gnome_is_program_in_path ("root-manager-helper");
|
||||||
arg[1] = NULL;
|
arg[1] = NULL;
|
||||||
execv (arg[0], arg);
|
execv (arg[0], arg);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
output = fdopen(pipe_fd[1], "a");
|
output = fdopen(pipe_fd[1], "a");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capplet_dir_views_set_authenticated (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
control-center/empty.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
control-center/foot.png
Normal file
After Width: | Height: | Size: 11 KiB |
|
@ -668,17 +668,8 @@
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkScrolledWindow</class>
|
<class>Placeholder</class>
|
||||||
<child_name>GnomeDock:contents</child_name>
|
<child_name>GnomeDock:contents</child_name>
|
||||||
<name>scrolled_window</name>
|
|
||||||
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
|
|
||||||
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
|
|
||||||
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
|
|
||||||
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
|
|
||||||
|
|
||||||
<widget>
|
|
||||||
<class>Placeholder</class>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
|
|
BIN
control-center/left.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
control-center/left_top.png
Normal file
After Width: | Height: | Size: 519 B |
|
@ -34,8 +34,6 @@
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
CappletDirEntry *main_dir;
|
|
||||||
|
|
||||||
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
||||||
textdomain (PACKAGE);
|
textdomain (PACKAGE);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
|
pixmapdir = $(datadir)/pixmaps
|
||||||
|
pixmap_DATA = xst-keys.png
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||||
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
|
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
|
||||||
-I$(includedir) $(shell gtk-config --cflags) \
|
@RMHELPER_CFLAGS@ \
|
||||||
|
-DUH_PATH=\""$(sbindir)/root-manager"\" \
|
||||||
|
-DUH_KEY_PIXMAP_PATH=\""$(pixmapdir)/xst-keys.png"\" \
|
||||||
-DDEBUG_USERHELPER
|
-DDEBUG_USERHELPER
|
||||||
|
|
||||||
bin_PROGRAMS = root-manager-helper
|
bin_PROGRAMS = root-manager-helper
|
||||||
|
@ -19,8 +24,6 @@ root_manager_LDFLAGS = $(shell glib-config --libs)
|
||||||
root_manager_helper_SOURCES = \
|
root_manager_helper_SOURCES = \
|
||||||
root-manager-helper.c \
|
root-manager-helper.c \
|
||||||
root-manager-wrap.c \
|
root-manager-wrap.c \
|
||||||
root-manager-wrap.h \
|
root-manager-wrap.h
|
||||||
userdialogs.c \
|
|
||||||
userdialogs.h
|
|
||||||
|
|
||||||
root_manager_helper_LDFLAGS = $(shell gtk-config --libs)
|
root_manager_helper_LDFLAGS = @RMHELPER_LIBS@
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 1999 Red Hat Software, Inc.
|
/* Copyright (C) 1999 Red Hat Software, Inc.
|
||||||
|
* Copyright 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* This is free software; you can redistribute it and/or modify it
|
* This is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,8 +24,7 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gnome.h>
|
||||||
#include "userdialogs.h"
|
|
||||||
#include "root-manager-wrap.h"
|
#include "root-manager-wrap.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -52,12 +52,18 @@ main(int argc, char* argv[])
|
||||||
argv_fake[1] = "0";
|
argv_fake[1] = "0";
|
||||||
|
|
||||||
if (!gtk_init_check(&argc_fake, &argv_fake)) {
|
if (!gtk_init_check(&argc_fake, &argv_fake)) {
|
||||||
g_error ("Must be run with $DISPLAY");
|
fprintf (stderr, _("Could not connect to X Display"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_fd = dup (STDIN_FILENO);
|
new_fd = dup (STDIN_FILENO);
|
||||||
if (new_fd < 0)
|
if (new_fd < 0) {
|
||||||
g_error ("error dup()'ing");
|
fprintf (stderr, _("Could not duplicate file descriptor"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gnome_init ("root-manager-helper", VERSION, argc_fake, argv_fake);
|
||||||
|
gdk_rgb_init ();
|
||||||
|
|
||||||
signal(SIGCHLD, userhelper_fatal_error);
|
signal(SIGCHLD, userhelper_fatal_error);
|
||||||
|
|
||||||
|
@ -65,7 +71,5 @@ main(int argc, char* argv[])
|
||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
g_print ("back...\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* -*-Mode: c-*- */
|
/* -*-Mode: c-*- */
|
||||||
/* Copyright (C) 1997 Red Hat Software, Inc.
|
/* Copyright (C) 1997 Red Hat Software, Inc.
|
||||||
|
* Copyright 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* This is free software; you can redistribute it and/or modify it
|
* This is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,16 +17,22 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <locale.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
|
#include <gnome.h>
|
||||||
|
|
||||||
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
|
||||||
|
|
||||||
#include "root-manager-wrap.h"
|
#include "root-manager-wrap.h"
|
||||||
#include "userdialogs.h"
|
|
||||||
|
|
||||||
#define MAXLINE 512
|
#define MAXLINE 512
|
||||||
|
|
||||||
|
@ -36,160 +43,157 @@ int childout_tag;
|
||||||
void
|
void
|
||||||
userhelper_runv(char *path, int new_fd)
|
userhelper_runv(char *path, int new_fd)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int retval;
|
int retval;
|
||||||
int i;
|
int i;
|
||||||
int stdin_save = STDIN_FILENO;
|
int stdin_save = STDIN_FILENO;
|
||||||
int stdout_save = STDOUT_FILENO;
|
int stdout_save = STDOUT_FILENO;
|
||||||
int stderr_save = STDERR_FILENO;
|
int stderr_save = STDERR_FILENO;
|
||||||
char *nargs[256]; /* only used internally, we know this will not overflow */
|
char *nargs[256]; /* only used internally, we know this will not overflow */
|
||||||
|
|
||||||
if((pipe(childout) == -1) || (pipe(childin) == -1))
|
if((pipe(childout) == -1) || (pipe(childin) == -1))
|
||||||
{
|
|
||||||
fprintf(stderr, _("Pipe error.\n"));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((pid = fork()) < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _("Cannot fork().\n"));
|
|
||||||
}
|
|
||||||
else if(pid > 0) /* parent */
|
|
||||||
{
|
|
||||||
close(childout[1]);
|
|
||||||
close(childin[0]);
|
|
||||||
close (new_fd);
|
|
||||||
|
|
||||||
childout_tag = gdk_input_add(childout[0], GDK_INPUT_READ, (GdkInputFunction) userhelper_read_childout, NULL);
|
|
||||||
|
|
||||||
}
|
|
||||||
else /* child */
|
|
||||||
{
|
|
||||||
close(childout[0]);
|
|
||||||
close(childin[1]);
|
|
||||||
|
|
||||||
if(childout[1] != STDOUT_FILENO)
|
|
||||||
{
|
{
|
||||||
if(((stdout_save = dup(STDOUT_FILENO)) == -1) ||
|
fprintf(stderr, _("Pipe error.\n"));
|
||||||
(dup2(childout[1], STDOUT_FILENO) != STDOUT_FILENO))
|
exit(1);
|
||||||
{
|
|
||||||
fprintf(stderr, _("dup2() error.\n"));
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
close(childout[1]);
|
|
||||||
}
|
|
||||||
if(childin[0] != STDIN_FILENO)
|
|
||||||
{
|
|
||||||
if(((stdin_save = dup(STDIN_FILENO)) == -1) ||
|
|
||||||
(dup2(childin[0], STDIN_FILENO) != STDIN_FILENO))
|
|
||||||
{
|
|
||||||
fprintf(stderr, _("dup2() error.\n"));
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&nargs, 0, sizeof(nargs));
|
if((pid = fork()) < 0)
|
||||||
nargs[0] = UH_PATH;
|
{
|
||||||
nargs[1] = g_strdup_printf ("%d", new_fd);
|
fprintf(stderr, _("Cannot fork().\n"));
|
||||||
|
}
|
||||||
|
else if(pid > 0) /* parent */
|
||||||
|
{
|
||||||
|
close(childout[1]);
|
||||||
|
close(childin[0]);
|
||||||
|
close (new_fd);
|
||||||
|
|
||||||
|
childout_tag = gdk_input_add(childout[0], GDK_INPUT_READ, (GdkInputFunction) userhelper_read_childout, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
else /* child */
|
||||||
|
{
|
||||||
|
close(childout[0]);
|
||||||
|
close(childin[1]);
|
||||||
|
|
||||||
|
if(childout[1] != STDOUT_FILENO)
|
||||||
|
{
|
||||||
|
if(((stdout_save = dup(STDOUT_FILENO)) == -1) ||
|
||||||
|
(dup2(childout[1], STDOUT_FILENO) != STDOUT_FILENO))
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("dup2() error.\n"));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
close(childout[1]);
|
||||||
|
}
|
||||||
|
if(childin[0] != STDIN_FILENO)
|
||||||
|
{
|
||||||
|
if(((stdin_save = dup(STDIN_FILENO)) == -1) ||
|
||||||
|
(dup2(childin[0], STDIN_FILENO) != STDIN_FILENO))
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("dup2() error.\n"));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&nargs, 0, sizeof(nargs));
|
||||||
|
nargs[0] = UH_PATH;
|
||||||
|
nargs[1] = g_strdup_printf ("%d", new_fd);
|
||||||
#if 0
|
#if 0
|
||||||
nargs[1] = "-d";
|
nargs[1] = "-d";
|
||||||
nargs[2] = g_strdup_printf("%d,%d,%d", stdin_save, stdout_save,
|
nargs[2] = g_strdup_printf("%d,%d,%d", stdin_save, stdout_save,
|
||||||
stderr_save);
|
stderr_save);
|
||||||
for(i = 3; i < sizeof(nargs) / sizeof(nargs[0]); i++) {
|
for(i = 3; i < sizeof(nargs) / sizeof(nargs[0]); i++) {
|
||||||
nargs[i] = args[i - 2];
|
nargs[i] = args[i - 2];
|
||||||
if(nargs[i] == NULL) {
|
if(nargs[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG_USERHELPER
|
#ifdef DEBUG_USERHELPER
|
||||||
for(i = 0; i < sizeof(nargs) / sizeof(nargs[0]); i++) {
|
for(i = 0; i < sizeof(nargs) / sizeof(nargs[0]); i++) {
|
||||||
if(nargs[i] == NULL) {
|
if(nargs[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Exec arg = \"%s\".\n", nargs[i]);
|
fprintf(stderr, "Exec arg = \"%s\".\n", nargs[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
retval = execv(path, nargs);
|
retval = execv(path, nargs);
|
||||||
|
|
||||||
if(retval < 0) {
|
if(retval < 0) {
|
||||||
fprintf(stderr, _("execl() error, errno=%d\n"), errno);
|
fprintf(stderr, _("execl() error, errno=%d\n"), errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
userhelper_run(char *path, ...)
|
userhelper_run(char *path, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *args[256]; /* only used internally, we know this will not overflow */
|
char *args[256]; /* only used internally, we know this will not overflow */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
va_start(ap, path);
|
va_start(ap, path);
|
||||||
while((i < 255) && ((args[i++] = va_arg(ap, char *)) != NULL));
|
while((i < 255) && ((args[i++] = va_arg(ap, char *)) != NULL));
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
userhelper_runv(path, args);
|
userhelper_runv(path, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
userhelper_parse_exitstatus(int exitstatus)
|
userhelper_parse_exitstatus(int exitstatus)
|
||||||
{
|
{
|
||||||
GtkWidget* message_box;
|
GtkWidget* message_box;
|
||||||
|
|
||||||
switch(exitstatus)
|
switch(exitstatus)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
message_box = create_message_box(_("Information updated."), NULL);
|
message_box = gnome_ok_dialog (_("Information updated."));
|
||||||
break;
|
break;
|
||||||
case ERR_PASSWD_INVALID:
|
case ERR_PASSWD_INVALID:
|
||||||
message_box = create_error_box(_("The password you typed is invalid.\nPlease try again."), NULL);
|
message_box = gnome_error_dialog(_("The password you typed is invalid.\nPlease try again."));
|
||||||
break;
|
break;
|
||||||
case ERR_FIELDS_INVALID:
|
case ERR_FIELDS_INVALID:
|
||||||
message_box = create_error_box(_("One or more of the changed fields is invalid.\nThis is probably due to either colons or commas in one of the fields.\nPlease remove those and try again."), NULL);
|
message_box = gnome_error_dialog(_("One or more of the changed fields is invalid.\nThis is probably due to either colons or commas in one of the fields.\nPlease remove those and try again."));
|
||||||
break;
|
break;
|
||||||
case ERR_SET_PASSWORD:
|
case ERR_SET_PASSWORD:
|
||||||
message_box = create_error_box(_("Password resetting error."), NULL);
|
message_box = gnome_error_dialog(_("Password resetting error."));
|
||||||
break;
|
break;
|
||||||
case ERR_LOCKS:
|
case ERR_LOCKS:
|
||||||
message_box = create_error_box(_("Some systems files are locked.\nPlease try again in a few moments."), NULL);
|
message_box = gnome_error_dialog(_("Some systems files are locked.\nPlease try again in a few moments."));
|
||||||
break;
|
break;
|
||||||
case ERR_NO_USER:
|
case ERR_NO_USER:
|
||||||
message_box = create_error_box(_("Unknown user."), NULL);
|
message_box = gnome_error_dialog(_("Unknown user."));
|
||||||
break;
|
break;
|
||||||
case ERR_NO_RIGHTS:
|
case ERR_NO_RIGHTS:
|
||||||
message_box = create_error_box(_("Insufficient rights."), NULL);
|
message_box = gnome_error_dialog(_("Insufficient rights."));
|
||||||
break;
|
break;
|
||||||
case ERR_INVALID_CALL:
|
case ERR_INVALID_CALL:
|
||||||
message_box = create_error_box(_("Invalid call to sub process."), NULL);
|
message_box = gnome_error_dialog(_("Invalid call to sub process."));
|
||||||
break;
|
break;
|
||||||
case ERR_SHELL_INVALID:
|
case ERR_SHELL_INVALID:
|
||||||
message_box = create_error_box(_("Your current shell is not listed in /etc/shells.\nYou are not allowed to change your shell.\nConsult your system administrator."), NULL);
|
message_box = gnome_error_dialog(_("Your current shell is not listed in /etc/shells.\nYou are not allowed to change your shell.\nConsult your system administrator."));
|
||||||
break;
|
break;
|
||||||
case ERR_NO_MEMORY:
|
case ERR_NO_MEMORY:
|
||||||
/* well, this is unlikely to work either, but at least we tried... */
|
/* well, this is unlikely to work either, but at least we tried... */
|
||||||
message_box = create_error_box(_("Out of memory."), NULL);
|
message_box = gnome_error_dialog(_("Out of memory."));
|
||||||
break;
|
break;
|
||||||
case ERR_EXEC_FAILED:
|
case ERR_EXEC_FAILED:
|
||||||
message_box = create_error_box(_("The exec() call failed."), NULL);
|
message_box = gnome_error_dialog(_("The exec() call failed."));
|
||||||
break;
|
break;
|
||||||
case ERR_NO_PROGRAM:
|
case ERR_NO_PROGRAM:
|
||||||
message_box = create_error_box(_("Failed to find selected program."), NULL);
|
message_box = gnome_error_dialog(_("Failed to find selected program."));
|
||||||
break;
|
break;
|
||||||
case ERR_UNK_ERROR:
|
case ERR_UNK_ERROR:
|
||||||
message_box = create_error_box(_("Unknown error."), NULL);
|
message_box = gnome_error_dialog(_("Unknown error."));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
message_box = create_error_box(_("Unknown exit code."), NULL);
|
message_box = gnome_error_dialog(_("Unknown exit code."));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(message_box), "destroy", (GtkSignalFunc) userhelper_fatal_error, NULL);
|
|
||||||
gtk_signal_connect(GTK_OBJECT(message_box), "delete_event", (GtkSignalFunc) userhelper_fatal_error, NULL);
|
|
||||||
gtk_widget_show(message_box);
|
|
||||||
|
|
||||||
|
gnome_dialog_run_and_close (GNOME_DIALOG (message_box));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -206,323 +210,369 @@ userhelper_grab_focus(GtkWidget *widget, GdkEvent *map_event, gpointer data)
|
||||||
static void
|
static void
|
||||||
mark_void(GtkWidget *widget, gpointer target)
|
mark_void(GtkWidget *widget, gpointer target)
|
||||||
{
|
{
|
||||||
if(target != NULL) {
|
if(target != NULL) {
|
||||||
*(gpointer*)target = NULL;
|
*(gpointer*)target = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
make_pixmap (const char *filename)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pb;
|
||||||
|
GtkWidget *canvas;
|
||||||
|
GtkWidget *frame;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
pb = gdk_pixbuf_new_from_file (filename);
|
||||||
|
if (!pb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
width = gdk_pixbuf_get_width (pb);
|
||||||
|
height = gdk_pixbuf_get_height (pb);
|
||||||
|
|
||||||
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_widget_set_usize (frame, width, height);
|
||||||
|
|
||||||
|
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||||
|
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||||
|
|
||||||
|
canvas = gnome_canvas_new_aa ();
|
||||||
|
|
||||||
|
gtk_widget_pop_colormap ();
|
||||||
|
gtk_widget_pop_visual ();
|
||||||
|
|
||||||
|
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, width, height);
|
||||||
|
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root),
|
||||||
|
GNOME_TYPE_CANVAS_PIXBUF, "pixbuf", pb, NULL);
|
||||||
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), canvas);
|
||||||
|
gtk_widget_show_all (frame);
|
||||||
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
userhelper_parse_childout(char* outline)
|
userhelper_parse_childout(char* outline)
|
||||||
{
|
{
|
||||||
char *prompt;
|
char *prompt;
|
||||||
char *rest = NULL;
|
char *rest = NULL;
|
||||||
char *title;
|
char *title;
|
||||||
int prompt_type;
|
int prompt_type;
|
||||||
static response *resp = NULL;
|
static response *resp = NULL;
|
||||||
GdkPixmap *pixmap;
|
GtkWidget *pixmap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (resp != NULL) {
|
if (resp != NULL) {
|
||||||
if(!GTK_IS_WINDOW(resp->top)) {
|
if(!GTK_IS_WINDOW(resp->top)) {
|
||||||
g_free(resp->user);
|
g_free(resp->user);
|
||||||
g_free(resp);
|
g_free(resp);
|
||||||
resp = NULL;
|
resp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp == NULL) {
|
if (resp == NULL) {
|
||||||
GtkWidget *vbox, *hbox, *sbox;
|
GtkWidget *hbox;
|
||||||
|
|
||||||
resp = g_malloc0(sizeof(response));
|
resp = g_malloc0(sizeof(response));
|
||||||
|
|
||||||
resp->user = g_strdup(getlogin());
|
resp->user = g_strdup(getlogin());
|
||||||
resp->top = gtk_window_new(GTK_WINDOW_DIALOG);
|
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->top), "destroy",
|
|
||||||
GTK_SIGNAL_FUNC(mark_void), &resp->top);
|
|
||||||
gtk_window_set_title(GTK_WINDOW(resp->top), _("Input"));
|
|
||||||
gtk_window_position(GTK_WINDOW(resp->top), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(resp->top), 5);
|
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->top), "map",
|
|
||||||
GTK_SIGNAL_FUNC(userhelper_grab_focus), NULL);
|
|
||||||
|
|
||||||
resp->table = gtk_table_new(1, 2, FALSE);
|
|
||||||
resp->rows = 1;
|
|
||||||
|
|
||||||
vbox = gtk_vbox_new(FALSE, 4);
|
resp->top = gnome_dialog_new (_("Input"),
|
||||||
sbox = gtk_hbox_new(TRUE, 4);
|
GNOME_STOCK_BUTTON_OK,
|
||||||
hbox = gtk_hbutton_box_new();
|
GNOME_STOCK_BUTTON_CANCEL,
|
||||||
gtk_object_set_data(GTK_OBJECT(resp->top), UH_ACTION_AREA, hbox);
|
NULL);
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), resp->table, TRUE, TRUE, 4);
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 4);
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), sbox, FALSE, FALSE, 4);
|
|
||||||
gtk_box_pack_start(GTK_BOX(sbox), hbox, FALSE, FALSE, 4);
|
|
||||||
gtk_container_add(GTK_CONTAINER(resp->top), vbox);
|
|
||||||
|
|
||||||
pixmap = gdk_pixmap_create_from_xpm(gdk_window_foreign_new(GDK_ROOT_WINDOW()),
|
gnome_dialog_close_hides (GNOME_DIALOG (resp->top), TRUE);
|
||||||
NULL, NULL, UH_KEY_PIXMAP_PATH);
|
gnome_dialog_set_default (GNOME_DIALOG (resp->top), 0);
|
||||||
if(pixmap != NULL) {
|
|
||||||
GtkWidget *pm = gtk_pixmap_new(pixmap, NULL);
|
gtk_window_position(GTK_WINDOW(resp->top), GTK_WIN_POS_CENTER);
|
||||||
if(pm != NULL) {
|
|
||||||
GtkWidget *frame = NULL;
|
|
||||||
frame = gtk_frame_new(NULL);
|
|
||||||
gtk_container_add(GTK_CONTAINER(frame), pm);
|
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), frame,
|
|
||||||
0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 2, 2);
|
|
||||||
resp->left = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resp->ok = gtk_button_new_with_label(_(UD_OK_TEXT));
|
gtk_signal_connect(GTK_OBJECT(resp->top), "map",
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->ok)->child), 4, 0);
|
GTK_SIGNAL_FUNC(userhelper_grab_focus), NULL);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), resp->ok, FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
resp->cancel = gtk_button_new_with_label(_(UD_CANCEL_TEXT));
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_BIG);
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->cancel)->child), 4, 0);
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (resp->top)->vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), resp->cancel, FALSE, FALSE, 0);
|
|
||||||
|
pixmap = make_pixmap (UH_KEY_PIXMAP_PATH);
|
||||||
|
if(pixmap != NULL) {
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->top), "delete_event",
|
resp->table = gtk_table_new (1, 2, FALSE);
|
||||||
(GtkSignalFunc) userhelper_fatal_error, NULL);
|
resp->rows = 1;
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->cancel), "clicked",
|
|
||||||
(GtkSignalFunc) userhelper_fatal_error, NULL);
|
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->ok), "clicked",
|
gtk_object_set_data(GTK_OBJECT(resp->top), UH_ACTION_AREA, hbox);
|
||||||
(GtkSignalFunc) userhelper_write_childin, resp);
|
gtk_box_pack_start(GTK_BOX(hbox), resp->table, TRUE, TRUE, GNOME_PAD);
|
||||||
|
|
||||||
gtk_object_set_user_data(GTK_OBJECT(resp->top), resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isdigit(outline[0])) {
|
|
||||||
gboolean echo = TRUE;
|
|
||||||
message *msg = g_malloc(sizeof(message));
|
|
||||||
|
|
||||||
prompt_type = strtol(outline, &prompt, 10);
|
|
||||||
if((prompt != NULL) && (strlen(prompt) > 0)) {
|
|
||||||
while((isspace(prompt[0]) && (prompt[0] != '\0') && (prompt[0] != '\n'))){
|
|
||||||
prompt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* snip off terminating newlines in the prompt string and save a pointer to
|
|
||||||
* interate the parser along */
|
|
||||||
rest = strchr(prompt, '\n');
|
|
||||||
if(rest != NULL) {
|
|
||||||
*rest = '\0';
|
|
||||||
rest++;
|
|
||||||
if (rest[0] == '\0') {
|
|
||||||
rest = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUG_USERHELPER
|
|
||||||
g_print("(%d) \"%s\"\n", prompt_type, prompt);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
msg->type = prompt_type;
|
|
||||||
msg->message = prompt;
|
|
||||||
msg->data = NULL;
|
|
||||||
msg->entry = NULL;
|
|
||||||
|
|
||||||
echo = TRUE;
|
|
||||||
switch(prompt_type) {
|
|
||||||
case UH_ECHO_OFF_PROMPT:
|
|
||||||
echo = FALSE;
|
|
||||||
/* fall through */
|
|
||||||
case UH_ECHO_ON_PROMPT:
|
|
||||||
msg->label = gtk_label_new(prompt);
|
|
||||||
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
|
||||||
gtk_misc_set_alignment(GTK_MISC(msg->label), 1.0, 1.0);
|
|
||||||
|
|
||||||
msg->entry = gtk_entry_new();
|
|
||||||
gtk_entry_set_visibility(GTK_ENTRY(msg->entry), echo);
|
|
||||||
|
|
||||||
if(resp->head == NULL) resp->head = msg->entry;
|
|
||||||
resp->tail = msg->entry;
|
|
||||||
|
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
|
||||||
resp->left + 0, resp->left + 1, resp->rows, resp->rows + 1,
|
|
||||||
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), msg->entry,
|
|
||||||
resp->left + 1, resp->left + 2, resp->rows, resp->rows + 1,
|
|
||||||
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
|
||||||
|
|
||||||
resp->message_list = g_slist_append(resp->message_list, msg);
|
|
||||||
resp->responses++;
|
|
||||||
resp->rows++;
|
|
||||||
#ifdef DEBUG_USERHELPER
|
|
||||||
g_print(_("Need %d responses.\n"), resp->responses);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UH_FALLBACK:
|
|
||||||
#if 0
|
#if 0
|
||||||
msg->label = gtk_label_new(prompt);
|
resp->ok = gtk_button_new_with_label(_(UD_OK_TEXT));
|
||||||
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->ok)->child), 4, 0);
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
gtk_box_pack_start(GTK_BOX(hbox), resp->ok, FALSE, FALSE, 0);
|
||||||
resp->left + 0, resp->left + 2, resp->rows, resp->rows + 1,
|
|
||||||
0, 0, 2, 2);
|
resp->cancel = gtk_button_new_with_label(_(UD_CANCEL_TEXT));
|
||||||
resp->message_list = g_slist_append(resp->message_list, msg);
|
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->cancel)->child), 4, 0);
|
||||||
#else
|
gtk_box_pack_start(GTK_BOX(hbox), resp->cancel, FALSE, FALSE, 0);
|
||||||
resp->fallback = atoi(prompt) != 0;
|
|
||||||
|
gtk_signal_connect(GTK_OBJECT(resp->top), "delete_event",
|
||||||
|
(GtkSignalFunc) userhelper_fatal_error, NULL);
|
||||||
|
gtk_signal_connect(GTK_OBJECT(resp->cancel), "clicked",
|
||||||
|
(GtkSignalFunc) userhelper_fatal_error, NULL);
|
||||||
|
|
||||||
|
gtk_signal_connect(GTK_OBJECT(resp->ok), "clicked",
|
||||||
|
(GtkSignalFunc) userhelper_write_childin, resp);
|
||||||
#endif
|
#endif
|
||||||
break;
|
|
||||||
|
|
||||||
case UH_USER:
|
gtk_object_set_user_data(GTK_OBJECT(resp->top), resp);
|
||||||
if(strstr(prompt, "<user>") == NULL) {
|
gtk_widget_show_all (hbox);
|
||||||
g_free(resp->user);
|
|
||||||
resp->user = g_strdup(prompt);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UH_SERVICE_NAME:
|
|
||||||
title = g_strdup_printf(_("In order to run \"%s\" with root's "
|
|
||||||
"privileges, additional information is "
|
|
||||||
"required."),
|
|
||||||
prompt);
|
|
||||||
msg->label = gtk_label_new(title);
|
|
||||||
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
|
||||||
0, resp->left + 2, 0, 1,
|
|
||||||
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
|
||||||
resp->message_list = g_slist_append(resp->message_list, msg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UH_ERROR_MSG:
|
|
||||||
gtk_window_set_title(GTK_WINDOW(resp->top), _("Error"));
|
|
||||||
/* fall through */
|
|
||||||
case UH_INFO_MSG:
|
|
||||||
msg->label = gtk_label_new(prompt);
|
|
||||||
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
|
||||||
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
|
||||||
resp->left + 0, resp->left + 2, resp->rows, resp->rows + 1, 0, 0, 2, 2);
|
|
||||||
resp->message_list = g_slist_append(resp->message_list, msg);
|
|
||||||
resp->rows++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UH_EXPECT_RESP:
|
|
||||||
g_free(msg); /* useless */
|
|
||||||
if (resp->responses != atoi(prompt)) {
|
|
||||||
g_print(_("You want %d response(s) from %d entry fields!?!?!\n"),
|
|
||||||
atoi(prompt), resp->responses);
|
|
||||||
exit (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp->fallback) {
|
if(isdigit(outline[0])) {
|
||||||
gpointer a = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(resp->top),
|
gboolean echo = TRUE;
|
||||||
UH_ACTION_AREA));
|
message *msg = g_malloc(sizeof(message));
|
||||||
GtkWidget *hbox = GTK_WIDGET(a);
|
|
||||||
resp->unprivileged = gtk_button_new_with_label(_(UD_FALLBACK_TEXT));
|
prompt_type = strtol(outline, &prompt, 10);
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->unprivileged)->child),
|
if((prompt != NULL) && (strlen(prompt) > 0)) {
|
||||||
4, 0);
|
while((isspace(prompt[0]) && (prompt[0] != '\0') && (prompt[0] != '\n'))){
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), resp->unprivileged,
|
prompt++;
|
||||||
FALSE, FALSE, 0);
|
}
|
||||||
if(resp->unprivileged != NULL) {
|
}
|
||||||
gtk_signal_connect(GTK_OBJECT(resp->unprivileged), "clicked",
|
|
||||||
GTK_SIGNAL_FUNC(userhelper_write_childin), resp);
|
/* snip off terminating newlines in the prompt string and save a pointer to
|
||||||
}
|
* interate the parser along */
|
||||||
|
rest = strchr(prompt, '\n');
|
||||||
|
if(rest != NULL) {
|
||||||
|
*rest = '\0';
|
||||||
|
rest++;
|
||||||
|
if (rest[0] == '\0') {
|
||||||
|
rest = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DEBUG_USERHELPER
|
||||||
|
g_print("(%d) \"%s\"\n", prompt_type, prompt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
msg->type = prompt_type;
|
||||||
|
msg->message = prompt;
|
||||||
|
msg->data = NULL;
|
||||||
|
msg->entry = NULL;
|
||||||
|
|
||||||
|
echo = TRUE;
|
||||||
|
switch(prompt_type) {
|
||||||
|
case UH_ECHO_OFF_PROMPT:
|
||||||
|
echo = FALSE;
|
||||||
|
/* fall through */
|
||||||
|
case UH_ECHO_ON_PROMPT:
|
||||||
|
msg->label = gtk_label_new(prompt);
|
||||||
|
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(msg->label), 1.0, 1.0);
|
||||||
|
|
||||||
|
msg->entry = gtk_entry_new();
|
||||||
|
gtk_entry_set_visibility(GTK_ENTRY(msg->entry), echo);
|
||||||
|
|
||||||
|
if(resp->head == NULL) resp->head = msg->entry;
|
||||||
|
resp->tail = msg->entry;
|
||||||
|
|
||||||
|
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
||||||
|
resp->left + 0, resp->left + 1, resp->rows, resp->rows + 1,
|
||||||
|
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
||||||
|
gtk_table_attach(GTK_TABLE(resp->table), msg->entry,
|
||||||
|
resp->left + 1, resp->left + 2, resp->rows, resp->rows + 1,
|
||||||
|
GTK_EXPAND | GTK_FILL, 0, 2, 2);
|
||||||
|
|
||||||
|
resp->message_list = g_slist_append(resp->message_list, msg);
|
||||||
|
resp->responses++;
|
||||||
|
resp->rows++;
|
||||||
|
#ifdef DEBUG_USERHELPER
|
||||||
|
g_print(_("Need %d responses.\n"), resp->responses);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UH_FALLBACK:
|
||||||
|
#if 0
|
||||||
|
msg->label = gtk_label_new(prompt);
|
||||||
|
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
||||||
|
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
||||||
|
resp->left + 0, resp->left + 2, resp->rows, resp->rows + 1,
|
||||||
|
0, 0, 2, 2);
|
||||||
|
resp->message_list = g_slist_append(resp->message_list, msg);
|
||||||
|
#else
|
||||||
|
resp->fallback = atoi(prompt) != 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UH_USER:
|
||||||
|
if(strstr(prompt, "<user>") == NULL) {
|
||||||
|
g_free(resp->user);
|
||||||
|
resp->user = g_strdup(prompt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UH_SERVICE_NAME:
|
||||||
|
title = _("In order to make changes to your system, you\n"
|
||||||
|
"must enter the administrator (root) password.");
|
||||||
|
|
||||||
|
msg->label = gtk_label_new(title);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (msg->label), 0.5, 0.0);
|
||||||
|
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
||||||
|
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
||||||
|
0, resp->left + 2, 0, 1,
|
||||||
|
GTK_EXPAND | GTK_FILL,
|
||||||
|
GTK_EXPAND | GTK_FILL, 2, 2);
|
||||||
|
resp->message_list = g_slist_append(resp->message_list, msg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UH_ERROR_MSG:
|
||||||
|
gtk_window_set_title(GTK_WINDOW(resp->top), _("Error"));
|
||||||
|
/* fall through */
|
||||||
|
case UH_INFO_MSG:
|
||||||
|
msg->label = gtk_label_new(prompt);
|
||||||
|
gtk_label_set_line_wrap(GTK_LABEL(msg->label), FALSE);
|
||||||
|
gtk_table_attach(GTK_TABLE(resp->table), msg->label,
|
||||||
|
resp->left + 0, resp->left + 2, resp->rows, resp->rows + 1, 0, 0, 2, 2);
|
||||||
|
resp->message_list = g_slist_append(resp->message_list, msg);
|
||||||
|
resp->rows++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UH_EXPECT_RESP:
|
||||||
|
g_free(msg); /* useless */
|
||||||
|
if (resp->responses != atoi(prompt)) {
|
||||||
|
g_print(_("You want %d response(s) from %d entry fields!?!?!\n"),
|
||||||
|
atoi(prompt), resp->responses);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resp->fallback) {
|
||||||
|
gnome_dialog_append_button (GNOME_DIALOG (resp->top), _("Run Unprivileged"));
|
||||||
|
#if 0
|
||||||
|
gpointer a = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(resp->top),
|
||||||
|
UH_ACTION_AREA));
|
||||||
|
GtkWidget *hbox = GTK_WIDGET(a);
|
||||||
|
resp->unprivileged = gtk_button_new_with_label(_(UD_FALLBACK_TEXT));
|
||||||
|
gtk_misc_set_padding(GTK_MISC(GTK_BIN(resp->unprivileged)->child),
|
||||||
|
4, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), resp->unprivileged,
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
if(resp->unprivileged != NULL) {
|
||||||
|
gtk_signal_connect(GTK_OBJECT(resp->unprivileged), "clicked",
|
||||||
|
GTK_SIGNAL_FUNC(userhelper_write_childin), resp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* here is where we do the thingie */
|
||||||
|
gtk_widget_show_all (resp->table);
|
||||||
|
|
||||||
|
if(GTK_IS_ENTRY(resp->head)) {
|
||||||
|
gtk_widget_grab_focus(resp->head);
|
||||||
|
}
|
||||||
|
if(GTK_IS_ENTRY(resp->tail)) {
|
||||||
|
gnome_dialog_editable_enters (GNOME_DIALOG (resp->top),
|
||||||
|
GTK_EDITABLE (resp->tail));
|
||||||
|
}
|
||||||
|
ret = gnome_dialog_run_and_close (GNOME_DIALOG (resp->top));
|
||||||
|
userhelper_write_childin (ret, resp);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* ignore, I guess... */
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show_all(resp->top);
|
if(rest != NULL) userhelper_parse_childout(rest);
|
||||||
if(GTK_IS_ENTRY(resp->head)) {
|
|
||||||
gtk_widget_grab_focus(resp->head);
|
|
||||||
}
|
|
||||||
if(GTK_IS_ENTRY(resp->tail)) {
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(resp->tail), "activate",
|
|
||||||
gtk_button_clicked, GTK_OBJECT(resp->ok));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* ignore, I guess... */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rest != NULL) userhelper_parse_childout(rest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
userhelper_read_childout(gpointer data, int source, GdkInputCondition cond)
|
userhelper_read_childout(gpointer data, int source, GdkInputCondition cond)
|
||||||
{
|
{
|
||||||
char* output;
|
char* output;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if(cond != GDK_INPUT_READ)
|
if(cond != GDK_INPUT_READ)
|
||||||
{
|
{
|
||||||
/* Serious error, this is. Panic. */
|
/* Serious error, this is. Panic. */
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
output = g_malloc(MAXLINE + 1);
|
output = g_malloc(MAXLINE + 1);
|
||||||
|
|
||||||
count = read(source, output, MAXLINE);
|
count = read(source, output, MAXLINE);
|
||||||
if (count == -1)
|
if (count == -1)
|
||||||
{
|
{
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
gdk_input_remove(childout_tag);
|
gdk_input_remove(childout_tag);
|
||||||
childout_tag = -1;
|
childout_tag = -1;
|
||||||
}
|
}
|
||||||
output[count] = '\0';
|
output[count] = '\0';
|
||||||
|
|
||||||
userhelper_parse_childout(output);
|
userhelper_parse_childout(output);
|
||||||
g_free(output);
|
g_free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
userhelper_write_childin(GtkWidget *widget, response *resp)
|
userhelper_write_childin(int button, response *resp)
|
||||||
{
|
{
|
||||||
char* input;
|
char* input;
|
||||||
int len;
|
int len;
|
||||||
guchar byte;
|
guchar byte;
|
||||||
GSList *message_list = resp->message_list;
|
GSList *message_list = resp->message_list;
|
||||||
|
|
||||||
if(widget == resp->unprivileged) {
|
switch (button) {
|
||||||
byte = UH_ABORT;
|
case 2:
|
||||||
for (message_list = resp->message_list;
|
byte = UH_ABORT;
|
||||||
(message_list != NULL) && (message_list->data != NULL);
|
for (message_list = resp->message_list;
|
||||||
message_list = g_slist_next(message_list)) {
|
(message_list != NULL) && (message_list->data != NULL);
|
||||||
message *m = (message*)message_list->data;
|
message_list = g_slist_next(message_list)) {
|
||||||
|
message *m = (message*)message_list->data;
|
||||||
#ifdef DEBUG_USERHELPER
|
#ifdef DEBUG_USERHELPER
|
||||||
fprintf(stderr, "message %d, \"%s\"\n", m->type, m->message);
|
fprintf(stderr, "message %d, \"%s\"\n", m->type, m->message);
|
||||||
#endif
|
#endif
|
||||||
if(GTK_IS_ENTRY(m->entry)) {
|
if(GTK_IS_ENTRY(m->entry)) {
|
||||||
write(childin[1], &byte, 1);
|
write(childin[1], &byte, 1);
|
||||||
write(childin[1], "\n", 1);
|
write(childin[1], "\n", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if(widget == resp->ok) {
|
case 0:
|
||||||
byte = UH_TEXT;
|
byte = UH_TEXT;
|
||||||
for (message_list = resp->message_list;
|
for (message_list = resp->message_list;
|
||||||
(message_list != NULL) && (message_list->data != NULL);
|
(message_list != NULL) && (message_list->data != NULL);
|
||||||
message_list = g_slist_next(message_list)) {
|
message_list = g_slist_next(message_list)) {
|
||||||
message *m = (message*)message_list->data;
|
message *m = (message*)message_list->data;
|
||||||
#ifdef DEBUG_USERHELPER
|
#ifdef DEBUG_USERHELPER
|
||||||
fprintf(stderr, "message %d, \"%s\"\n", m->type, m->message);
|
fprintf(stderr, "message %d, \"%s\"\n", m->type, m->message);
|
||||||
#endif
|
#endif
|
||||||
if(GTK_IS_ENTRY(m->entry)) {
|
if(GTK_IS_ENTRY(m->entry)) {
|
||||||
input = gtk_entry_get_text(GTK_ENTRY(m->entry));
|
input = gtk_entry_get_text(GTK_ENTRY(m->entry));
|
||||||
len = strlen(input);
|
len = strlen(input);
|
||||||
write(childin[1], &byte, 1);
|
write(childin[1], &byte, 1);
|
||||||
write(childin[1], input, len);
|
write(childin[1], input, len);
|
||||||
write(childin[1], "\n", 1);
|
write(childin[1], "\n", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
gtk_widget_destroy(resp->top);
|
default:
|
||||||
|
gtk_main_quit ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gtk_widget_destroy(resp->top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
userhelper_sigchld()
|
userhelper_sigchld()
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
signal(SIGCHLD, userhelper_sigchld);
|
signal(SIGCHLD, userhelper_sigchld);
|
||||||
|
|
||||||
pid = waitpid(0, &status, WNOHANG);
|
pid = waitpid(0, &status, WNOHANG);
|
||||||
|
|
||||||
if(WIFEXITED(status))
|
if(WIFEXITED(status))
|
||||||
{
|
{
|
||||||
userhelper_parse_exitstatus(WEXITSTATUS(status));
|
userhelper_parse_exitstatus(WEXITSTATUS(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 1997-1999 Red Hat Software, Inc.
|
/* Copyright (C) 1997-1999 Red Hat Software, Inc.
|
||||||
|
* Copyright 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* This is free software; you can redistribute it and/or modify it
|
* This is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,7 +20,6 @@
|
||||||
#define __USERHELPER_WRAP_H__
|
#define __USERHELPER_WRAP_H__
|
||||||
|
|
||||||
/* lots 'o includes. */
|
/* lots 'o includes. */
|
||||||
#include "userdialogs.h"
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -59,7 +59,7 @@ void userhelper_runv(char *path, int new_fd);
|
||||||
void userhelper_parse_exitstatus(int exitstatus);
|
void userhelper_parse_exitstatus(int exitstatus);
|
||||||
void userhelper_parse_childout();
|
void userhelper_parse_childout();
|
||||||
void userhelper_read_childout(gpointer data, int source, GdkInputCondition cond);
|
void userhelper_read_childout(gpointer data, int source, GdkInputCondition cond);
|
||||||
void userhelper_write_childin(GtkWidget* widget, response *resp);
|
void userhelper_write_childin(int button, response *resp);
|
||||||
|
|
||||||
void userhelper_sigchld(); /* sigchld handler */
|
void userhelper_sigchld(); /* sigchld handler */
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* -*-Mode: c-*- */
|
/* -*-Mode: c-*- */
|
||||||
/* Copyright (C) 1997 Red Hat Software, Inc.
|
/* Copyright (C) 1997 Red Hat Software, Inc.
|
||||||
|
* Copyright 2001 Ximian Inc.
|
||||||
*
|
*
|
||||||
* This is free software; you can redistribute it and/or modify it
|
* This is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
|
@ -57,6 +58,8 @@
|
||||||
#include "root-manager.h"
|
#include "root-manager.h"
|
||||||
#include "shvar.h"
|
#include "shvar.h"
|
||||||
|
|
||||||
|
#define _(s) gettext(s)
|
||||||
|
|
||||||
/* Total GECOS field length... is this enough ? */
|
/* Total GECOS field length... is this enough ? */
|
||||||
#define GECOS_LENGTH 80
|
#define GECOS_LENGTH 80
|
||||||
|
|
||||||
|
@ -438,12 +441,16 @@ int main(int argc, char *argv[])
|
||||||
exit(ERR_NO_RIGHTS);
|
exit(ERR_NO_RIGHTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2) {
|
||||||
g_error ("Usage: root-helper fd");
|
fprintf(stderr, _("Usage: root-helper fd"));
|
||||||
|
exit(ERR_INVALID_CALL);
|
||||||
|
}
|
||||||
|
|
||||||
fd = atoi (argv[1]);
|
fd = atoi (argv[1]);
|
||||||
if (fd <= STDERR_FILENO)
|
if (fd <= STDERR_FILENO) {
|
||||||
g_error ("Usage: root-helper fd");
|
fprintf (stderr, _("Usage: root-helper fd"));
|
||||||
|
exit(ERR_INVALID_CALL);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_USERHELPER
|
#ifdef DEBUG_USERHELPER
|
||||||
fprintf (stderr, "fd is %d\n", fd);
|
fprintf (stderr, "fd is %d\n", fd);
|
||||||
|
@ -598,6 +605,7 @@ int main(int argc, char *argv[])
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
{
|
{
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
|
fprintf (stdout, "success\n");
|
||||||
#ifdef DEBUG_USERHELPER
|
#ifdef DEBUG_USERHELPER
|
||||||
fprintf (stderr, "looping for input\n");
|
fprintf (stderr, "looping for input\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -615,7 +623,7 @@ int main(int argc, char *argv[])
|
||||||
"/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/root/bin", 1);
|
"/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/root/bin", 1);
|
||||||
|
|
||||||
execv (args[0], args);
|
execv (args[0], args);
|
||||||
g_error ("s", g_strerror (errno));
|
g_error ("%s", g_strerror (errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,7 +688,7 @@ int main(int argc, char *argv[])
|
||||||
"/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/root/bin", 1);
|
"/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/root/bin", 1);
|
||||||
|
|
||||||
execv (args[0], args);
|
execv (args[0], args);
|
||||||
g_error ("s", g_strerror (errno));
|
g_error ("%s", g_strerror (errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 1997-1999 Red Hat Software, Inc.
|
/* Copyright (C) 1997-1999 Red Hat Software, Inc.
|
||||||
|
* Copyright 2001 Ximian, Inc.
|
||||||
*
|
*
|
||||||
* This is free software; you can redistribute it and/or modify it
|
* This is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by
|
* under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +19,6 @@
|
||||||
#ifndef __USERHELPER_H__
|
#ifndef __USERHELPER_H__
|
||||||
#define __USERHELPER_H__
|
#define __USERHELPER_H__
|
||||||
|
|
||||||
#define _(String) gettext(String)
|
|
||||||
|
|
||||||
#define UH_ECHO_ON_PROMPT 1
|
#define UH_ECHO_ON_PROMPT 1
|
||||||
#define UH_ECHO_OFF_PROMPT 2
|
#define UH_ECHO_OFF_PROMPT 2
|
||||||
#define UH_INFO_MSG 3
|
#define UH_INFO_MSG 3
|
||||||
|
@ -46,8 +45,8 @@
|
||||||
#define ERR_EXEC_FAILED 11 /* exec failed for some reason */
|
#define ERR_EXEC_FAILED 11 /* exec failed for some reason */
|
||||||
#define ERR_UNK_ERROR 255 /* unknown error */
|
#define ERR_UNK_ERROR 255 /* unknown error */
|
||||||
|
|
||||||
#define UH_PATH "/gnome/sbin/root-manager"
|
#ifndef _
|
||||||
#define UH_KEY_PIXMAP_PATH "/usr/share/pixmaps/userhelper-keys.xpm"
|
#define _(s) gettext(s)
|
||||||
/*#define UH_PATH "./root-manager"*/
|
#endif
|
||||||
|
|
||||||
#endif /* __USERHELPER_H__ */
|
#endif /* __USERHELPER_H__ */
|
||||||
|
|
|
@ -1,229 +0,0 @@
|
||||||
/* -*-Mode: c-*- */
|
|
||||||
/* Copyright (C) 1997 Red Hat Software, Inc.
|
|
||||||
*
|
|
||||||
* This is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#include <locale.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#define _(String) gettext(String)
|
|
||||||
#include "userdialogs.h"
|
|
||||||
|
|
||||||
GtkWidget*
|
|
||||||
create_message_box(gchar* message, gchar* title)
|
|
||||||
{
|
|
||||||
GtkWidget* message_box;
|
|
||||||
GtkWidget* label;
|
|
||||||
GtkWidget* hbox;
|
|
||||||
GtkWidget* ok;
|
|
||||||
|
|
||||||
message_box = gtk_dialog_new();
|
|
||||||
gtk_window_position(GTK_WINDOW(message_box), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(message_box), 5);
|
|
||||||
if(title == NULL)
|
|
||||||
gtk_window_set_title(GTK_WINDOW(message_box), _("Message"));
|
|
||||||
else
|
|
||||||
gtk_window_set_title(GTK_WINDOW(message_box), title);
|
|
||||||
|
|
||||||
label = gtk_label_new(message);
|
|
||||||
hbox = gtk_hbox_new(TRUE, 5);
|
|
||||||
ok = gtk_button_new_with_label(_(UD_OK_TEXT));
|
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(ok)->child), 4, 0);
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(ok), "clicked",
|
|
||||||
(GtkSignalFunc) gtk_widget_destroy,
|
|
||||||
(gpointer) message_box);
|
|
||||||
gtk_widget_set_usize(ok, 50, 0);
|
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(message_box)->vbox), hbox,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(message_box)->action_area), ok,
|
|
||||||
FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default(ok);
|
|
||||||
|
|
||||||
gtk_widget_show(ok);
|
|
||||||
gtk_widget_show(label);
|
|
||||||
gtk_widget_show(hbox);
|
|
||||||
gtk_widget_show(message_box);
|
|
||||||
|
|
||||||
return message_box;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* conslidate error_box and message_box.. they're the same damn thing
|
|
||||||
* with a different default title.
|
|
||||||
*/
|
|
||||||
GtkWidget*
|
|
||||||
create_error_box(gchar* error, gchar* title)
|
|
||||||
{
|
|
||||||
GtkWidget* error_box;
|
|
||||||
GtkWidget* label;
|
|
||||||
GtkWidget* hbox;
|
|
||||||
GtkWidget* ok;
|
|
||||||
|
|
||||||
error_box = gtk_dialog_new();
|
|
||||||
gtk_window_position(GTK_WINDOW(error_box), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(error_box), 5);
|
|
||||||
if(title == NULL)
|
|
||||||
gtk_window_set_title(GTK_WINDOW(error_box), _("Error"));
|
|
||||||
else
|
|
||||||
gtk_window_set_title(GTK_WINDOW(error_box), title);
|
|
||||||
|
|
||||||
label = gtk_label_new(error);
|
|
||||||
hbox = gtk_hbox_new(TRUE, 5);
|
|
||||||
ok = gtk_button_new_with_label(_(UD_OK_TEXT));
|
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(ok)->child), 4, 0);
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(ok), "clicked",
|
|
||||||
(GtkSignalFunc) gtk_widget_destroy,
|
|
||||||
(gpointer) error_box);
|
|
||||||
gtk_widget_set_usize(ok, 50, 0);
|
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(error_box)->vbox), hbox,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(error_box)->action_area), ok,
|
|
||||||
FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default(ok);
|
|
||||||
|
|
||||||
gtk_widget_show(ok);
|
|
||||||
gtk_widget_show(label);
|
|
||||||
gtk_widget_show(hbox);
|
|
||||||
gtk_widget_show(error_box);
|
|
||||||
|
|
||||||
return error_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget*
|
|
||||||
create_query_box(gchar* prompt, gchar* title, GtkSignalFunc func)
|
|
||||||
{
|
|
||||||
GtkWidget* query_box;
|
|
||||||
GtkWidget* label;
|
|
||||||
GtkWidget* entry;
|
|
||||||
GtkWidget* hbox;
|
|
||||||
GtkWidget* ok;
|
|
||||||
|
|
||||||
query_box = gtk_dialog_new();
|
|
||||||
gtk_window_position(GTK_WINDOW(query_box), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(query_box), 5);
|
|
||||||
if(title == NULL)
|
|
||||||
gtk_window_set_title(GTK_WINDOW(query_box), _("Prompt"));
|
|
||||||
else
|
|
||||||
gtk_window_set_title(GTK_WINDOW(query_box), _("Prompt"));
|
|
||||||
|
|
||||||
label = gtk_label_new(prompt);
|
|
||||||
entry = gtk_entry_new();
|
|
||||||
ok = gtk_button_new_with_label(_(UD_OK_TEXT));
|
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(ok)->child), 4, 0);
|
|
||||||
gtk_widget_set_usize(ok, 50, 0);
|
|
||||||
|
|
||||||
hbox = gtk_hbox_new(TRUE, 0);
|
|
||||||
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(entry), "activate",
|
|
||||||
(GtkSignalFunc) gtk_button_clicked,
|
|
||||||
(gpointer) GTK_BUTTON(ok));
|
|
||||||
|
|
||||||
/* FIXME: memory leak... well, not really. Just rely on the caller
|
|
||||||
* to free the widget... 'cept that's not nice either. :-S
|
|
||||||
*/
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(ok), "clicked",
|
|
||||||
(GtkSignalFunc) gtk_widget_hide,
|
|
||||||
(gpointer) query_box);
|
|
||||||
if(func != NULL)
|
|
||||||
{
|
|
||||||
gtk_signal_connect(GTK_OBJECT(ok), "clicked", func, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->vbox), label,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->vbox), hbox,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->action_area), ok,
|
|
||||||
TRUE, FALSE, 0);
|
|
||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default(ok);
|
|
||||||
|
|
||||||
gtk_widget_grab_focus(entry);
|
|
||||||
|
|
||||||
gtk_widget_show(ok);
|
|
||||||
gtk_widget_show(label);
|
|
||||||
gtk_widget_show(entry);
|
|
||||||
gtk_widget_show(hbox);
|
|
||||||
gtk_widget_show(query_box);
|
|
||||||
|
|
||||||
return query_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget*
|
|
||||||
create_invisible_query_box(gchar* prompt, gchar* title, GtkSignalFunc func)
|
|
||||||
{
|
|
||||||
GtkWidget* query_box;
|
|
||||||
GtkWidget* label;
|
|
||||||
GtkWidget* entry;
|
|
||||||
GtkWidget* hbox;
|
|
||||||
GtkWidget* ok;
|
|
||||||
|
|
||||||
query_box = gtk_dialog_new();
|
|
||||||
gtk_window_position(GTK_WINDOW(query_box), GTK_WIN_POS_CENTER);
|
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(query_box), 5);
|
|
||||||
gtk_window_set_title(GTK_WINDOW(query_box), _("Prompt"));
|
|
||||||
/* gtk_container_border_width(GTK_CONTAINER(GTK_DIALOG(query_box)->vbox), 5); */
|
|
||||||
label = gtk_label_new(prompt);
|
|
||||||
entry = gtk_entry_new();
|
|
||||||
gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
|
|
||||||
|
|
||||||
hbox = gtk_hbox_new(TRUE, 5);
|
|
||||||
|
|
||||||
ok = gtk_button_new_with_label(_("OK"));
|
|
||||||
gtk_misc_set_padding(GTK_MISC(GTK_BIN(ok)->child), 4, 0);
|
|
||||||
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(entry), "activate",
|
|
||||||
(GtkSignalFunc) gtk_button_clicked,
|
|
||||||
(gpointer) GTK_BUTTON(ok));
|
|
||||||
gtk_signal_connect_object(GTK_OBJECT(ok), "clicked",
|
|
||||||
(GtkSignalFunc) gtk_widget_hide,
|
|
||||||
(gpointer) query_box);
|
|
||||||
gtk_widget_set_usize(ok, 50, 0);
|
|
||||||
|
|
||||||
if(func != NULL)
|
|
||||||
{
|
|
||||||
gtk_signal_connect(GTK_OBJECT(ok), "clicked", func, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->vbox), label,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->vbox), hbox,
|
|
||||||
FALSE, FALSE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(query_box)->action_area), ok,
|
|
||||||
TRUE, FALSE, 0);
|
|
||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
||||||
gtk_widget_grab_default(ok);
|
|
||||||
|
|
||||||
gtk_widget_grab_focus(entry);
|
|
||||||
|
|
||||||
gtk_widget_show(ok);
|
|
||||||
gtk_widget_show(label);
|
|
||||||
gtk_widget_show(entry);
|
|
||||||
gtk_widget_show(hbox);
|
|
||||||
gtk_widget_show(query_box);
|
|
||||||
|
|
||||||
return query_box;
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/* -*-Mode: c-*- */
|
|
||||||
/* Copyright (C) 1997 Red Hat Software, Inc.
|
|
||||||
*
|
|
||||||
* This is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __USERDIALOGS_H__
|
|
||||||
#define __USERDIALOGS_H__
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#define i18n(String) gettext(String)
|
|
||||||
#define N_(String) String
|
|
||||||
|
|
||||||
#define UD_OK_TEXT N_("OK")
|
|
||||||
#define UD_HELP_TEXT N_("Help")
|
|
||||||
#define UD_CANCEL_TEXT N_("Cancel")
|
|
||||||
#define UD_EXIT_TEXT N_("Exit")
|
|
||||||
#define UD_FALLBACK_TEXT N_("Run Unprivileged")
|
|
||||||
|
|
||||||
/* consider a "has args" arg, so I can use the arg argument or not at will */
|
|
||||||
GtkWidget* create_message_box(gchar* message, gchar* title);
|
|
||||||
GtkWidget* create_error_box(gchar* error, gchar* title);
|
|
||||||
GtkWidget* create_query_box(gchar* prompt, gchar* title, GtkSignalFunc func);
|
|
||||||
GtkWidget* create_invisible_query_box(gchar* prompt, gchar* title,
|
|
||||||
GtkSignalFunc func);
|
|
||||||
|
|
||||||
#endif /* __USERDIALOGS_H__ */
|
|
BIN
root-manager/xst-keys.png
Normal file
After Width: | Height: | Size: 3.7 KiB |