Merging of my tree.

This contains:

* a few capplets were redone UI wise:

  ui-properties
  keyboard
  background-properties

* splitting of libcapplet out of this modules (into libcapplet)

* new html-based view in the control-center

* initial import of functional root-manager

This stuff isn't all done yet, but I wanted to get it in.

TODO files will hopefully follow.
This commit is contained in:
Jacob Berkman 2000-12-26 19:41:33 +00:00
parent 2749ba455b
commit d42affc965
73 changed files with 6567 additions and 3322 deletions

View file

@ -26,11 +26,22 @@
#endif
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glade/glade.h>
#include "capplet-dir-view.h"
static GnomeAppClass *parent_class;
static GtkCTreeClass *ctree_class;
extern CappletDirViewImpl capplet_dir_view_html;
extern CappletDirViewImpl capplet_dir_view_list;
extern CappletDirViewImpl capplet_dir_view_tree;
CappletDirViewImpl *capplet_dir_view_impl[] = {
NULL,
&capplet_dir_view_list,
&capplet_dir_view_tree,
&capplet_dir_view_html
};
static GtkObjectClass *parent_class;
static GnomeCCPreferences *prefs;
@ -42,178 +53,17 @@ enum {
static GList *window_list;
static GtkWidget *about;
static void capplet_dir_view_init (CappletDirView *view);
static void capplet_dir_view_class_init (CappletDirViewClass *klass);
static void capplet_dir_view_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void capplet_dir_view_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static gint tree_event_cb (GtkCTree *ctree,
GdkEventButton *event,
CappletDirView *view);
static void clear (CappletDirView *view);
static void clean (CappletDirView *view);
static void switch_to_icon_list (CappletDirView *view);
static void create_icon_list (CappletDirView *view);
static void populate_icon_list (CappletDirView *view);
static void switch_to_tree (CappletDirView *view);
static void create_tree (CappletDirView *view);
static void populate_tree_branch (CappletDir *dir, GtkCTree *ctree,
GtkCTreeNode *parent);
static void populate_tree (CappletDirView *view);
static void select_icon_list_cb (GtkWidget *widget,
gint arg1, GdkEvent *event,
CappletDirView *view);
static void select_tree_cb (GtkCTree *ctree,
GtkCTreeNode *node, gint column,
GdkEventButton *event,
CappletDirView *view);
static void preferences_cb (GtkWidget *widget, CappletDirView *view);
static void close_cb (GtkWidget *widget, CappletDirView *view);
static void help_cb (GtkWidget *widget, CappletDirView *view);
static void about_cb (GtkWidget *widget, CappletDirView *view);
static void up_cb (GtkWidget *widget, CappletDirView *view);
static void icons_cb (GtkWidget *widget, CappletDirView *view);
static void tree_cb (GtkWidget *widget, CappletDirView *view);
static void prefs_changed_cb (GnomeCCPreferences *prefs);
static void about_done_cb (GtkWidget *widget, gpointer user_data);
CappletDirView *get_capplet_dir_view (CappletDir *dir,
CappletDirView *launcher);
static GnomeUIInfo file_menu[] = {
GNOMEUIINFO_MENU_PREFERENCES_ITEM (preferences_cb, NULL),
GNOMEUIINFO_MENU_CLOSE_ITEM (close_cb, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo help_menu[] = {
GNOMEUIINFO_ITEM_STOCK (N_("Help on control-center"),
N_("Help with the GNOME control-center."),
help_cb, GNOME_STOCK_PIXMAP_HELP),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK (N_("About"),
N_("About the GNOME control-center."),
about_cb, GNOME_STOCK_MENU_ABOUT),
GNOMEUIINFO_END
};
static GnomeUIInfo menu_bar[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu),
GNOMEUIINFO_MENU_HELP_TREE (help_menu),
GNOMEUIINFO_END
};
static GnomeUIInfo tool_bar[] = {
GNOMEUIINFO_ITEM_STOCK (N_("Up"), N_("Parent Group"), up_cb,
GNOME_STOCK_PIXMAP_UP),
GNOMEUIINFO_ITEM_STOCK (N_("Preferences"),
N_("Control Center Preferences"),
preferences_cb,
GNOME_STOCK_PIXMAP_PREFERENCES),
GNOMEUIINFO_ITEM_STOCK (N_("Close"), N_("Close this Window"),
close_cb, GNOME_STOCK_PIXMAP_CLOSE),
GNOMEUIINFO_END
};
guint
capplet_dir_view_get_type (void)
{
static guint capplet_dir_view_type;
if (!capplet_dir_view_type) {
GtkTypeInfo capplet_dir_view_info = {
"CappletDirView",
sizeof (CappletDirView),
sizeof (CappletDirViewClass),
(GtkClassInitFunc) capplet_dir_view_class_init,
(GtkObjectInitFunc) capplet_dir_view_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
};
capplet_dir_view_type =
gtk_type_unique (gnome_app_get_type (),
&capplet_dir_view_info);
}
return capplet_dir_view_type;
}
static void
capplet_dir_view_init (CappletDirView *view)
{
view->layout = LAYOUT_NONE;
gnome_app_construct (GNOME_APP (view),
"control-center",
_("Control Center"));
gtk_widget_set_usize (GTK_WIDGET (view), 400, 300);
view->scrolled_win = GTK_SCROLLED_WINDOW
(gtk_scrolled_window_new (NULL, NULL));
gtk_scrolled_window_set_policy (view->scrolled_win,
GTK_POLICY_NEVER,
GTK_POLICY_ALWAYS);
gnome_app_create_menus_with_data (GNOME_APP (view), menu_bar, view);
gnome_app_create_toolbar_with_data (GNOME_APP (view), tool_bar, view);
gnome_app_set_contents (GNOME_APP (view),
GTK_WIDGET (view->scrolled_win));
view->up_button = tool_bar[0].widget;
}
static void
capplet_dir_view_class_init (CappletDirViewClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
object_class->destroy =
(void (*) (GtkObject *)) capplet_dir_view_destroy;
object_class->set_arg = capplet_dir_view_set_arg;
object_class->get_arg = capplet_dir_view_get_arg;
gtk_object_add_arg_type ("CappletDirView::layout",
GTK_TYPE_UINT,
GTK_ARG_READWRITE,
ARG_LAYOUT);
gtk_object_add_arg_type ("CappletDirView::capplet_dir",
GTK_TYPE_POINTER,
GTK_ARG_READWRITE,
ARG_CAPPLET_DIR);
parent_class = gtk_type_class (gnome_app_get_type ());
ctree_class = gtk_type_class (gtk_ctree_get_type ());
/* nothing to do here */
}
static void
capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
CappletDirView *view;
CappletDirViewLayout layout;
view = CAPPLET_DIR_VIEW (object);
@ -222,10 +72,45 @@ capplet_dir_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
capplet_dir_view_load_dir (view, GTK_VALUE_POINTER (*arg));
break;
case ARG_LAYOUT:
switch (GTK_VALUE_UINT (*arg)) {
case LAYOUT_ICON_LIST: switch_to_icon_list (view); break;
case LAYOUT_TREE: switch_to_tree (view); break;
layout = CLAMP (GTK_VALUE_UINT (*arg), 0, LAYOUT_HTML);
if (layout == view->layout)
break;
if (view->impl && view->impl->clean)
view->impl->clean (view);
view->layout =layout;
view->impl = capplet_dir_view_impl[layout];
if (view->impl && view->impl->create) {
view->view = view->impl->create (view);
gtk_container_add (GTK_CONTAINER (view->scrolled_win),
view->view);
if (view->capplet_dir && view->impl->populate)
view->impl->populate (view);
gtk_signal_connect (GTK_OBJECT (view->view), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&view->view);
gtk_widget_show (view->view);
}
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view->list_menu),
layout == LAYOUT_ICON_LIST);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view->tree_menu),
layout == LAYOUT_TREE);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view->html_menu),
layout == LAYOUT_HTML);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->list_toggle),
layout == LAYOUT_ICON_LIST);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->tree_toggle),
layout == LAYOUT_TREE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->html_toggle),
layout == LAYOUT_HTML);
break;
default:
break;
@ -252,18 +137,253 @@ capplet_dir_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
}
GtkWidget *
static void
capplet_dir_view_class_init (CappletDirViewClass *klass)
{
GtkObjectClass *object_class;
parent_class = object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy =
(void (*) (GtkObject *)) capplet_dir_view_destroy;
object_class->set_arg = capplet_dir_view_set_arg;
object_class->get_arg = capplet_dir_view_get_arg;
gtk_object_add_arg_type ("CappletDirView::layout",
GTK_TYPE_UINT,
GTK_ARG_READWRITE,
ARG_LAYOUT);
gtk_object_add_arg_type ("CappletDirView::capplet_dir",
GTK_TYPE_POINTER,
GTK_ARG_READWRITE,
ARG_CAPPLET_DIR);
}
guint
capplet_dir_view_get_type (void)
{
static guint capplet_dir_view_type = 0;
if (!capplet_dir_view_type) {
GtkTypeInfo capplet_dir_view_info = {
"CappletDirView",
sizeof (CappletDirView),
sizeof (CappletDirViewClass),
(GtkClassInitFunc) capplet_dir_view_class_init,
(GtkObjectInitFunc) capplet_dir_view_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
};
capplet_dir_view_type =
gtk_type_unique (gtk_object_get_type (),
&capplet_dir_view_info);
}
return capplet_dir_view_type;
}
static void
print_somthing (GtkObject *o, char *s)
{
g_print ("somthing destroyed: %s\n", s);
}
static void
destroy (GtkObject *o, GtkObject *o2)
{
gtk_object_destroy (o2);
}
static void
close_cb (GtkWidget *widget, CappletDirView *view)
{
gtk_widget_destroy (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view)));
}
static void
exit_cb (GtkWidget *w, gpointer data)
{
gtk_main_quit ();
}
static void
menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
{
if (!GTK_CHECK_MENU_ITEM (w)->active)
return;
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
}
static void
html_menu_cb (GtkWidget *w, CappletDirView *view)
{
menu_cb (w, view, LAYOUT_HTML);
}
static void
icon_menu_cb (GtkWidget *w, CappletDirView *view)
{
menu_cb (w, view, LAYOUT_ICON_LIST);
}
static void
tree_menu_cb (GtkWidget *w, CappletDirView *view)
{
menu_cb (w, view, LAYOUT_TREE);
}
static void
button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
{
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
return;
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
}
static void
html_toggle_cb (GtkWidget *w, CappletDirView *view)
{
button_cb (w, view, LAYOUT_HTML);
}
static void
list_toggle_cb (GtkWidget *w, CappletDirView *view)
{
button_cb (w, view, LAYOUT_ICON_LIST);
}
static void
tree_toggle_cb (GtkWidget *w, CappletDirView *view)
{
button_cb (w, view, LAYOUT_TREE);
}
static void
prefs_menu_cb (GtkWidget *widget, CappletDirView *view)
{
gnomecc_preferences_get_config_dialog (prefs);
}
static void
about_menu_cb (GtkWidget *widget, CappletDirView *view)
{
static GtkWidget *about = NULL;
static gchar *authors[] = {
"Bradford Hovinen <hovinen@helixcode.com>",
"Jacob Berkman <jacob@helixcode.com>",
"Johnathan Blandford <jrb@redhat.com>",
NULL
};
if (about) {
gdk_window_show (about->window);
gdk_window_raise (about->window);
return;
}
about = gnome_about_new
(_("GNOME Control Center"), VERSION,
_("Desktop properties manager."),
(const gchar **) authors,
"Copyright (C) 2000 Helix Code, Inc.\n"
"Copyright (C) 1999 Red Hat Software, Inc.",
NULL);
gtk_signal_connect (GTK_OBJECT (about), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&about);
gtk_widget_show (about);
}
static void
back_button_cb (GtkWidget *widget, CappletDirView *view)
{
if (CAPPLET_DIR_ENTRY (view->capplet_dir)->dir)
capplet_dir_view_load_dir
(view, CAPPLET_DIR_ENTRY (view->capplet_dir)->dir);
}
static void
rootm_button_cb (GtkWidget *w, CappletDirView *view)
{
if (GTK_WIDGET_VISIBLE (view->rootm_locked)) {
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 *
capplet_dir_view_new (void)
{
GtkWidget *widget;
GladeXML *xml;
CappletDirView *view;
widget = gtk_widget_new (capplet_dir_view_get_type (),
"layout", prefs->layout,
NULL);
xml = glade_xml_new (GLADEDIR"/gnomecc.glade", "main_window");
if (!xml)
return NULL;
window_list = g_list_append (window_list, widget);
return widget;
view = CAPPLET_DIR_VIEW (gtk_type_new (CAPPLET_DIR_VIEW_TYPE));
window_list = g_list_append (window_list, view);
view->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->parents_option = glade_xml_get_widget (xml, "parents_option");
view->html_toggle = glade_xml_get_widget (xml, "html_toggle");
view->list_toggle = glade_xml_get_widget (xml, "list_toggle");
view->tree_toggle = glade_xml_get_widget (xml, "tree_toggle");
view->html_menu = glade_xml_get_widget (xml, "html_menu");
view->list_menu = glade_xml_get_widget (xml, "list_menu");
view->tree_menu = glade_xml_get_widget (xml, "tree_menu");
view->rootm_button = glade_xml_get_widget (xml, "rootm_button");
view->rootm_locked = glade_xml_get_widget (xml, "rootm_locked");
view->rootm_unlocked = glade_xml_get_widget (xml, "rootm_unlocked");
if (!gnome_preferences_get_toolbar_relief_btn ())
gtk_button_set_relief (GTK_BUTTON (view->rootm_button), GTK_RELIEF_NONE);
gtk_signal_connect (GTK_OBJECT (view->app), "destroy",
GTK_SIGNAL_FUNC (destroy), view);
gtk_signal_connect (GTK_OBJECT (xml), "destroy",
GTK_SIGNAL_FUNC (print_somthing), "glade xml");
gtk_signal_connect (GTK_OBJECT (view->app), "destroy",
GTK_SIGNAL_FUNC (print_somthing), "main window");
gtk_signal_connect (GTK_OBJECT (view), "destroy",
GTK_SIGNAL_FUNC (print_somthing), "capplet dir view");
glade_xml_signal_connect_data (xml, "close_cb", close_cb, view);
glade_xml_signal_connect_data (xml, "exit_cb", exit_cb, view);
glade_xml_signal_connect_data (xml, "html_menu_cb", html_menu_cb, view);
glade_xml_signal_connect_data (xml, "icon_menu_cb", icon_menu_cb, view);
glade_xml_signal_connect_data (xml, "tree_menu_cb", tree_menu_cb, view);
glade_xml_signal_connect_data (xml, "html_toggle_cb", html_toggle_cb, view);
glade_xml_signal_connect_data (xml, "list_toggle_cb", list_toggle_cb, view);
glade_xml_signal_connect_data (xml, "tree_toggle_cb", tree_toggle_cb, view);
glade_xml_signal_connect_data (xml, "prefs_menu_cb", prefs_menu_cb, view);
glade_xml_signal_connect_data (xml, "about_menu_cb", about_menu_cb, view);
glade_xml_signal_connect_data (xml, "back_button_cb", back_button_cb, view);
glade_xml_signal_connect_data (xml, "rootm_button_cb", rootm_button_cb, view);
gtk_object_unref (GTK_OBJECT (xml));
gtk_object_set (GTK_OBJECT (view), "layout", prefs->layout, NULL);
return view;
}
void
@ -279,286 +399,81 @@ capplet_dir_view_destroy (CappletDirView *view)
if (g_list_length (window_list) == 0)
gtk_main_quit ();
GTK_OBJECT_CLASS (parent_class)->destroy (GTK_OBJECT (view));
/* GTK_OBJECT_CLASS (parent_class)->destroy (GTK_OBJECT (view)); */
}
static void
option_menu_activate (GtkWidget *w, CappletDirEntry *entry)
{
CappletDirView *view;
view = gtk_object_get_user_data (GTK_OBJECT (w));
if (!IS_CAPPLET_DIR_VIEW (view))
return;
capplet_dir_entry_activate (entry, view);
}
void
capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir)
{
GtkWidget *menu, *menuitem, *w, *hbox;
GdkPixbuf *pb, *scaled;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
CappletDirEntry *entry;
int parents = 0;
g_return_if_fail (view != NULL);
g_return_if_fail (IS_CAPPLET_DIR_VIEW (view));
view->capplet_dir = dir;
clear (view);
if (view->impl && view->impl->clear)
view->impl->clear (view);
if (!dir || view->layout == LAYOUT_NONE) return;
switch (view->layout) {
case LAYOUT_ICON_LIST: populate_icon_list (view); break;
case LAYOUT_TREE: populate_tree (view); break;
}
if (view->impl && view->impl->populate)
view->impl->populate (view);
if (CAPPLET_DIR_ENTRY (dir)->dir == NULL)
gtk_widget_set_sensitive (view->up_button, FALSE);
else
gtk_widget_set_sensitive (view->up_button, TRUE);
}
/* Clear all the icons/entries from the view */
menu = gtk_menu_new ();
static void
clear (CappletDirView *view)
{
switch (view->layout) {
case LAYOUT_ICON_LIST:
gnome_icon_list_clear (view->u.icon_list);
break;
case LAYOUT_TREE:
gtk_clist_clear (GTK_CLIST (view->u.tree));
break;
}
}
for (entry = CAPPLET_DIR_ENTRY (dir); entry; entry = CAPPLET_DIR_ENTRY (entry->dir), parents++) {
menuitem = gtk_menu_item_new ();
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
/* Destroy the object that holds the view */
w = gnome_pixmap_new_from_file_at_size (entry->icon, 16, 16);
gtk_box_pack_start (GTK_BOX (hbox), w,
FALSE, FALSE, 0);
static void
clean (CappletDirView *view)
{
switch (view->layout) {
case LAYOUT_ICON_LIST:
gtk_object_destroy (GTK_OBJECT (view->u.icon_list));
break;
case LAYOUT_TREE:
gtk_object_destroy (GTK_OBJECT (view->u.tree));
break;
}
}
w = gtk_label_new (entry->label);
gtk_box_pack_start (GTK_BOX (hbox), w,
FALSE, FALSE, 0);
static void
switch_to_icon_list (CappletDirView *view)
{
if (view->layout != LAYOUT_ICON_LIST) {
clean (view);
create_icon_list (view);
view->layout = LAYOUT_ICON_LIST;
}
}
gtk_container_add (GTK_CONTAINER (menuitem), hbox);
static void
create_icon_list (CappletDirView *view)
{
GtkAdjustment *adjustment;
int i;
adjustment = gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (view->scrolled_win));
view->u.icon_list =
GNOME_ICON_LIST (gnome_icon_list_new (96, adjustment, 0));
gtk_container_add (GTK_CONTAINER (view->scrolled_win),
GTK_WIDGET (view->u.icon_list));
if (view->selected)
view->capplet_dir = view->selected->dir;
if (view->capplet_dir) populate_icon_list (view);
if (view->selected) {
for (i = 0; view->capplet_dir->entries[i]; i++)
if (view->capplet_dir->entries[i] == view->selected)
break;
if (view->capplet_dir->entries[i])
gnome_icon_list_select_icon (view->u.icon_list, i);
}
gtk_signal_connect (GTK_OBJECT (view->u.icon_list),
"select-icon",
GTK_SIGNAL_FUNC (select_icon_list_cb),
view);
gtk_widget_show (GTK_WIDGET (view->u.icon_list));
}
static void
populate_icon_list (CappletDirView *view)
{
int i;
gnome_icon_list_freeze (view->u.icon_list);
for (i = 0; view->capplet_dir->entries[i]; i++)
gnome_icon_list_insert
(view->u.icon_list, i,
view->capplet_dir->entries[i]->icon,
view->capplet_dir->entries[i]->label);
gnome_icon_list_thaw (view->u.icon_list);
}
static void
switch_to_tree (CappletDirView *view)
{
CappletDir *dir, *old_dir;
GtkCTreeNode *node;
if (view->layout != LAYOUT_TREE) {
if (view->capplet_dir) {
old_dir = view->capplet_dir;
while (CAPPLET_DIR_ENTRY (view->capplet_dir)->dir)
view->capplet_dir = CAPPLET_DIR_ENTRY
(view->capplet_dir)->dir;
}
clean (view);
create_tree (view);
view->layout = LAYOUT_TREE;
if (!view->capplet_dir) return;
if (view->selected) {
node = gtk_ctree_find_by_row_data (view->u.tree,
NULL,
view->selected);
gtk_ctree_select (view->u.tree, node);
dir = IS_CAPPLET_DIR (view->selected) ?
CAPPLET_DIR (view->selected) :
view->selected->dir;
} else {
dir = old_dir;
}
while (dir) {
node = gtk_ctree_find_by_row_data (view->u.tree,
NULL, dir);
if (!node) break;
gtk_ctree_expand (view->u.tree, node);
dir = CAPPLET_DIR_ENTRY (dir)->dir;
if (entry != CAPPLET_DIR_ENTRY (dir)) {
gtk_object_set_user_data (GTK_OBJECT (menuitem), view);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (option_menu_activate),
entry);
}
gtk_menu_prepend (GTK_MENU (menu), menuitem);
}
gtk_widget_show_all (menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (view->parents_option), menu);
gtk_option_menu_set_history (GTK_OPTION_MENU (view->parents_option), parents-1);
}
static void
create_tree (CappletDirView *view)
{
GtkAdjustment *adjustment;
adjustment = gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (view->scrolled_win));
view->u.tree = GTK_CTREE (gtk_ctree_new (1, 0));
gtk_container_add (GTK_CONTAINER (view->scrolled_win),
GTK_WIDGET (view->u.tree));
if (view->capplet_dir) populate_tree (view);
gtk_signal_connect (GTK_OBJECT (view->u.tree),
"tree-select-row",
GTK_SIGNAL_FUNC (select_tree_cb),
view);
gtk_signal_connect (GTK_OBJECT (view->u.tree),
"button_press_event",
GTK_SIGNAL_FUNC (tree_event_cb),
view);
gtk_widget_show (GTK_WIDGET (view->u.tree));
}
static void
populate_tree_branch (CappletDir *dir, GtkCTree *ctree, GtkCTreeNode *parent)
{
GdkPixbuf *pixbuf, *scaled;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkCTreeNode *current = NULL;
int i;
capplet_dir_load (dir);
for (i = 0; dir->entries[i]; i++) {
pixbuf = gdk_pixbuf_new_from_file (dir->entries[i]->icon);
scaled = gdk_pixbuf_scale_simple (pixbuf, 16, 16,
GDK_INTERP_TILES);
gdk_pixbuf_render_pixmap_and_mask (scaled, &pixmap, &mask, 1);
gdk_pixbuf_unref (pixbuf);
gdk_pixbuf_unref (scaled);
current = gtk_ctree_insert_node
(ctree, parent, NULL,
&(dir->entries[i]->label),
10, pixmap, mask, pixmap, mask,
IS_CAPPLET (dir->entries[i]), FALSE);
gtk_ctree_node_set_row_data (ctree, current, dir->entries[i]);
if (IS_CAPPLET_DIR (dir->entries[i]))
populate_tree_branch (CAPPLET_DIR (dir->entries[i]),
ctree, current);
}
}
static void
populate_tree (CappletDirView *view)
{
gtk_clist_freeze (GTK_CLIST (view->u.tree));
populate_tree_branch (view->capplet_dir, view->u.tree, NULL);
gtk_clist_thaw (GTK_CLIST (view->u.tree));
}
static gint
tree_event_cb (GtkCTree *ctree, GdkEventButton *event,
CappletDirView *view)
{
CappletDirEntry *entry;
GtkCTreeNode *node;
gint row, column;
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
{
gtk_clist_get_selection_info (GTK_CLIST (ctree),
event->x, event->y,
&row, &column);
node = gtk_ctree_node_nth (ctree, row);
entry = gtk_ctree_node_get_row_data (ctree, node);
if (entry && IS_CAPPLET (entry))
capplet_dir_entry_activate (entry, view);
}
}
static void
select_icon_list_cb (GtkWidget *widget, gint arg1, GdkEvent *event,
CappletDirView *view)
{
if (event->type == GDK_2BUTTON_PRESS &&
((GdkEventButton *) event)->button == 1)
{
capplet_dir_entry_activate
(view->capplet_dir->entries[arg1], view);
view->selected = NULL;
} else {
view->selected = view->capplet_dir->entries[arg1];
}
}
static void
select_tree_cb (GtkCTree *ctree, GtkCTreeNode *node, gint column,
GdkEventButton *event, CappletDirView *view)
{
CappletDirEntry *dir_entry;
dir_entry = gtk_ctree_node_get_row_data (ctree, node);
view->selected = dir_entry;
}
static void
preferences_cb (GtkWidget *widget, CappletDirView *view)
{
gnomecc_preferences_get_config_dialog (prefs);
}
static void
close_cb (GtkWidget *widget, CappletDirView *view)
{
gtk_object_destroy (GTK_OBJECT (view));
}
static void
help_cb (GtkWidget *widget, CappletDirView *view)
@ -583,43 +498,8 @@ help_cb (GtkWidget *widget, CappletDirView *view)
}
}
static void
about_cb (GtkWidget *widget, CappletDirView *view)
{
static gchar *authors[] = {
"Bradford Hovinen <hovinen@helixcode.com>",
NULL
};
if (about == NULL) {
about = gnome_about_new
(_("GNOME Control Center"), VERSION,
"Copyright (C) 2000 Helix Code, Inc.\n",
(const gchar **) authors,
_("Desktop Properties manager."),
NULL);
gtk_signal_connect (GTK_OBJECT (about), "destroy",
about_done_cb, NULL);
}
gtk_widget_show (about);
}
static void
about_done_cb (GtkWidget *widget, gpointer user_data)
{
gtk_widget_hide (about);
}
static void
up_cb (GtkWidget *widget, CappletDirView *view)
{
if (CAPPLET_DIR_ENTRY (view->capplet_dir)->dir)
capplet_dir_view_load_dir
(view, CAPPLET_DIR_ENTRY (view->capplet_dir)->dir);
}
#if 0
static void
icons_cb (GtkWidget *widget, CappletDirView *view)
{
@ -631,6 +511,7 @@ tree_cb (GtkWidget *widget, CappletDirView *view)
{
switch_to_tree (view);
}
#endif
static void
prefs_changed_cb (GnomeCCPreferences *prefs)
@ -638,31 +519,17 @@ prefs_changed_cb (GnomeCCPreferences *prefs)
GList *node;
CappletDirView *view;
switch (prefs->layout) {
case LAYOUT_ICON_LIST:
for (node = window_list; node; node = node->next)
switch_to_icon_list (CAPPLET_DIR_VIEW (node->data));
break;
case LAYOUT_TREE:
node = window_list;
switch_to_tree (CAPPLET_DIR_VIEW (node->data));
capplet_dir_view_load_dir
(CAPPLET_DIR_VIEW (node->data),
get_root_capplet_dir ());
node = node->next;
while (node) {
view = CAPPLET_DIR_VIEW (node->data);
node = node->next;
gtk_object_destroy (GTK_OBJECT (view));
}
break;
}
for (node = window_list; node; node = node->next)
gtk_object_set (GTK_OBJECT (node->data), "layout", prefs->layout, NULL);
}
CappletDirView *
void
capplet_dir_view_show (CappletDirView *view)
{
gtk_widget_show (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view)));
}
static CappletDirView *
get_capplet_dir_view (CappletDir *dir, CappletDirView *launcher)
{
if (prefs->single_window && launcher)