Initial port to GNOME2, removal of gtkhtml deps.

2001-11-26  Richard Hestilow  <hestilow@ximian.com>

	* Initial port to GNOME2, removal of gtkhtml deps.
This commit is contained in:
Richard Hestilow 2001-11-26 17:06:41 +00:00 committed by Rachel Hestilow
parent 575c8e852f
commit 45c1c24057
12 changed files with 867 additions and 450 deletions

View file

@ -1,3 +1,7 @@
2001-11-26 Richard Hestilow <hestilow@ximian.com>
* Initial port to GNOME2, removal of gtkhtml deps.
2001-10-26 Bradford Hovinen <hovinen@ximian.com> 2001-10-26 Bradford Hovinen <hovinen@ximian.com>
* main.c: Remove #ifdef HAVE_BONOBO instances * main.c: Remove #ifdef HAVE_BONOBO instances

View file

@ -31,7 +31,8 @@ INCLUDES = \
-DPIXMAPS_DIR=\""$(appicondir)"\" \ -DPIXMAPS_DIR=\""$(appicondir)"\" \
-DART_DIR=\""$(splashdir)"\" \ -DART_DIR=\""$(splashdir)"\" \
-DGNOME_SBINDIR=\""$(sbindir)"\" \ -DGNOME_SBINDIR=\""$(sbindir)"\" \
@GNOMECC_CFLAGS@ -I/gnome/head/INSTALL/include/gnome-desktop-2.0 \
@GNOMECC_CFLAGS@
bin_PROGRAMS = gnomecc bin_PROGRAMS = gnomecc
@ -40,13 +41,13 @@ gnomecc_SOURCES = \
capplet-dir.c capplet-dir.h \ capplet-dir.c capplet-dir.h \
capplet-dir-view.c capplet-dir-view.h \ capplet-dir-view.c capplet-dir-view.h \
preferences.c preferences.h \ preferences.c preferences.h \
capplet-dir-view-html.c \
capplet-dir-view-tree.c \ capplet-dir-view-tree.c \
capplet-dir-view-list.c capplet-dir-view-list.c
gnomecc_LDADD = \ gnomecc_LDADD = \
@GNOMECC_LIBS@ \ @GNOMECC_LIBS@ \
$(INTLLIBS) -lgnome-desktop-2
# $(INTLLIBS)
EXTRA_DIST = gnomecc.desktop.in $(appicon_DATA) $(splash_DATA) $(glade_DATA) Gnome.directory.in.in EXTRA_DIST = gnomecc.desktop.in $(appicon_DATA) $(splash_DATA) $(glade_DATA) Gnome.directory.in.in
@ -62,7 +63,7 @@ $(groups_in_files): %.directory.in: %.directory.in.in
sed s#Icon=#Icon=$(GNOMECC_ICONS_DIR)/control-center.png# < $< > $@ sed s#Icon=#Icon=$(GNOMECC_ICONS_DIR)/control-center.png# < $< > $@
$(groups_files): %.directory: %.directory.in $(groups_files): %.directory: %.directory.in
$(top_builddir)/xml-i18n-merge -d $(top_srcdir)/po $< $@ $(top_builddir)/intltool-merge -d $(top_srcdir)/po $< $@
install-data-local: install-data-local:
$(mkinstalldirs) $(DESTDIR)$(datadir)/control-center/capplets $(mkinstalldirs) $(DESTDIR)$(datadir)/control-center/capplets

View file

