diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2000-06-13 02:54:58 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2000-06-13 02:54:58 +0000 |
commit | 0d32835b0948230e699a8b7c8b3ed196d7744b9a (patch) | |
tree | 0c842fa3ebaa40c0917082069969871b1a7d9bd4 /src/nautilus-link-set-window.c | |
parent | 3e29784ca8db5b317ed2214be26c67fd21c473d0 (diff) | |
download | nautilus-0d32835b0948230e699a8b7c8b3ed196d7744b9a.tar.gz |
various clean-ups for the link set configuration window
various clean-ups for the link set configuration window
Diffstat (limited to 'src/nautilus-link-set-window.c')
-rw-r--r-- | src/nautilus-link-set-window.c | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/nautilus-link-set-window.c b/src/nautilus-link-set-window.c index ce81694b5..de3b41344 100644 --- a/src/nautilus-link-set-window.c +++ b/src/nautilus-link-set-window.c @@ -30,6 +30,7 @@ #include <libgnomevfs/gnome-vfs.h> #include <gtk/gtkwindow.h> +#include <gtk/gtkvbox.h> #include <gtk/gtktogglebutton.h> #include <libnautilus-extensions/nautilus-file.h> @@ -45,6 +46,10 @@ #include "nautilus-window.h" #include "nautilus-link-set-window.h" +/* global to hold the currently allocated link set window, if any */ + +static GtkWindow *link_set_window = NULL; + /* handle the check box toggling */ static void link_set_check_box_toggled (GtkToggleButton *button, GtkWindow *window_to_update) @@ -161,30 +166,38 @@ get_link_set_names() /* create a window used to configure the link sets in the passed in directory */ GtkWindow * -nautilus_link_set_configure_window(const char *directory_path, GtkWindow *window_to_update) -{ - char *title, *temp_str; +nautilus_link_set_configure_window (const char *directory_path, GtkWindow *window_to_update) +{ + char *temp_str; int link_set_count, index; GtkWindow *window; + GtkWidget *vbox, *label; GtkWidget *checkbox_table, *scrolled_window; GList *link_set_names, *current_link_set; /* Create the window. */ window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); gtk_container_set_border_width (GTK_CONTAINER (window), GNOME_PAD); - /* - gtk_widget_set_usize(GTK_WIDGET(window), 240, 160); - */ + gtk_widget_set_usize(GTK_WIDGET(window), 280, 120); /* set the window title */ - title = g_strdup_printf (_("Linksets for %s"), directory_path); - gtk_window_set_title (window, title); - g_free(title); + gtk_window_set_title (window, _("Link sets")); /* fetch the link set names */ link_set_names = get_link_set_names(); link_set_count = g_list_length(link_set_names); + /* allocate a vbox to hold the contents of the window */ + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox); + gtk_widget_show(vbox); + + /* add a descriptive label */ + label = gtk_label_new(_("Add or remove sets of links by clicking on the checkboxes below.")); + gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 4); + gtk_widget_show(label); + /* allocate a table to hold the link set checkboxes */ checkbox_table = gtk_table_new ((link_set_count + 1) / 2, 2, TRUE); gtk_widget_show (checkbox_table); @@ -196,7 +209,7 @@ nautilus_link_set_configure_window(const char *directory_path, GtkWindow *window GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), checkbox_table); - gtk_container_add(GTK_CONTAINER(window), scrolled_window); + gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show (scrolled_window); /* iterate the directory to add a checkbox for each linkset found */ @@ -208,13 +221,40 @@ nautilus_link_set_configure_window(const char *directory_path, GtkWindow *window make_link_set_check_box(directory_path, checkbox_table, index++, temp_str, window_to_update); } - - /* clean up and we're done */ - + nautilus_g_list_free_deep (link_set_names); - + + /* show the window */ + gtk_window_set_position(window, GTK_WIN_POS_CENTER); gtk_widget_show(GTK_WIDGET(window)); return window; } +/* callback to clear the window global when the window is deleted */ +static gboolean +delete_window_callback (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + link_set_window = NULL; + return FALSE; +} + +/* toggle the visiblity of the link set window */ +GtkWindow * +nautilus_link_set_toggle_configure_window (const char *directory_path, GtkWindow *window_to_update) +{ + if (link_set_window != NULL) { + gtk_widget_destroy(GTK_WIDGET(link_set_window)); + link_set_window = NULL; + } else { + link_set_window = nautilus_link_set_configure_window (directory_path, + window_to_update); + + gtk_signal_connect (GTK_OBJECT (link_set_window), "delete_event", + GTK_SIGNAL_FUNC (delete_window_callback), NULL); + } + + return link_set_window; +} |