summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Goldberg <jody@gnome.org>2002-07-10 21:25:27 +0000
committerJody Goldberg <jody@src.gnome.org>2002-07-10 21:25:27 +0000
commitbfa7fc3e6d761b433b65affa516ccff5586ed497 (patch)
tree54638f82a826557347594e3054cb6b0dfb7b9c8f
parent70354bdf8f067ba07689b0b9532b6dcf061c9c13 (diff)
downloadgnome-control-center-bfa7fc3e6d761b433b65affa516ccff5586ed497.tar.gz
create and destroy the dialog.
2002-07-10 Jody Goldberg <jody@gnome.org> * theme-switcher.c (show_install_dialog) : create and destroy the dialog.
-rw-r--r--capplets/theme-switcher/ChangeLog5
-rw-r--r--capplets/theme-switcher/Makefile.am2
-rw-r--r--capplets/theme-switcher/theme-properties.glade207
-rw-r--r--capplets/theme-switcher/theme-switcher.c192
4 files changed, 124 insertions, 282 deletions
diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog
index 178ff4830..71c2bc208 100644
--- a/capplets/theme-switcher/ChangeLog
+++ b/capplets/theme-switcher/ChangeLog
@@ -1,3 +1,8 @@
+2002-07-10 Jody Goldberg <jody@gnome.org>
+
+ * theme-switcher.c (show_install_dialog) : create and destroy the
+ dialog.
+
2002-07-05 jacob berkman <jacob@ximian.com>
* theme-switcher.c (transfer_done_cb): do the real work in an idle
diff --git a/capplets/theme-switcher/Makefile.am b/capplets/theme-switcher/Makefile.am
index 3c6e994c8..9bdc2149a 100644
--- a/capplets/theme-switcher/Makefile.am
+++ b/capplets/theme-switcher/Makefile.am
@@ -12,7 +12,7 @@ Desktop_in_files = gtk-theme-selector.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
gladedir = $(GNOMECC_GLADE_DIR)
-glade_DATA = theme-properties.glade
+glade_DATA = theme-properties.glade theme-install.glade
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
diff --git a/capplets/theme-switcher/theme-properties.glade b/capplets/theme-switcher/theme-properties.glade
index c4dd0fec1..4abc68ef4 100644
--- a/capplets/theme-switcher/theme-properties.glade
+++ b/capplets/theme-switcher/theme-properties.glade
@@ -168,119 +168,18 @@
<property name="fill">True</property>
</packing>
</child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Installed Themes</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-<widget class="GtkDialog" id="install_dialog">
- <property name="title" translatable="yes">Install new theme</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="has_separator">False</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
- <property name="border_width">2</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area2">
- <property name="border_width">5</property>
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <property name="spacing">10</property>
-
- <child>
- <widget class="GtkButton" id="helpbutton2">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-help</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="response_id">-11</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button3">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="button4">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="response_id">0</property>
-
- <child>
- <widget class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
<child>
- <widget class="GtkHBox" id="hbox3">
+ <widget class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">2</property>
+ <property name="spacing">8</property>
<child>
- <widget class="GtkImage" id="image2">
+ <widget class="GtkImage" id="image1">
<property name="visible">True</property>
- <property name="stock">gtk-ok</property>
- <property name="icon_size">4</property>
+ <property name="stock">gtk-dialog-info</property>
+ <property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
@@ -294,15 +193,15 @@
</child>
<child>
- <widget class="GtkLabel" id="label7">
+ <widget class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Install</property>
- <property name="use_underline">True</property>
+ <property name="label" translatable="yes">New themes can also be installed by dragging them into the window.</property>
+ <property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
+ <property name="wrap">True</property>
<property name="selectable">False</property>
- <property name="xalign">0.5</property>
+ <property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@@ -314,97 +213,31 @@
</packing>
</child>
</widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
</child>
</widget>
</child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox6">
- <property name="border_width">16</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">16</property>
-
- <child>
- <widget class="GtkImage" id="image3">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-question</property>
- <property name="icon_size">6</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">16</property>
<child>
- <widget class="GtkLabel" id="label8">
+ <widget class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Location of new theme:</property>
- <property name="use_underline">True</property>
+ <property name="label" translatable="yes">Installed Themes</property>
+ <property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
- <property name="xalign">0</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="mnemonic_widget">install_theme_combo_entry</property>
</widget>
<packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GnomeFileEntry" id="install_theme_picker">
- <property name="visible">True</property>
- <property name="max_saved">10</property>
- <property name="directory_entry">False</property>
- <property name="modal">False</property>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="install_theme_combo_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char" translatable="yes">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="type">label_item</property>
</packing>
</child>
</widget>
diff --git a/capplets/theme-switcher/theme-switcher.c b/capplets/theme-switcher/theme-switcher.c
index e8a8a6cf8..70c0894c5 100644
--- a/capplets/theme-switcher/theme-switcher.c
+++ b/capplets/theme-switcher/theme-switcher.c
@@ -248,81 +248,6 @@ sort_func (GtkTreeModel *model,
return g_utf8_collate (a_str, b_str);
}
-/* Callback issued during drag movements */
-
-static gboolean
-drag_motion_cb (GtkWidget *widget, GdkDragContext *context,
- gint x, gint y, guint time, gpointer data)
-{
- return FALSE;
-}
-
-/* Callback issued during drag leaves */
-
-static void
-drag_leave_cb (GtkWidget *widget, GdkDragContext *context,
- guint time, gpointer data)
-{
- gtk_widget_queue_draw (widget);
-}
-
-/* Callback issued on actual drops. Attempts to load the file dropped. */
-static void
-drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
- gint x, gint y,
- GtkSelectionData *selection_data,
- guint info, guint time, gpointer data)
-{
- GList *uris;
- GladeXML *dialog = data;
- gchar *filename;
-
- if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL))
- return;
-
- uris = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
-
- filename = gnome_vfs_uri_to_string (uris->data, GNOME_VFS_URI_HIDE_NONE);
- if (strncmp (filename, "http://", 7) && strncmp (filename, "ftp://", 6))
- {
- g_free (filename);
- filename = gnome_vfs_uri_to_string (uris->data, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
- }
- gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("install_theme_picker")), filename);
- g_free (filename);
- gnome_vfs_uri_list_unref (uris);
- gtk_widget_show (WID ("install_dialog"));
-}
-
-static void
-show_install_dialog (GtkWidget *button, gpointer data)
-{
- GladeXML *dialog = data;
- gtk_widget_show (WID ("install_dialog"));
-}
-
-static void
-show_manage_themes (GtkWidget *button, gpointer data)
-{
- gchar *path, *command;
- GnomeVFSURI *uri;
-
- path = g_strdup_printf ("%s/.themes", g_get_home_dir ());
- uri = gnome_vfs_uri_new (path);
-
- if (!gnome_vfs_uri_exists (uri)) {
- /* Create the directory */
- gnome_vfs_make_directory_for_uri (uri, 0775);
- }
- gnome_vfs_uri_unref (uri);
-
- command = g_strdup_printf ("nautilus --no-desktop %s", path);
- g_free (path);
-
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-}
-
static void
transfer_cancel_cb (GtkWidget *dlg, gchar *path)
{
@@ -397,8 +322,6 @@ install_dialog_response (GtkWidget *widget, int response_id, gpointer data)
if (filename == NULL)
return;
- gtk_widget_hide (widget);
-
src_uri = gnome_vfs_uri_new (filename);
base = gnome_vfs_uri_extract_short_name (src_uri);
src = g_list_append (NULL, src_uri);
@@ -422,8 +345,94 @@ install_dialog_response (GtkWidget *widget, int response_id, gpointer data)
g_signal_connect (G_OBJECT (dlg), "done",
G_CALLBACK (transfer_done_cb), path);
gtk_widget_show (dlg);
- } else
- gtk_widget_hide (widget);
+ }
+}
+
+static void
+show_install_dialog (GtkWidget *button, gpointer parent)
+{
+ GladeXML *dialog = glade_xml_new (GLADEDIR "/theme-install.glade", NULL, NULL);
+ GtkWidget *widget = WID ("install_dialog");
+
+ g_signal_connect (G_OBJECT (widget), "response",
+ G_CALLBACK (install_dialog_response), dialog);
+ gtk_window_set_transient_for (GTK_WINDOW (widget), parent);
+ gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ON_PARENT);
+
+ while (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_HELP)
+ ;
+
+ gtk_widget_destroy (widget);
+ g_object_unref (G_OBJECT (dialog));
+}
+
+/* Callback issued during drag movements */
+
+static gboolean
+drag_motion_cb (GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, guint time, gpointer data)
+{
+ return FALSE;
+}
+
+/* Callback issued during drag leaves */
+
+static void
+drag_leave_cb (GtkWidget *widget, GdkDragContext *context,
+ guint time, gpointer data)
+{
+ gtk_widget_queue_draw (widget);
+}
+
+/* Callback issued on actual drops. Attempts to load the file dropped. */
+static void
+drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time, gpointer data)
+{
+ GList *uris;
+ GladeXML *dialog = data;
+ gchar *filename;
+
+ if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL))
+ return;
+
+ uris = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
+
+ filename = gnome_vfs_uri_to_string (uris->data, GNOME_VFS_URI_HIDE_NONE);
+ if (strncmp (filename, "http://", 7) && strncmp (filename, "ftp://", 6))
+ {
+ g_free (filename);
+ filename = gnome_vfs_uri_to_string (uris->data, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
+ }
+ gnome_file_entry_set_filename (GNOME_FILE_ENTRY (WID ("install_theme_picker")), filename);
+ g_free (filename);
+ gnome_vfs_uri_list_unref (uris);
+
+ show_install_dialog (NULL, widget);
+}
+
+static void
+show_manage_themes (GtkWidget *button, gpointer data)
+{
+ gchar *path, *command;
+ GnomeVFSURI *uri;
+
+ path = g_strdup_printf ("%s/.themes", g_get_home_dir ());
+ uri = gnome_vfs_uri_new (path);
+
+ if (!gnome_vfs_uri_exists (uri)) {
+ /* Create the directory */
+ gnome_vfs_make_directory_for_uri (uri, 0775);
+ }
+ gnome_vfs_uri_unref (uri);
+
+ command = g_strdup_printf ("nautilus --no-desktop %s", path);
+ g_free (path);
+
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
}
static void
@@ -441,11 +450,12 @@ static void
setup_dialog (GladeXML *dialog)
{
GConfClient *client;
- GtkWidget *widget;
+ GtkWidget *widget, *parent;
GtkTreeModel *model;
GtkTreeSelection *selection;
client = gconf_client_get_default ();
+ parent = WID ("theme_dialog");
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (WID ("theme_treeview")),
-1, NULL,
@@ -471,35 +481,29 @@ setup_dialog (GladeXML *dialog)
widget = WID ("install_button");
g_signal_connect (G_OBJECT (widget), "clicked",
- G_CALLBACK (show_install_dialog), dialog);
+ G_CALLBACK (show_install_dialog), parent);
widget = WID ("manage_button");
g_signal_connect (G_OBJECT (widget), "clicked",
G_CALLBACK (show_manage_themes), dialog);
- widget = WID ("install_dialog");
- g_signal_connect (G_OBJECT (widget), "response",
- G_CALLBACK (install_dialog_response), dialog);
-
- widget = WID ("theme_dialog");
-
- g_signal_connect (G_OBJECT (widget),
+ g_signal_connect (G_OBJECT (parent),
"response",
G_CALLBACK (cb_dialog_response), NULL);
- gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
+ gtk_drag_dest_set (parent, GTK_DEST_DEFAULT_ALL,
drop_types, n_drop_types,
GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
- g_signal_connect (G_OBJECT (widget), "drag-motion",
+ g_signal_connect (G_OBJECT (parent), "drag-motion",
G_CALLBACK (drag_motion_cb), NULL);
- g_signal_connect (G_OBJECT (widget), "drag-leave",
+ g_signal_connect (G_OBJECT (parent), "drag-leave",
G_CALLBACK (drag_leave_cb), NULL);
- g_signal_connect (G_OBJECT (widget), "drag-data-received",
+ g_signal_connect (G_OBJECT (parent), "drag-data-received",
G_CALLBACK (drag_data_received_cb),
dialog);
- capplet_set_icon (widget, "gnome-ccthemes.png");
- gtk_widget_show (widget);
+ capplet_set_icon (parent, "gnome-ccthemes.png");
+ gtk_widget_show (parent);
}
int