@ -5,6 +5,7 @@
* *
* Authors: Jacob Berkman <jacob@ximian.com> * Authors: Jacob Berkman <jacob@ximian.com>
* Bradford Hovinen <hovinen@ximian.com> * Bradford Hovinen <hovinen@ximian.com>
* Richard Hestilow <hestilow@ximian.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -24,23 +25,61 @@
#include <config.h> #include <config.h>
#include <gdk-pixbuf/gnome-canvas-pixbuf.h> #include <libgnomecanvas/gnome-canvas.h>
#include <gtk/gtk.h>
#include "capplet-dir-view.h" #include "capplet-dir-view.h"
typedef struct
{
GnomeIconList *gil;
CappletDir *root_dir;
CappletDir *current;
gboolean ignore_selection;
/* Header stuff */
GtkWidget *header;
GdkPixbuf *header_logo;
GdkGC *gc1, *gc2;
PangoLayout *layout;
gchar *header_text;
/* Sidebar */
GtkListStore *sidebar_model;
GtkWidget *sidebar;
gboolean sidebar_populated;
GdkPixbuf *arrow;
} ListViewData;
enum
{
SIDEBAR_ICON,
SIDEBAR_LABEL,
SIDEBAR_ACTIVE,
SIDEBAR_DATA
};
static void static void
list_clear (CappletDirView *view) list_clear (CappletDirView *view)
{ {
g_return_if_fail (GNOME_IS_ICON_LIST (view->view_data)); ListViewData *data = view->view_data;
gnome_icon_list_clear (GNOME_ICON_LIST (view->view_data)); g_return_if_fail (GNOME_IS_ICON_LIST (data->gil));
gnome_icon_list_clear (data->gil);
} }
static void static void
list_clean (CappletDirView *view) list_clean (CappletDirView *view)
{ {
/* i think this can be a no-op now */ ListViewData *data = view->view_data;
view->view_data = NULL;
gdk_pixbuf_unref (data->header_logo);
gdk_pixbuf_unref (data->arrow);
gdk_gc_unref (data->gc1);
gdk_gc_unref (data->gc2);
g_free (data);
} }
/* /*
@ -95,30 +134,200 @@ flatten_alpha (GdkPixbuf *image, GnomeCanvas *canvas)
return item; return item;
} }
static gpointer
real_slist_nth_data (GSList *list, guint n, guint type)
{
int i = 0;
for (; list; list = list->next)
{
if (CAPPLET_DIR_ENTRY (list->data)->type != type)
continue;
if (i == n)
return list->data;
i++;
}
}
static void
sidebar_dummy_foreach (GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, CappletDir **dir)
{
GValue val = {0, };
g_return_if_fail (dir != NULL);
g_value_init (&val, G_TYPE_POINTER);
gtk_tree_model_get_value (model, iter, SIDEBAR_DATA, &val);
*dir = g_value_get_pointer (&val);
}
static void
sidebar_select_cb (GtkTreeSelection *sel, CappletDirView *view)
{
ListViewData *data = view->view_data;
CappletDir *dir;
if (data->ignore_selection)
return;
gtk_tree_selection_selected_foreach (sel, sidebar_dummy_foreach, &dir);
data->current = dir;
capplet_dir_entry_activate (CAPPLET_DIR_ENTRY (dir), view);
}
static void
sidebar_arrow_update (CappletDirView *view)
{
ListViewData *data = view->view_data;
GSList *list, *root;
GtkTreeIter iter;
int enabled, i;
g_print ("Hi\n");
if (!data->arrow)
{
gchar *file = g_concat_dir_and_file (ART_DIR, "active.png");
data->arrow = gdk_pixbuf_new_from_file (file, NULL);
}
root = list = g_slist_append (NULL, data->root_dir);
list->next = data->root_dir->entries;
for (enabled = 0; list; list = list->next)
{
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
if (dir->type != TYPE_CAPPLET_DIR)
continue;
if (CAPPLET_DIR (dir) == data->current)
break;
enabled++;
}
g_print ("okay\n");
for (i = 0, list = root; list; list = list->next)
{
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
if (dir->type != TYPE_CAPPLET_DIR)
continue;
gtk_tree_model_iter_nth_child
(GTK_TREE_MODEL (data->sidebar_model),
&iter, NULL, i);
gtk_list_store_set (data->sidebar_model, &iter,
SIDEBAR_ACTIVE, (i == enabled) ? data->arrow : NULL,
-1);
i++;
}
g_slist_free_1 (root);
g_print ("right\n");
}
static void
sidebar_populate (CappletDirView *view)
{
ListViewData *data = view->view_data;
GSList *list, *root;
g_print ("Hi 2\n");
if (data->sidebar_populated)
{
sidebar_arrow_update (view);
return;
}
gtk_list_store_clear (data->sidebar_model);
root = list = g_slist_append (NULL, data->root_dir);
list->next = data->root_dir->entries;
for (; list; list = list->next)
{
GdkPixbuf *buf;
GtkTreeIter iter;
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
if (dir->type != TYPE_CAPPLET_DIR)
continue;
buf = gdk_pixbuf_new_from_file (dir->icon, NULL);
gtk_list_store_append (data->sidebar_model, &iter);
gtk_list_store_set (data->sidebar_model, &iter,
SIDEBAR_ICON, buf,
SIDEBAR_LABEL, dir->label,
SIDEBAR_DATA, dir,
SIDEBAR_ACTIVE, NULL,
-1);
gdk_pixbuf_unref (buf);
}
g_slist_free_1 (root); /* Just this first node */
data->sidebar_populated = TRUE;
sidebar_arrow_update (view);
}
static void static void
list_populate (CappletDirView *view) list_populate (CappletDirView *view)
{ {
GSList *list; GSList *list;
int i; int i;
GnomeCanvasItem *item; GnomeCanvasItem *item;
GtkTreeIter iter;
ListViewData *data = view->view_data;
g_return_if_fail (GNOME_IS_ICON_LIST (view->view_data)); g_return_if_fail (GNOME_IS_ICON_LIST (data->gil));
gnome_icon_list_freeze (GNOME_ICON_LIST (view->view_data)); if (!data->root_dir)
data->root_dir = view->capplet_dir;
data->ignore_selection = TRUE;
sidebar_populate (view);
for (i = 0, list = view->capplet_dir->entries; list; list = list->next, i++) { /* FIXME: Is this triggering a gtk+ bug? */
#if 0
gtk_tree_model_get_iter_root (GTK_TREE_MODEL (data->sidebar_model),
&iter);
gtk_tree_selection_select_iter (
gtk_tree_view_get_selection (GTK_TREE_VIEW (data->sidebar)),
&iter);
#endif
data->ignore_selection = FALSE;
gnome_icon_list_freeze (data->gil);
for (i = 0, list = view->capplet_dir->entries; list; list = list->next)
{
if (CAPPLET_DIR_ENTRY (list->data)->type == TYPE_CAPPLET_DIR)
continue;
#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_data)); GNOME_CANVAS (view->view_data));
gnome_icon_list_insert_item (GNOME_ICON_LIST (view->view_data), 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_data), i, g_print ("Icon: %s %s", CAPPLET_DIR_ENTRY (list->data)->icon,
CAPPLET_DIR_ENTRY (list->data)->icon,
CAPPLET_DIR_ENTRY (list->data)->label); CAPPLET_DIR_ENTRY (list->data)->label);
gnome_icon_list_insert (data->gil, i++,
CAPPLET_DIR_ENTRY (list->data)->icon,
"Hi");
// CAPPLET_DIR_ENTRY (list->data)->label);
#endif #endif
} }
gnome_icon_list_thaw (GNOME_ICON_LIST (view->view_data)); gnome_icon_list_thaw (data->gil);
g_free (data->header_text);
data->header_text = g_strdup_printf (_("GNOME Control Center: %s"),
CAPPLET_DIR_ENTRY (view->capplet_dir)->label);
gtk_widget_queue_draw (data->header);
} }
static void static void
@ -129,21 +338,148 @@ select_icon_list_cb (GtkWidget *widget, gint arg1, GdkEvent *event,
((GdkEventButton *) event)->button == 1) ((GdkEventButton *) event)->button == 1)
{ {
capplet_dir_entry_activate capplet_dir_entry_activate
(g_slist_nth_data (view->capplet_dir->entries, arg1), view); (real_slist_nth_data (view->capplet_dir->entries, arg1, TYPE_CAPPLET), view);
view->selected = NULL; view->selected = NULL;
} else { } else {
view->selected = g_slist_nth_data (view->capplet_dir->entries, arg1); view->selected = real_slist_nth_data (view->capplet_dir->entries, arg1, TYPE_CAPPLET);
} }
} }
void
lighten_color (GdkColor *color)
{
g_return_if_fail (color != NULL);
#define SPLIT_THE_DISTANCE(x, y) ((x) += ((y) - (x)) / 2)
SPLIT_THE_DISTANCE (color->red, 1 << 16);
SPLIT_THE_DISTANCE (color->green, 1 << 16);
SPLIT_THE_DISTANCE (color->blue, 1 << 16);
#undef SPLIT_THE_DISTANCE
}
static gint
header_expose_cb (GtkWidget *darea, GdkEventExpose *event,
CappletDirView *view)
{
ListViewData *data = view->view_data;
int tw, th;
int i;
if (!data->gc1)
{
GdkColor c1, c2;
//gdk_color_parse ("#625784", &c1);
c1 = darea->style->bg[GTK_STATE_SELECTED];
lighten_color (&c1);
//gdk_color_parse ("#494066", &c2);
//c2 = darea->style->dark[GTK_STATE_SELECTED];
c2 = darea->style->black;
lighten_color (&c2);
data->gc1 = gdk_gc_new (darea->window);
gdk_gc_copy (data->gc1, darea->style->white_gc);
gdk_gc_set_rgb_fg_color (data->gc1, &c1);
data->gc2 = gdk_gc_new (darea->window);
gdk_gc_copy (data->gc2, darea->style->white_gc);
gdk_gc_set_rgb_fg_color (data->gc2, &c2);
}
if (!data->layout)
{
PangoContext *context = gtk_widget_get_pango_context (darea);
PangoFontDescription *desc = pango_font_description_copy (darea->style->font_desc);
pango_font_description_set_size (desc, 16);
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
data->layout = pango_layout_new (context);
pango_layout_set_font_description (data->layout, desc);
pango_font_description_free (desc);
}
for (i = 0; i < event->area.height; i++)
{
int y = i + event->area.y;
GdkGC *gc = (y % 2) ? data->gc2 : data->gc1;
gdk_draw_line (darea->window, gc,
event->area.x, y,
event->area.x + event->area.width,
y);
}
gdk_pixbuf_render_to_drawable_alpha (data->header_logo,
darea->window,
event->area.x, event->area.y,
event->area.x, event->area.y,
MIN (gdk_pixbuf_get_width (data->header_logo), event->area.width),
MIN (gdk_pixbuf_get_height (data->header_logo), event->area.height),
GDK_PIXBUF_ALPHA_FULL, 255,
GDK_RGB_DITHER_MAX,
0, 0);
pango_layout_set_text (data->layout, data->header_text, -1);
pango_layout_get_pixel_size (data->layout, &tw, &th);
// gdk_draw_layout (darea->window, darea->style->text[GTK_STATE_SELECTED],
gdk_draw_layout (darea->window, darea->style->white_gc,
64, (darea->allocation.height - th) / 2,
data->layout);
return TRUE;
}
static GtkWidget * static GtkWidget *
list_create (CappletDirView *view) list_create (CappletDirView *view)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
GtkWidget *w, *sw; GtkWidget *w, *sw, *vbox, *hbox;
GtkWidget *darea;
GSList *list; GSList *list;
ListViewData *data;
gchar *title;
int i; int i;
GtkCellRenderer *renderer;
GtkTreeSelection *sel;
data = view->view_data = g_new0 (ListViewData, 1);
vbox = gtk_vbox_new (FALSE, 0);
darea = data->header = gtk_drawing_area_new ();
gtk_widget_set_usize (darea, 48, 48);
gtk_signal_connect (GTK_OBJECT (darea), "expose_event",
header_expose_cb, view);
gtk_box_pack_start (GTK_BOX (vbox), darea, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 0);
data->sidebar_model = gtk_list_store_new (4,
GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF,
G_TYPE_POINTER);
data->sidebar = w = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data->sidebar_model));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (w), FALSE);
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
-1, "", renderer, "pixbuf", SIDEBAR_ICON, NULL);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
-1, "", renderer, "text", SIDEBAR_LABEL, NULL);
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
-1, "", renderer, "pixbuf", SIDEBAR_ACTIVE, NULL);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
g_signal_connect (G_OBJECT (sel), "changed", sidebar_select_cb, view);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_usize (sw, 200, -1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (sw), w);
gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
sw = gtk_scrolled_window_new (NULL, NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC,
@ -151,7 +487,11 @@ list_create (CappletDirView *view)
adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)); adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
view->view_data = w = gnome_icon_list_new (72, adjustment, 0); data->gil = w = gnome_icon_list_new (72, 0);
title = g_concat_dir_and_file (ART_DIR, "title.png");
data->header_logo = gdk_pixbuf_new_from_file (title, NULL);
g_free (title);
if (view->selected) if (view->selected)
view->capplet_dir = view->selected->dir; view->capplet_dir = view->selected->dir;
@ -174,9 +514,11 @@ list_create (CappletDirView *view)
view); view);
gtk_container_add (GTK_CONTAINER (sw), w); gtk_container_add (GTK_CONTAINER (sw), w);
gtk_widget_show_all (sw); gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
return sw; gtk_widget_show_all (vbox);
return vbox;
} }
CappletDirViewImpl capplet_dir_view_list = { CappletDirViewImpl capplet_dir_view_list = {

View file

@ -57,7 +57,7 @@ populate_tree_branch (CappletDir *dir, GtkCTree *ctree, GtkCTreeNode *parent)
for (list = dir->entries; list; list = list->next) { for (list = dir->entries; list; list = list->next) {
entry = CAPPLET_DIR_ENTRY (list->data); entry = CAPPLET_DIR_ENTRY (list->data);
pixbuf = gdk_pixbuf_new_from_file (entry->icon); pixbuf = gdk_pixbuf_new_from_file (entry->icon, NULL);
scaled = gdk_pixbuf_scale_simple (pixbuf, 16, 16, scaled = gdk_pixbuf_scale_simple (pixbuf, 16, 16,
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
gdk_pixbuf_render_pixmap_and_mask (scaled, &pixmap, &mask, 128); gdk_pixbuf_render_pixmap_and_mask (scaled, &pixmap, &mask, 128);

View file

@ -32,7 +32,9 @@
#include "capplet-dir-view.h" #include "capplet-dir-view.h"
#ifdef USE_HTML
extern CappletDirViewImpl capplet_dir_view_html; extern CappletDirViewImpl capplet_dir_view_html;
#endif
extern CappletDirViewImpl capplet_dir_view_list; extern CappletDirViewImpl capplet_dir_view_list;
extern CappletDirViewImpl capplet_dir_view_tree; extern CappletDirViewImpl capplet_dir_view_tree;
@ -40,7 +42,9 @@ CappletDirViewImpl *capplet_dir_view_impl[] = {
NULL, NULL,
&capplet_dir_view_list, &capplet_dir_view_list,
&capplet_dir_view_tree, &capplet_dir_view_tree,
#ifdef USE_HTML
&capplet_dir_view_html &capplet_dir_view_html
#endif
}; };
static GtkObjectClass *parent_class; static GtkObjectClass *parent_class;
@ -87,7 +91,12 @@ capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
capplet_dir_view_load_dir (view, GTK_VALUE_POINTER (*arg)); capplet_dir_view_load_dir (view, GTK_VALUE_POINTER (*arg));
break; break;
case ARG_LAYOUT: case ARG_LAYOUT:
#ifdef USE_HTML
layout = CLAMP (GTK_VALUE_UINT (*arg), 0, LAYOUT_HTML); layout = CLAMP (GTK_VALUE_UINT (*arg), 0, LAYOUT_HTML);
#else
layout = CLAMP (GTK_VALUE_UINT (*arg), 0, LAYOUT_TREE);
#endif
if (layout == view->layout) if (layout == view->layout)
break; break;
@ -169,22 +178,26 @@ capplet_dir_view_class_init (CappletDirViewClass *klass)
guint guint
capplet_dir_view_get_type (void) capplet_dir_view_get_type (void)
{ {
static guint capplet_dir_view_type = 0; static GtkType capplet_dir_view_type = 0;
if (!capplet_dir_view_type) { if (!capplet_dir_view_type) {
GtkTypeInfo capplet_dir_view_info = { static const GTypeInfo capplet_dir_view_info = {
"CappletDirView",
sizeof (CappletDirView),
sizeof (CappletDirViewClass), sizeof (CappletDirViewClass),
(GtkClassInitFunc) capplet_dir_view_class_init, NULL, /* base_init */
(GtkObjectInitFunc) capplet_dir_view_init, NULL, /* base_finalize */
(GtkArgSetFunc) NULL, (GClassInitFunc) capplet_dir_view_class_init,
(GtkArgGetFunc) NULL NULL, /* class_finalize */
NULL, /* class_data */
sizeof (CappletDirView),
0 /* n_preallocs */,
(GInstanceInitFunc) capplet_dir_view_init
}; };
capplet_dir_view_type = capplet_dir_view_type =
gtk_type_unique (gtk_object_get_type (), g_type_register_static (gtk_object_get_type (),
&capplet_dir_view_info); "CappletDirView",
&capplet_dir_view_info,
0);
} }
return capplet_dir_view_type; return capplet_dir_view_type;
@ -223,11 +236,13 @@ menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL); gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
} }
#ifdef USE_HTML
static void static void
html_menu_cb (GtkWidget *w, CappletDirView *view) html_menu_cb (GtkWidget *w, CappletDirView *view)
{ {
menu_cb (w, view, LAYOUT_HTML); menu_cb (w, view, LAYOUT_HTML);
} }
#endif
static void static void
icon_menu_cb (GtkWidget *w, CappletDirView *view) icon_menu_cb (GtkWidget *w, CappletDirView *view)
@ -250,11 +265,13 @@ button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL); gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
} }
#ifdef USE_HTML
static void static void
html_toggle_cb (GtkWidget *w, CappletDirView *view) html_toggle_cb (GtkWidget *w, CappletDirView *view)
{ {
button_cb (w, view, LAYOUT_HTML); button_cb (w, view, LAYOUT_HTML);
} }
#endif
static void static void
list_toggle_cb (GtkWidget *w, CappletDirView *view) list_toggle_cb (GtkWidget *w, CappletDirView *view)
@ -296,11 +313,11 @@ about_menu_cb (GtkWidget *widget, CappletDirView *view)
about = gnome_about_new about = gnome_about_new
(_("GNOME Control Center"), VERSION, (_("GNOME Control Center"), VERSION,
_("Desktop properties manager."),
(const gchar **) authors,
"Copyright (C) 2000, 2001 Ximian, Inc.\n" "Copyright (C) 2000, 2001 Ximian, Inc.\n"
"Copyright (C) 1999 Red Hat Software, Inc.", "Copyright (C) 1999 Red Hat Software, Inc.",
NULL); _("Desktop properties manager."),
(const gchar **) authors,
NULL, NULL, NULL);
gtk_signal_connect (GTK_OBJECT (about), "destroy", gtk_signal_connect (GTK_OBJECT (about), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed), GTK_SIGNAL_FUNC (gtk_widget_destroyed),
@ -329,7 +346,7 @@ capplet_dir_view_new (void)
GladeXML *xml; GladeXML *xml;
CappletDirView *view; CappletDirView *view;
xml = glade_xml_new (GLADEDIR"/gnomecc.glade", "main_window"); xml = glade_xml_new (GLADEDIR"/gnomecc.glade", "main_window", NULL);
if (!xml) if (!xml)
return NULL; return NULL;
@ -346,9 +363,9 @@ capplet_dir_view_new (void)
gtk_signal_connect (GTK_OBJECT (view->app), "destroy", gtk_signal_connect (GTK_OBJECT (view->app), "destroy",
GTK_SIGNAL_FUNC (destroy), view); GTK_SIGNAL_FUNC (destroy), view);
glade_xml_signal_connect_data (xml, "close_cb", close_cb, view); glade_xml_signal_connect_data (xml, "close_cb", GTK_SIGNAL_FUNC (close_cb), view);
glade_xml_signal_connect_data (xml, "about_menu_cb", about_menu_cb, view); glade_xml_signal_connect_data (xml, "about_menu_cb", GTK_SIGNAL_FUNC (about_menu_cb), view);
gtk_object_unref (GTK_OBJECT (xml)); gtk_object_unref (GTK_OBJECT (xml));
gtk_object_set (GTK_OBJECT (view), "layout", prefs->layout, NULL); gtk_object_set (GTK_OBJECT (view), "layout", prefs->layout, NULL);
@ -410,7 +427,7 @@ capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir)
if (view->impl && view->impl->populate) if (view->impl && view->impl->populate)
view->impl->populate (view); view->impl->populate (view);
title = g_strdup_printf (_("Gnome Control Center : %s"), dir->entry.entry->name); title = g_strdup_printf (_("Gnome Control Center : %s"), dir->entry.label);
gtk_window_set_title (GTK_WINDOW (view->app), title); gtk_window_set_title (GTK_WINDOW (view->app), title);
g_free (title); g_free (title);
@ -449,12 +466,10 @@ help_cb (GtkWidget *widget, CappletDirView *view)
{ {
gchar *tmp; gchar *tmp;
tmp = gnome_help_file_find_file ("users-guide", "gcc.html"); if (!gnome_help_display (gnome_program_get (),
"users-guide", "gcc.html",
if (tmp) { NULL))
gnome_help_goto (0, tmp); {
g_free (tmp);
} else {
GtkWidget *mbox; GtkWidget *mbox;
mbox = gnome_message_box_new mbox = gnome_message_box_new

View file

@ -26,7 +26,6 @@
#include <gnome.h> #include <gnome.h>
#include <gtkhtml/gtkhtml.h>
#include "capplet-dir.h" #include "capplet-dir.h"
#include "preferences.h" #include "preferences.h"

View file

@ -45,7 +45,9 @@ static void capplet_dir_shutdown (CappletDir *capplet_dir);
static GSList *read_entries (CappletDir *dir); static GSList *read_entries (CappletDir *dir);
static void start_capplet_through_root_manager (GnomeDesktopEntry *gde); #ifdef USE_ROOT_MANAGER
static void start_capplet_through_root_manager (GnomeDesktopItem *gde);
#endif
CappletDirView *(*get_view_cb) (CappletDir *dir, CappletDirView *launcher); CappletDirView *(*get_view_cb) (CappletDir *dir, CappletDirView *launcher);
@ -57,8 +59,9 @@ capplet_new (CappletDir *dir, gchar *desktop_path)
{ {
Capplet *capplet; Capplet *capplet;
CappletDirEntry *entry; CappletDirEntry *entry;
GnomeDesktopEntry *dentry; GnomeDesktopItem *dentry;
gchar *path; gchar *path, **vec;
const gchar *execstr;
g_return_val_if_fail (desktop_path != NULL, NULL); g_return_val_if_fail (desktop_path != NULL, NULL);
@ -67,13 +70,20 @@ capplet_new (CappletDir *dir, gchar *desktop_path)
return entry; return entry;
} }
dentry = gnome_desktop_entry_load (desktop_path); dentry = gnome_desktop_item_new_from_file (desktop_path,
GNOME_DESKTOP_ITEM_TYPE_NULL,
NULL);
if (dentry == NULL) if (dentry == NULL)
return NULL; return NULL;
if ((dentry->exec_length == 0) || !(path = gnome_is_program_in_path (dentry->exec[0]))) execstr = gnome_desktop_item_get_string (dentry,
GNOME_DESKTOP_ITEM_EXEC);
/* Perhaps use poptParseArgvString here */
vec = g_strsplit (execstr, " ", 0);
if (!(execstr && execstr[0]) || !(vec && (path = gnome_is_program_in_path (vec[0]))))
{ {
gnome_desktop_entry_free (dentry); g_strfreev (vec);
gnome_desktop_item_unref (dentry);
return NULL; return NULL;
} }
g_free (path); g_free (path);
@ -86,16 +96,33 @@ capplet_new (CappletDir *dir, gchar *desktop_path)
entry->type = TYPE_CAPPLET; entry->type = TYPE_CAPPLET;
entry->entry = dentry; entry->entry = dentry;
entry->label = entry->entry->name; entry->label = g_strdup (gnome_desktop_item_get_string (dentry,
entry->icon = entry->entry->icon; GNOME_DESKTOP_ITEM_NAME));
entry->path = entry->entry->location; entry->icon = g_strdup (gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON));
if (entry->icon && entry->icon[0] != '/')
{
gchar *old = entry->icon;
entry->icon = g_concat_dir_and_file (PIXMAPS_DIR, old);
g_free (old);
}
if (!g_file_exists (entry->icon))
{
g_free (entry->icon);
entry->icon = gnome_pixmap_file (
gnome_desktop_item_get_string (dentry,
GNOME_DESKTOP_ITEM_ICON));
if (!entry->icon)
entry->icon = gnome_pixmap_file ("gnome-unknown.png");
}
entry->path = g_strdup (gnome_desktop_item_get_location (dentry));
entry->exec = vec;
entry->dir = dir; entry->dir = dir;
if (!entry->icon) if (!entry->icon)
entry->icon = GNOMECC_PIXMAPS_DIR "/control-center.png"; entry->icon = GNOMECC_PIXMAPS_DIR "/control-center.png";
entry->pb = gdk_pixbuf_new_from_file (entry->icon); entry->pb = gdk_pixbuf_new_from_file (entry->icon, NULL);
g_hash_table_insert (capplet_hash, g_strdup (desktop_path), entry); g_hash_table_insert (capplet_hash, g_strdup (desktop_path), entry);
@ -122,20 +149,26 @@ capplet_dir_new (CappletDir *dir, gchar *dir_path)
entry = CAPPLET_DIR_ENTRY (capplet_dir); entry = CAPPLET_DIR_ENTRY (capplet_dir);
entry->type = TYPE_CAPPLET_DIR; entry->type = TYPE_CAPPLET_DIR;
entry->entry = gnome_desktop_entry_load (desktop_path); entry->entry = gnome_desktop_item_new_from_file (desktop_path,
GNOME_DESKTOP_ITEM_TYPE_NULL,
NULL);
entry->dir = dir; entry->dir = dir;
entry->path = g_strdup (dir_path); entry->path = g_strdup (dir_path);
g_free (desktop_path); g_free (desktop_path);
if (entry->entry) { if (entry->entry) {
entry->label = entry->entry->name; entry->label = g_strdup (gnome_desktop_item_get_string (
entry->icon = entry->entry->icon; entry->entry,
GNOME_DESKTOP_ITEM_NAME));
entry->icon = g_strdup (gnome_desktop_item_get_string (
entry->entry,
GNOME_DESKTOP_ITEM_ICON));
if (!entry->icon) if (!entry->icon)
entry->icon = GNOMECC_PIXMAPS_DIR "/control-center.png"; entry->icon = g_strdup (GNOMECC_PIXMAPS_DIR "/control-center.png");
entry->pb = gdk_pixbuf_new_from_file (entry->icon); entry->pb = gdk_pixbuf_new_from_file (entry->icon, NULL);
} else { } else {
/* If the .directory file could not be found or read, abort */ /* If the .directory file could not be found or read, abort */
g_free (capplet_dir); g_free (capplet_dir);
@ -164,10 +197,13 @@ capplet_dir_entry_destroy (CappletDirEntry *entry)
capplet_shutdown (CAPPLET (entry)); capplet_shutdown (CAPPLET (entry));
} else { } else {
capplet_dir_shutdown (CAPPLET_DIR (entry)); capplet_dir_shutdown (CAPPLET_DIR (entry));
g_free (entry->path);
} }
gnome_desktop_entry_free (entry->entry); g_free (entry->label);
g_free (entry->icon);
g_free (entry->path);
g_strfreev (entry->exec);
gnome_desktop_item_unref (entry->entry);
g_free (entry); g_free (entry);
} }
@ -206,9 +242,9 @@ capplet_reset_cb (Capplet *capplet)
static void static void
capplet_activate (Capplet *capplet) capplet_activate (Capplet *capplet)
{ {
GnomeDesktopEntry *entry; CappletDirEntry *entry;
entry = CAPPLET_DIR_ENTRY (capplet)->entry; entry = CAPPLET_DIR_ENTRY (capplet);
#warning FIXME: this should probably be root-manager-helper #warning FIXME: this should probably be root-manager-helper
if (!strncmp (entry->exec[0], "gnomecc", strlen ("gnomecc"))) { if (!strncmp (entry->exec[0], "gnomecc", strlen ("gnomecc"))) {
@ -217,17 +253,19 @@ capplet_activate (Capplet *capplet)
} else { } else {
capplet->launching = TRUE; capplet->launching = TRUE;
gtk_idle_add ((GtkFunction) capplet_reset_cb, capplet); gtk_idle_add ((GtkFunction) capplet_reset_cb, capplet);
capplet_control_launch (entry->exec[2], entry->name); capplet_control_launch (entry->exec[2], entry->label);
} }
#ifdef USE_ROOT_MANAGER
} else if (!strncmp (entry->exec[0], "root-manager", strlen ("root-manager"))) { } else if (!strncmp (entry->exec[0], "root-manager", strlen ("root-manager"))) {
start_capplet_through_root_manager (entry); start_capplet_through_root_manager (entry->entry);
#endif
} else { } else {
if (capplet->launching) { if (capplet->launching) {
return; return;
} else { } else {
capplet->launching = TRUE; capplet->launching = TRUE;
gtk_timeout_add (1000, (GtkFunction) capplet_reset_cb, capplet); gtk_timeout_add (1000, (GtkFunction) capplet_reset_cb, capplet);
gnome_desktop_entry_launch (entry); gnome_desktop_item_launch (entry->entry, 0, NULL, NULL);
} }
} }
} }
@ -275,8 +313,8 @@ capplet_dir_shutdown (CappletDir *capplet_dir)
static gint static gint
node_compare (gconstpointer a, gconstpointer b) node_compare (gconstpointer a, gconstpointer b)
{ {
return strcmp (CAPPLET_DIR_ENTRY (a)->entry->name, return strcmp (CAPPLET_DIR_ENTRY (a)->label,
CAPPLET_DIR_ENTRY (b)->entry->name); CAPPLET_DIR_ENTRY (b)->label);
} }
/* Adapted from the original control center... */ /* Adapted from the original control center... */
@ -335,8 +373,9 @@ read_entries (CappletDir *dir)
: list; : list;
} }
#ifdef USE_ROOT_MANAGER
static void static void
start_capplet_through_root_manager (GnomeDesktopEntry *gde) start_capplet_through_root_manager (GnomeDesktopItem *gde)
{ {
static FILE *output = NULL; static FILE *output = NULL;
pid_t pid; pid_t pid;
@ -382,6 +421,7 @@ start_capplet_through_root_manager (GnomeDesktopEntry *gde)
fflush (output); fflush (output);
g_free (cmdline); g_free (cmdline);
} }
#endif
void void
capplet_dir_init (CappletDirView *(*cb) (CappletDir *, CappletDirView *)) capplet_dir_init (CappletDirView *(*cb) (CappletDir *, CappletDirView *))

