aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--data/glade/prefs-dialog.glade24
-rw-r--r--src/prefs-dialog.c168
3 files changed, 61 insertions, 141 deletions
diff --git a/ChangeLog b/ChangeLog
index edb1ed138..190042e68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2005-10-15 Christian Persch <chpe@cvs.gnome.org>
+ * data/glade/prefs-dialog.glade:
+ * src/prefs-dialog.c: (prefs_dialog_finalize),
+ (download_path_changed_cb), (create_download_path_button),
+ (prefs_dialog_init), (prefs_homepage_blank_button_clicked_cb):
+
+ Use a GtkFileChooserButton for the download path selector.
+ Fixes bug #135738.
+
+2005-10-15 Christian Persch <chpe@cvs.gnome.org>
+
* embed/ephy-favicon-cache.c: (ephy_favicon_cache_download),
(ephy_favicon_cache_get):
* embed/mozilla/EphyBrowser.cpp:
diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade
index 80e9322eb..5421ba76b 100644
--- a/data/glade/prefs-dialog.glade
+++ b/data/glade/prefs-dialog.glade
@@ -17,6 +17,8 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<signal name="response" handler="prefs_dialog_response_cb" last_modification_time="Sat, 10 May 2003 09:37:44 GMT"/>
@@ -302,7 +304,7 @@
<property name="spacing">6</property>
<child>
- <widget class="GtkHBox" id="hbox183">
+ <widget class="GtkHBox" id="download_button_hbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
@@ -320,7 +322,6 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">download_path_button</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@@ -334,22 +335,7 @@
</child>
<child>
- <widget class="GtkButton" id="download_path_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="prefs_download_path_button_clicked_cb"/>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
+ <placeholder/>
</child>
</widget>
<packing>
@@ -1728,6 +1714,8 @@
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index c8e7187b0..2b8d00bd1 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1,6 +1,6 @@
- /*
+/*
* Copyright (C) 200-2003 Marco Pesenti Gritti
- * Copyright (C) 2003, 2004 Christian Persch
+ * Copyright (C) 2003, 2004, 2005 Christian Persch
*
* 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
@@ -57,9 +57,11 @@
#include <gtk/gtklabel.h>
#include <gtk/gtkstock.h>
#include <gtk/gtknotebook.h>
+#include <gtk/gtkfilechooserbutton.h>
#include <string.h>
#define CONF_FONTS_FOR_LANGUAGE "/apps/epiphany/dialogs/preferences_font_language"
+#define DOWNLOAD_BUTTON_WIDTH 8
static void prefs_dialog_class_init (PrefsDialogClass *klass);
static void prefs_dialog_init (PrefsDialog *pd);
@@ -76,8 +78,6 @@ void prefs_homepage_blank_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog);
void prefs_language_more_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog);
-void prefs_download_path_button_clicked_cb (GtkWidget *button,
- PrefsDialog *dialog);
void language_editor_add_button_clicked_cb (GtkWidget *button,
PrefsDialog *pd);
void language_editor_remove_button_clicked_cb (GtkWidget *button,
@@ -138,7 +138,7 @@ enum
HOMEPAGE_CURRENT_PROP,
HOMEPAGE_BLANK_PROP,
AUTO_OPEN_PROP,
- DOWNLOAD_PATH_BUTTON_PROP,
+ DOWNLOAD_PATH_HBOX_PROP,
/* Fonts and Colors */
FONTS_LANGUAGE_PROP,
@@ -180,7 +180,7 @@ EphyDialogProperty properties [] =
{ "homepage_current_button", NULL, PT_NORMAL, 0 },
{ "homepage_blank_button", NULL, PT_NORMAL, 0 },
{ "automatic_downloads_checkbutton", CONF_AUTO_DOWNLOADS, PT_AUTOAPPLY, 0 },
- { "download_path_button", NULL, PT_NORMAL, 0 },
+ { "download_button_hbox", NULL, PT_NORMAL, 0 },
/* Fonts and Colors */
{ "fonts_language_combo", CONF_FONTS_FOR_LANGUAGE, PT_AUTOAPPLY, G_TYPE_STRING },
@@ -252,7 +252,6 @@ enum
struct PrefsDialogPrivate
{
- GtkWidget *download_dir_chooser;
GtkTreeView *lang_treeview;
GtkTreeModel *lang_model;
EphyDialog *add_lang_dialog;
@@ -264,10 +263,6 @@ struct PrefsDialogPrivate
GHashTable *iso_3166_table;
};
-/* gtk+' gettext domain */
-#define GTK_DOMAIN "gtk20"
-#define DGETTEXT_GTK_(x) dgettext(GTK_DOMAIN, x)
-
static GObjectClass *parent_class = NULL;
GType
@@ -311,13 +306,6 @@ prefs_dialog_finalize (GObject *object)
g_object_unref (dialog->priv->add_lang_dialog);
}
- if (dialog->priv->download_dir_chooser != NULL)
- {
- g_object_remove_weak_pointer
- (G_OBJECT (dialog->priv->download_dir_chooser),
- (gpointer *) &dialog->priv->download_dir_chooser);
- }
-
g_hash_table_destroy (dialog->priv->iso_639_table);
g_hash_table_destroy (dialog->priv->iso_3166_table);
@@ -1126,58 +1114,55 @@ create_language_section (EphyDialog *dialog)
g_slist_free (ulist);
}
-static char*
-get_download_button_label (void)
+static void
+download_path_changed_cb (GtkFileChooser *button)
{
- char *key, *label, *downloads_path, *converted_dp;
-
- key = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
-
- downloads_path = ephy_file_downloads_dir ();
- converted_dp = g_filename_to_utf8 (downloads_path, -1, NULL, NULL, NULL);
+ char *dir;
- if (key == NULL || g_utf8_collate (key, "~") == 0)
- {
- label = g_strdup (DGETTEXT_GTK_("Home"));
- }
- else if ((converted_dp != NULL && g_utf8_collate (key, converted_dp) == 0) ||
- g_utf8_collate (key, "Downloads") == 0)
+ /* FIXME: use _uri variant when we support downloading
+ * to gnome-vfs remote locations
+ */
+ dir = gtk_file_chooser_get_filename (button);
+ if (dir != NULL)
{
- label = g_strdup (_("Downloads"));
+ eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir);
+ g_free (dir);
}
- else if (g_utf8_collate (key, "~/Desktop") == 0 ||
- g_utf8_collate (key, "Desktop") == 0)
- {
- label = g_strdup (DGETTEXT_GTK_("Desktop"));
- }
- else
- {
- label = g_strdup (key);
- }
-
- g_free (downloads_path);
- g_free (converted_dp);
- g_free (key);
-
- return label;
}
-
+
static void
-create_download_path_label (EphyDialog *dialog)
+create_download_path_button (EphyDialog *dialog)
{
- GtkWidget *button, *label;
+ GtkWidget *parent, *hbox, *button;
+ EphyFileChooser *fc;
char *dir;
- button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id);
-
- dir = get_download_button_label ();
- label = gtk_label_new (dir);
- gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_START);
- gtk_container_add (GTK_CONTAINER (button), label);
- g_free (dir);
- gtk_widget_show (label);
+ dir = ephy_file_downloads_dir ();
+
+ ephy_dialog_get_controls (dialog,
+ properties[DOWNLOAD_PATH_HBOX_PROP].id, &hbox,
+ properties[WINDOW_PROP].id, &parent,
+ NULL);
+
+ fc = ephy_file_chooser_new (_("Select a directory"),
+ parent,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ NULL, EPHY_FILE_FILTER_NONE);
+
+ /* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't expect this */
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (fc), FALSE);
+
+ button = gtk_file_chooser_button_new_with_dialog (GTK_WIDGET (fc));
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), dir);
+ gtk_file_chooser_button_set_width_chars (GTK_FILE_CHOOSER_BUTTON (button),
+ DOWNLOAD_BUTTON_WIDTH);
+ g_signal_connect (button, "current-folder-changed",
+ G_CALLBACK (download_path_changed_cb), dialog);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
gtk_widget_set_sensitive (button, eel_gconf_key_is_writable (CONF_STATE_DOWNLOAD_DIR));
+ g_free (dir);
}
static void
@@ -1192,12 +1177,6 @@ prefs_dialog_init (PrefsDialog *pd)
pd->priv = EPHY_PREFS_DIALOG_GET_PRIVATE (pd);
-#ifdef ENABLE_NLS
- /* Initialize the control centre domain */
- bindtextdomain (GTK_DOMAIN, GNOMELOCALEDIR);
- bind_textdomain_codeset(GTK_DOMAIN, "UTF-8");
-#endif
-
ephy_dialog_construct (dialog,
properties,
ephy_file ("prefs-dialog.glade"),
@@ -1250,7 +1229,7 @@ prefs_dialog_init (PrefsDialog *pd)
create_language_section (dialog);
- create_download_path_label (dialog);
+ create_download_path_button (dialog);
}
void
@@ -1323,60 +1302,3 @@ prefs_homepage_blank_button_clicked_cb (GtkWidget *button,
{
set_homepage_entry (dialog, NULL);
}
-
-static void
-download_path_response_cb (GtkDialog *fc, gint response, EphyDialog *dialog)
-{
- if (response == GTK_RESPONSE_ACCEPT)
- {
- char *dir;
-
- dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc));
- if (dir != NULL)
- {
- GtkWidget *button;
- char *label;
-
- eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir);
-
- button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id);
- label = get_download_button_label ();
- gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), label);
-
- g_free (dir);
- g_free (label);
- }
- }
-
- gtk_widget_destroy (GTK_WIDGET (fc));
-}
-
-void
-prefs_download_path_button_clicked_cb (GtkWidget *button,
- PrefsDialog *dialog)
-{
- if (dialog->priv->download_dir_chooser == NULL)
- {
- GtkWidget *parent;
- EphyFileChooser *fc;
-
- parent = ephy_dialog_get_control
- (EPHY_DIALOG (dialog), properties[WINDOW_PROP].id);
-
- fc = ephy_file_chooser_new (_("Select a directory"),
- GTK_WIDGET (parent),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- NULL, EPHY_FILE_FILTER_NONE);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc),
- g_get_home_dir ());
-
- g_signal_connect (GTK_DIALOG (fc), "response",
- G_CALLBACK (download_path_response_cb),
- dialog);
- dialog->priv->download_dir_chooser = GTK_WIDGET (fc);
- g_object_add_weak_pointer
- (G_OBJECT (fc), (gpointer *) &dialog->priv->download_dir_chooser);
- }
-
- gtk_widget_show (dialog->priv->download_dir_chooser);
-}