View file

@ -25,6 +25,7 @@
#define __CAPPLET_DIR_H #define __CAPPLET_DIR_H
#include <gnome.h> #include <gnome.h>
#include <libgnome/gnome-desktop-item.h>
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#define CAPPLET_DIR_ENTRY(obj) ((CappletDirEntry *) obj) #define CAPPLET_DIR_ENTRY(obj) ((CappletDirEntry *) obj)
@ -48,7 +49,8 @@ typedef enum {
struct _CappletDirEntry struct _CappletDirEntry
{ {
CappletEntryType type; CappletEntryType type;
GnomeDesktopEntry *entry; GnomeDesktopItem *entry;
gchar **exec;
gchar *label; gchar *label;
gchar *icon; gchar *icon;
gchar *path; gchar *path;

View file

@ -1,364 +1,370 @@
<?xml version="1.0"?> <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<GTK-Interface> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
<project> <glade-interface>
<name>New-control-center</name> <requires lib="gnome" />
<program_name>new-control-center</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<widget> <widget class="GtkDialog" id="preferences_dialog">
<class>GnomeDialog</class> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<name>preferences_dialog</name> <property name="modal">no</property>
<type>GTK_WINDOW_TOPLEVEL</type> <property name="allow_shrink">no</property>
<position>GTK_WIN_POS_NONE</position> <property name="allow_grow">no</property>
<modal>False</modal> <property name="auto_close">no</property>
<allow_shrink>False</allow_shrink> <property name="hide_on_close">no</property>
<allow_grow>False</allow_grow> <property name="visible">no</property>
<auto_shrink>False</auto_shrink> <property name="window-position">GTK_WIN_POS_NONE</property>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget> <child internal-child="vbox">
<class>GtkVBox</class> <widget class="GtkVBox" id="dialog-vbox1">
<child_name>GnomeDialog:vbox</child_name> <property name="homogeneous">no</property>
<name>dialog-vbox1</name> <property name="spacing">8</property>
<homogeneous>False</homogeneous> <property name="visible">yes</property>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget> <child internal-child="action_area">
<class>GtkHButtonBox</class> <widget class="GtkHButtonBox" id="dialog-action_area1">
<child_name>GnomeDialog:action_area</child_name> <property name="layout_style">GTK_BUTTONBOX_END</property>
<name>dialog-action_area1</name> <property name="spacing">8</property>
<layout_style>GTK_BUTTONBOX_END</layout_style> <property name="child_min_width">85</property>
<spacing>8</spacing> <property name="child_min_height">27</property>
<child_min_width>85</child_min_width> <property name="child_ipad_x">7</property>
<child_min_height>27</child_min_height> <property name="child_ipad_y">0</property>
<child_ipad_x>7</child_ipad_x> <property name="visible">yes</property>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget> <child>
<class>GtkButton</class> <widget class="GtkButton" id="button1">
<name>button1</name> <property name="can_default">yes</property>
<can_default>True</can_default> <property name="can_focus">yes</property>
<can_focus>True</can_focus> <property name="visible">yes</property>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button> <property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button2">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label" translatable="yes">gtk-apply</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button3">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">yes</property>
<property name="pack">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkNotebook" id="notebook1">
<property name="can_focus">yes</property>
<property name="show_tabs">yes</property>
<property name="show_border">yes</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">no</property>
<property name="tab_hborder">2</property>
<property name="tab_vborder">2</property>
<property name="enable-popup">no</property>
<property name="visible">yes</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="border_width">5</property>
<property name="homogeneous">no</property>
<property name="spacing">5</property>
<property name="visible">yes</property>
<child>
<widget class="GtkRadioButton" id="no_embed_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Launch control panels in separate windows</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="embed_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Put control panels in the control center's window</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<property name="group">no_embed_widget</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="html_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Display control panels as HTML</property>
<property name="active">yes</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="icon_list_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Display control panels as a set of icons</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<property name="group">html_widget</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="tree_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Display control panels as a tree</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<property name="group">html_widget</property>
<signal name="toggled" handler="tree_widget_toggled_cb" />
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator2">
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="single_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Browse with single window</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="multiple_widget">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Browse with multiple windows</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<property name="group">single_widget</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="label" translatable="yes">Appearance</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
</widget> </widget>
<packing>
<widget> <property name="padding">4</property>
<class>GtkButton</class> <property name="expand">yes</property>
<name>button2</name> <property name="fill">yes</property>
<can_default>True</can_default> </packing>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkNotebook</class>
<name>notebook1</name>
<can_focus>True</can_focus>
<show_tabs>True</show_tabs>
<show_border>True</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
<scrollable>False</scrollable>
<tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<border_width>5</border_width>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<widget>
<class>GtkRadioButton</class>
<name>no_embed_widget</name>
<can_focus>True</can_focus>
<label>Launch control panels in separate windows</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>embed_group</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>embed_widget</name>
<can_focus>True</can_focus>
<label>Put control panels in the control center's window</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>embed_group</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator1</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>html_widget</name>
<can_focus>True</can_focus>
<label>Display control panels as HTML</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<group>display_type_group</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>icon_list_widget</name>
<can_focus>True</can_focus>
<label>Display control panels as a set of icons</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>display_type_group</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>tree_widget</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>tree_widget_toggled_cb</handler>
<last_modification_time>Fri, 11 Aug 2000 17:13:59 GMT</last_modification_time>
</signal>
<label>Display control panels as a tree</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>display_type_group</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator2</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>single_widget</name>
<can_focus>True</can_focus>
<label>Browse with single window</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>browse_type</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>multiple_widget</name>
<can_focus>True</can_focus>
<label>Browse with multiple windows</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>browse_type</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label1</name>
<label>Appearance</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GnomeApp</class>
<name>main_window</name>
<visible>False</visible>
<title>New-control-center</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<default_width>620</default_width>
<default_height>430</default_height>
<allow_shrink>True</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<enable_layout_config>True</enable_layout_config>
<widget>
<class>GnomeDock</class>
<child_name>GnomeApp:dock</child_name>
<name>dock1</name>
<allow_floating>True</allow_floating>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GnomeDockItem</class>
<name>dockitem1</name>
<border_width>2</border_width>
<placement>GNOME_DOCK_TOP</placement>
<band>0</band>
<position>0</position>
<offset>0</offset>
<locked>False</locked>
<exclusive>True</exclusive>
<never_floating>False</never_floating>
<never_vertical>True</never_vertical>
<never_horizontal>False</never_horizontal>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<widget>
<class>GtkMenuBar</class>
<name>menubar1</name>
<shadow_type>GTK_SHADOW_NONE</shadow_type>
<widget>
<class>GtkMenuItem</class>
<name>file1</name>
<stock_item>GNOMEUIINFO_MENU_FILE_TREE</stock_item>
<widget>
<class>GtkMenu</class>
<name>file1_menu</name>
<widget>
<class>GtkPixmapMenuItem</class>
<name>exit1</name>
<signal>
<name>activate</name>
<handler>close_cb</handler>
<last_modification_time>Tue, 05 Dec 2000 02:53:49 GMT</last_modification_time>
</signal>
<stock_item>GNOMEUIINFO_MENU_CLOSE_ITEM</stock_item>
</widget>
</widget>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>help1</name>
<stock_item>GNOMEUIINFO_MENU_HELP_TREE</stock_item>
<widget>
<class>GtkMenu</class>
<name>help1_menu</name>
<widget>
<class>GtkPixmapMenuItem</class>
<name>about1</name>
<signal>
<name>activate</name>
<handler>about_menu_cb</handler>
<last_modification_time>Tue, 05 Dec 2000 02:53:49 GMT</last_modification_time>
</signal>
<stock_item>GNOMEUIINFO_MENU_ABOUT_ITEM</stock_item>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>Placeholder</class>
<child_name>GnomeDock:contents</child_name>
</widget>
</widget>
<widget>
<class>GnomeAppBar</class>
<child_name>GnomeApp:appbar</child_name>
<name>appbar1</name>
<has_progress>False</has_progress>
<has_status>True</has_status>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child> </child>
</widget> </widget>
</widget> <widget class="GnomeApp" id="main_window">
<property name="visible">no</property>
<property name="title" translatable="yes">New-control-center</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="modal">no</property>
<property name="default_width">620</property>
<property name="default_height">430</property>
<property name="allow_shrink">yes</property>
<property name="allow_grow">yes</property>
<property name="enable_layout_config">yes</property>
<property name="window-position">GTK_WIN_POS_NONE</property>
</GTK-Interface> <child internal-child="vbox">
<widget class="GnomeDock" id="dock1">
<property name="allow_floating">yes</property>
<property name="visible">yes</property>
<child>
<widget class="GnomeDockItem" id="dockitem1">
<property name="border_width">2</property>
<property name="placement">GNOME_DOCK_TOP</property>
<property name="band">0</property>
<property name="position">0</property>
<property name="offset">0</property>
<property name="locked">no</property>
<property name="exclusive">yes</property>
<property name="never_floating">no</property>
<property name="never_vertical">yes</property>
<property name="never_horizontal">no</property>
<property name="shadow_type">GTK_SHADOW_OUT</property>
<property name="visible">yes</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="visible">yes</property>
<child>
<widget class="GtkMenuItem" id="file1">
<property name="stock_item">GNOMEUIINFO_MENU_FILE_TREE</property>
<property name="visible">yes</property>
<child>
<widget class="GtkMenu" id="file1_menu">
<property name="visible">yes</property>
<child>
<widget class="GtkImageMenuItem" id="exit1">
<property name="stock_item">GNOMEUIINFO_MENU_CLOSE_ITEM</property>
<property name="visible">yes</property>
<signal name="activate" handler="close_cb" />
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="help1">
<property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
<property name="visible">yes</property>
<child>
<widget class="GtkMenu" id="help1_menu">
<property name="visible">yes</property>
<child>
<widget class="GtkImageMenuItem" id="about1">
<property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
<property name="visible">yes</property>
<signal name="activate" handler="about_menu_cb" />
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="None">
<property name="visible">yes</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GnomeAppBar" id="appbar1">
<property name="child_name">GnomeApp:appbar</property>
<property name="has_progress">no</property>
<property name="has_status">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
</widget>
</glade-interface>

View file

@ -67,13 +67,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, GNOMELOCALEDIR); bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE); textdomain (PACKAGE);
gnomelib_register_popt_table (gnomecc_options, _("GNOME Control Center options")); gnome_program_init ("control-center", VERSION, LIBGNOMEUI_MODULE,
gnome_init ("control-center", VERSION, argc, argv); argc, argv,
glade_gnome_init (); GNOME_PARAM_POPT_TABLE, gnomecc_options);
orb = oaf_init (argc, argv);
if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
g_error ("Cannot initialize bonobo");
gconf_init (argc, argv, NULL); gconf_init (argc, argv, NULL);

View file

@ -55,19 +55,23 @@ gnomecc_preferences_get_type (void)
static guint gnomecc_preferences_type; static guint gnomecc_preferences_type;
if (!gnomecc_preferences_type) { if (!gnomecc_preferences_type) {
GtkTypeInfo gnomecc_preferences_info = { static const GTypeInfo gnomecc_preferences_info = {
"GnomeCCPreferences",
sizeof (GnomeCCPreferences),
sizeof (GnomeCCPreferencesClass), sizeof (GnomeCCPreferencesClass),
(GtkClassInitFunc) gnomecc_preferences_class_init, NULL, /* base_init */
(GtkObjectInitFunc) gnomecc_preferences_init, NULL, /* base_finalize */
(GtkArgSetFunc) NULL, (GClassInitFunc) gnomecc_preferences_class_init,
(GtkArgGetFunc) NULL NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeCCPreferences),
0 /* n_preallocs */,
(GInstanceInitFunc) gnomecc_preferences_init
}; };
gnomecc_preferences_type = gnomecc_preferences_type =
gtk_type_unique (gtk_object_get_type (), g_type_register_static (gtk_object_get_type (),
&gnomecc_preferences_info); "GnomeCCPreferences",
&gnomecc_preferences_info,
0);
} }
return gnomecc_preferences_type; return gnomecc_preferences_type;
@ -90,15 +94,16 @@ gnomecc_preferences_class_init (GnomeCCPreferencesClass *klass)
gnomecc_preferences_signals[CHANGED_SIGNAL] = gnomecc_preferences_signals[CHANGED_SIGNAL] =
gtk_signal_new ("changed", GTK_RUN_FIRST, gtk_signal_new ("changed", GTK_RUN_FIRST,
object_class->type, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GnomeCCPreferencesClass, GTK_SIGNAL_OFFSET (GnomeCCPreferencesClass,
changed), changed),
gtk_marshal_NONE__NONE, gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0); GTK_TYPE_NONE, 0);
#if 0
gtk_object_class_add_signals (object_class, gtk_object_class_add_signals (object_class,
gnomecc_preferences_signals, gnomecc_preferences_signals,
LAST_SIGNAL); LAST_SIGNAL);
#endif
} }
GnomeCCPreferences * GnomeCCPreferences *
@ -134,7 +139,7 @@ gnomecc_preferences_load (GnomeCCPreferences *prefs)
gnome_config_push_prefix ("/control-center/appearance"); gnome_config_push_prefix ("/control-center/appearance");
prefs->embed = gnome_config_get_bool ("embed=false"); prefs->embed = gnome_config_get_bool ("embed=false");
prefs->single_window = gnome_config_get_bool ("single_window=true"); prefs->single_window = gnome_config_get_bool ("single_window=true");
prefs->layout = gnome_config_get_int ("layout=3"); prefs->layout = gnome_config_get_int ("layout=1");
gnome_config_pop_prefix (); gnome_config_pop_prefix ();
} }
@ -167,7 +172,9 @@ place_preferences (GladeXML *prefs_data, GnomeCCPreferences *prefs)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
switch (prefs->layout) { switch (prefs->layout) {
#ifdef USE_HTML
case LAYOUT_HTML: w = "html_widget"; break; case LAYOUT_HTML: w = "html_widget"; break;
#endif
case LAYOUT_TREE: w = "tree_widget"; break; case LAYOUT_TREE: w = "tree_widget"; break;
case LAYOUT_ICON_LIST: w = "icon_list_widget"; break; case LAYOUT_ICON_LIST: w = "icon_list_widget"; break;
default: w = NULL; break; default: w = NULL; break;
@ -196,10 +203,12 @@ read_preferences (GladeXML *prefs_data, GnomeCCPreferences *prefs)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
prefs->layout = LAYOUT_TREE; prefs->layout = LAYOUT_TREE;
else { else {
#ifdef USE_HTML
widget = glade_xml_get_widget (prefs_data, "html_widget"); widget = glade_xml_get_widget (prefs_data, "html_widget");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
prefs->layout = LAYOUT_HTML; prefs->layout = LAYOUT_HTML;
else else
#endif
prefs->layout = LAYOUT_ICON_LIST; prefs->layout = LAYOUT_ICON_LIST;
} }
@ -275,7 +284,8 @@ gnomecc_preferences_get_config_dialog (GnomeCCPreferences *prefs)
old_prefs = gnomecc_preferences_clone (prefs); old_prefs = gnomecc_preferences_clone (prefs);
prefs_dialog_data = prefs_dialog_data =
glade_xml_new (GLADEDIR "/gnomecc.glade", "preferences_dialog"); glade_xml_new (GLADEDIR "/gnomecc.glade", "preferences_dialog",
NULL);
if (!prefs_dialog_data) { if (!prefs_dialog_data) {
g_warning ("Could not find data for preferences dialog"); g_warning ("Could not find data for preferences dialog");

View file

@ -28,7 +28,9 @@ typedef enum _CappletDirViewLayout {
LAYOUT_NONE, LAYOUT_NONE,
LAYOUT_ICON_LIST, LAYOUT_ICON_LIST,
LAYOUT_TREE, LAYOUT_TREE,
#ifdef USE_HTML
LAYOUT_HTML LAYOUT_HTML
#endif
} CappletDirViewLayout; } CappletDirViewLayout;
#define GNOMECC_PREFERENCES(obj) GTK_CHECK_CAST (obj, gnomecc_preferences_get_type (), GnomeCCPreferences) #define GNOMECC_PREFERENCES(obj) GTK_CHECK_CAST (obj, gnomecc_preferences_get_type (), GnomeCCPreferences)