Re: [evolution-patches] Patch for #ifdef'ed GtkFileChooser support
- From: Carlos Garnacho <garnacho tuxerver net>
- To: Not Zed <notzed ximian com>
- Cc: Patches <evolution-patches ximian com>
- Subject: Re: [evolution-patches] Patch for #ifdef'ed GtkFileChooser support
- Date: Fri, 23 Jul 2004 00:21:33 +0200
On Thu, 2004-07-22 at 10:04 +0800, Not Zed wrote:
>
> This seems to change an awful lot of unrelated logic. And also
> unecessarily changes a lot of widget types to the more specific type
> for no reason whatsoever, since it still has the stupid glib casts
> anyway.
>
> Any reason for this?
make_safe_filename() in addressbook/gui/widgets/eab-gui-util.c returned
the whole path to the file, which was OK with the GtkFileSelection API,
but with GtkFileChooser we must use gtk_file_chooser_set_current_folder
() and gtk_file_chooser_set_current_name(), so I made it to return only
the filename for being more suitable for both widgets.
e_msg_composer_select_file() in composer/e-msg-composer-select-file.[ch]
is used both for selecting a file and for saving to a file, so I had to
pass it a save_mode parameter to show the correct GtkFileChooserDialog.
composer/e-msg-composer.c uses that function, so I had to change it too.
Regarding to the use of more specific widget types, I don't understand,
I've changed the GtkFileSelection widgets to GtkWidget (and it's more
generic) for reusing this variable in both modes.
I'm attaching a improved patch:
- adds the "use_filechooser" property to all the GnomeFileEntries (for
those which are in glade files, I've added the property directly in the
glade file, if the gtk version is < 2.4.0, libglade will only warn
through console, is that fine for you?)
- fixes a couple of wrong/unused casts
Please, let me know if there are still issues
Carlos
>
> On Wed, 2004-07-21 at 11:19 +0200, Carlos Garnacho wrote:
> > Hi,
> >
> > I've attached a patch for using GtkFileChooser if the Gtk+ version that
> > evo has been compiled against is >= 2.4.0, if not, it will use
> > GtkFileSelection. Seems OK to you?
> >
> > Carlos
> >
> --
>
> Michael Zucchi <notzed ximian com>
> "born to die, live to work, it's
> all downhill from here"
> Novell's Evolution and Free
> Software Developer
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1799
diff -u -r1.1799 ChangeLog
--- addressbook/ChangeLog 22 Jul 2004 13:18:40 -0000 1.1799
+++ addressbook/ChangeLog 22 Jul 2004 21:11:49 -0000
@@ -1,3 +1,8 @@
+2004-07-20 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/widgets/eab-gui-util.c: Optionally use GtkFileChooser if
+ compiled against Gtk+ >= 2.4.0
+
2004-07-19 Radek Doulik <rodo ximian com>
* gui/widgets/eab-vcard-control.c (eab_vcard_control_new): but
Index: addressbook/gui/widgets/eab-gui-util.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/eab-gui-util.c,v
retrieving revision 1.24
diff -u -r1.24 eab-gui-util.c
--- addressbook/gui/widgets/eab-gui-util.c 23 Jun 2004 22:59:21 -0000 1.24
+++ addressbook/gui/widgets/eab-gui-util.c 22 Jul 2004 21:11:52 -0000
@@ -289,12 +289,12 @@
static gint
-file_exists(GtkFileSelection *filesel, const char *filename)
+file_exists(GtkWindow *window, const char *filename)
{
GtkWidget *dialog;
gint response;
- dialog = gtk_message_dialog_new (GTK_WINDOW (filesel),
+ dialog = gtk_message_dialog_new (window,
0,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
@@ -311,22 +311,28 @@
}
typedef struct {
- GtkFileSelection *filesel;
+ GtkWidget *filesel;
char *vcard;
} SaveAsInfo;
static void
save_it(GtkWidget *widget, SaveAsInfo *info)
{
+ const char *filename;
gint error = 0;
gint response = 0;
- const char *filename = gtk_file_selection_get_filename (info->filesel);
+
+#if GTK_CHECK_VERSION(2,4,0)
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (info->filesel));
+#else
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (info->filesel));
+#endif
error = e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC);
if (error == EEXIST) {
- response = file_exists(info->filesel, filename);
+ response = file_exists(GTK_WINDOW (info->filesel), filename);
switch (response) {
case GTK_RESPONSE_ACCEPT : /* Overwrite */
e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC);
@@ -356,25 +362,33 @@
g_free (info);
}
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+filechooser_response (GtkWidget *widget, gint response_id, SaveAsInfo *info)
+{
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ save_it (widget, info);
+ else
+ close_it (widget, info);
+}
+#endif
+
static char *
-make_safe_filename (const char *prefix, char *name)
+make_safe_filename (char *name)
{
- char *safe, *p;
+ char *safe;
if (!name) {
/* This is a filename. Translators take note. */
name = _("card.vcf");
}
- p = strrchr (name, '/');
- if (p)
- safe = g_strdup_printf ("%s%s%s", prefix, p, ".vcf");
+ if (!g_strrstr (name, ".vcf"))
+ safe = g_strdup_printf ("%s%s", name, ".vcf");
else
- safe = g_strdup_printf ("%s/%s%s", prefix, name, ".vcf");
-
- p = strrchr (safe, '/') + 1;
- if (p)
- e_filename_make_safe (p);
+ safe = g_strdup (name);
+
+ e_filename_make_safe (safe);
return safe;
}
@@ -447,26 +461,48 @@
void
eab_contact_save (char *title, EContact *contact, GtkWindow *parent_window)
{
- GtkFileSelection *filesel;
- char *file;
+ GtkWidget *filesel;
+ char *file, *full_filename;
char *name;
SaveAsInfo *info = g_new(SaveAsInfo, 1);
- filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
-
name = e_contact_get (contact, E_CONTACT_FILE_AS);
- file = make_safe_filename (g_get_home_dir(), name);
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
+ file = make_safe_filename (name);
+
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (title,
+ parent_window,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_ACCEPT);
+
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ());
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), file);
+
+ info->filesel = filesel;
+ info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
+ g_signal_connect (G_OBJECT (filesel), "response",
+ G_CALLBACK (filechooser_response), info);
+ g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+#else
+ filesel = gtk_file_selection_new (title);
+
+ full_filename = g_strdup_printf ("%s/%s", g_get_home_dir (), file);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), full_filename);
+ g_free (full_filename);
+
info->filesel = filesel;
info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
- g_signal_connect(filesel->ok_button, "clicked",
+ g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked",
G_CALLBACK (save_it), info);
- g_signal_connect(filesel->cancel_button, "clicked",
+ g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), "clicked",
G_CALLBACK (close_it), info);
g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+#endif
if (parent_window) {
gtk_window_set_transient_for (GTK_WINDOW (filesel),
@@ -475,41 +511,63 @@
}
gtk_widget_show(GTK_WIDGET(filesel));
+ g_free (file);
}
void
eab_contact_list_save (char *title, GList *list, GtkWindow *parent_window)
{
- GtkFileSelection *filesel;
+ GtkWidget *filesel;
SaveAsInfo *info = g_new(SaveAsInfo, 1);
+ char *file, *full_filename;
- filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (title,
+ parent_window,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_ACCEPT);
+#else
+ filesel = gtk_file_selection_new(title);
+#endif
/* This is a filename. Translators take note. */
if (list && list->data && list->next == NULL) {
- char *name, *file;
+ char *name;
name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FILE_AS);
if (!name)
name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FULL_NAME);
- file = make_safe_filename (g_get_home_dir(), name);
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
+ file = make_safe_filename (name);
} else {
- char *file;
- file = make_safe_filename (g_get_home_dir(), _("list"));
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
+ file = make_safe_filename (_("list"));
}
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ());
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), file);
+#else
+ full_filename = g_strdup_printf ("%s/%s", g_get_home_dir (), file);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), full_filename);
+ g_free (full_filename);
+#endif
+
info->filesel = filesel;
info->vcard = eab_contact_list_to_string (list);
-
- g_signal_connect(filesel->ok_button, "clicked",
+
+#if GTK_CHECK_VERSION(2,4,0)
+ g_signal_connect (G_OBJECT (filesel), "response",
+ G_CALLBACK (filechooser_response), info);
+ g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+#else
+ g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked",
G_CALLBACK (save_it), info);
- g_signal_connect(filesel->cancel_button, "clicked",
+ g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), "clicked",
G_CALLBACK (close_it), info);
g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+#endif
if (parent_window) {
gtk_window_set_transient_for (GTK_WINDOW (filesel),
@@ -518,6 +576,7 @@
}
gtk_widget_show(GTK_WIDGET(filesel));
+ g_free (file);
}
typedef struct ContactCopyProcess_ ContactCopyProcess;
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2455
diff -u -r1.2455 ChangeLog
--- calendar/ChangeLog 22 Jul 2004 18:11:24 -0000 1.2455
+++ calendar/ChangeLog 22 Jul 2004 21:12:15 -0000
@@ -1,3 +1,8 @@
+2004-07-22 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/dialogs/alarm-dialog.glade: added the property "use_filechooser"
+ to the GnomeFileEntry
+
2004-07-16 Larry Ewing <lewing ximian com>
* gui/e-meeting-time-sel.c (e_meeting_time_selector_style_set):
Index: calendar/gui/dialogs/alarm-dialog.glade
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/alarm-dialog.glade,v
retrieving revision 1.5
diff -u -r1.5 alarm-dialog.glade
--- calendar/gui/dialogs/alarm-dialog.glade 25 Jun 2004 17:39:26 -0000 1.5
+++ calendar/gui/dialogs/alarm-dialog.glade 22 Jul 2004 21:12:19 -0000
@@ -751,6 +751,7 @@
<property name="max_saved">10</property>
<property name="directory_entry">False</property>
<property name="modal">True</property>
+ <property name="use_filechooser">True</property>
<child internal-child="entry">
<widget class="GtkEntry" id="aalarm-attach">
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.653
diff -u -r1.653 ChangeLog
--- composer/ChangeLog 22 Jul 2004 16:36:15 -0000 1.653
+++ composer/ChangeLog 22 Jul 2004 21:12:24 -0000
@@ -1,3 +1,12 @@
+2004-07-20 Carlos Garnacho Parro <carlosg gnome org>
+
+ * e-msg-composer-select-file.[ch]: Optionally use GtkFileChooser if
+ compiled against Gtk+ >= 2.4.0. (e_msg_composer_select_file): added
+ save_mode parameter
+
+ * e-msg-composer: use the modified e_msg_composer_select_file()
+ function
+
2004-07-22 Radek Doulik <rodo ximian com>
* e-msg-composer.c (set_editor_text): removed body content +
Index: composer/e-msg-composer-select-file.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-select-file.c,v
retrieving revision 1.27
diff -u -r1.27 e-msg-composer-select-file.c
--- composer/e-msg-composer-select-file.c 19 Apr 2004 15:20:26 -0000 1.27
+++ composer/e-msg-composer-select-file.c 22 Jul 2004 21:12:25 -0000
@@ -29,57 +29,108 @@
#include <gtk/gtkbox.h>
#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkfilesel.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
+#include <gtk/gtkversion.h>
+
+#if GTK_CHECK_VERSION(2,4,0)
+#include <gtk/gtkfilechooser.h>
+#include <gtk/gtkfilechooserdialog.h>
+#include <gtk/gtkstock.h>
+#else
+#include <gtk/gtkfilesel.h>
+#endif
#include <libgnomeui/gnome-uidefs.h>
#include "e-msg-composer-select-file.h"
#include <e-util/e-icon-factory.h>
-static GtkFileSelection *
-run_selector(EMsgComposer *composer, const char *title, int multi, gboolean *showinline_p)
+static GtkWidget*
+run_selector(EMsgComposer *composer, const char *title, int multi, gboolean *showinline_p, gboolean save_mode)
{
- GtkFileSelection *selection;
+ GtkWidget *selection;
GtkWidget *showinline = NULL;
char *path;
GList *icon_list;
- selection = (GtkFileSelection *)gtk_file_selection_new(title);
- gtk_window_set_transient_for((GtkWindow *)selection, (GtkWindow *)composer);
- gtk_window_set_wmclass((GtkWindow *)selection, "fileselection", "Evolution:composer");
- gtk_window_set_modal((GtkWindow *)selection, TRUE);
-
- icon_list = e_icon_factory_get_icon_list ("stock_mail-compose");
- if (icon_list) {
- gtk_window_set_icon_list (GTK_WINDOW (selection), icon_list);
- g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
- g_list_free (icon_list);
- }
-
+ path = g_object_get_data((GObject *)composer, "attach_path");
+
+#if GTK_CHECK_VERSION(2,4,0)
+ if (save_mode)
+ selection = gtk_file_chooser_dialog_new (title,
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+ else
+ selection = gtk_file_chooser_dialog_new (title,
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_OK);
+
+ if (!save_mode)
+ gtk_file_chooser_set_select_multiple((GtkFileChooser *) selection, multi);
+
+ /* restore last path used */
+ if (!path)
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), g_get_home_dir ());
+ else
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), path);
+
+ if (showinline_p) {
+ showinline = gtk_check_button_new_with_label (_("Suggest automatic display of attachment"));
+ gtk_widget_show (showinline);
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (selection), showinline);
+ }
+#else
+ selection = gtk_file_selection_new(title);
+
gtk_file_selection_set_select_multiple((GtkFileSelection *)selection, multi);
/* restore last path used */
- path = g_object_get_data((GObject *)composer, "attach_path");
- if (path == NULL) {
+ if (!path) {
path = g_strdup_printf("%s/", g_get_home_dir());
- gtk_file_selection_set_filename(selection, path);
- g_free(path);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION (selection), path);
+ g_free (path);
} else {
- gtk_file_selection_set_filename(selection, path);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION (selection), path);
}
if (showinline_p) {
showinline = gtk_check_button_new_with_label (_("Suggest automatic display of attachment"));
gtk_widget_show (showinline);
- gtk_box_pack_end (GTK_BOX (selection->main_vbox), showinline, FALSE, FALSE, 4);
+ gtk_box_pack_end (GTK_BOX (GTK_FILE_SELECTION (selection)->main_vbox), showinline, FALSE, FALSE, 4);
}
+#endif
+
+ gtk_window_set_transient_for((GtkWindow *)selection, (GtkWindow *)composer);
+ gtk_window_set_wmclass((GtkWindow *)selection, "fileselection", "Evolution:composer");
+ gtk_window_set_modal((GtkWindow *)selection, TRUE);
+
+ icon_list = e_icon_factory_get_icon_list ("stock_mail-compose");
+ if (icon_list) {
+ gtk_window_set_icon_list (GTK_WINDOW (selection), icon_list);
+ g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
+ g_list_free (icon_list);
+ }
+
if (gtk_dialog_run((GtkDialog *)selection) == GTK_RESPONSE_OK) {
if (showinline_p)
*showinline_p = gtk_toggle_button_get_active((GtkToggleButton *)showinline);
- path = g_path_get_dirname(gtk_file_selection_get_filename(selection));
+
+#if GTK_CHECK_VERSION(2,4,0)
+ path = g_path_get_dirname(gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selection)));
+#else
+ path = g_path_get_dirname(gtk_file_selection_get_filename(GTK_FILE_SELECTION (selection)));
+#endif
+
g_object_set_data_full((GObject *)composer, "attach_path", g_strdup_printf("%s/", path), g_free);
g_free(path);
} else {
@@ -94,6 +145,7 @@
* e_msg_composer_select_file:
* @composer: a composer
* @title: the title for the file selection dialog box
+ * @save_mode: whether the file selection box should be shown in save mode or not
*
* This pops up a file selection dialog box with the given title
* and allows the user to select a file.
@@ -102,14 +154,18 @@
* cancelled.
**/
char *
-e_msg_composer_select_file (EMsgComposer *composer, const char *title)
+e_msg_composer_select_file (EMsgComposer *composer, const char *title, gboolean save_mode)
{
- GtkFileSelection *selection;
+ GtkWidget *selection;
char *name = NULL;
- selection = run_selector (composer, title, TRUE, NULL);
+ selection = run_selector (composer, title, TRUE, FALSE, save_mode);
if (selection) {
- name = g_strdup(gtk_file_selection_get_filename(selection));
+#if GTK_CHECK_VERSION(2,4,0)
+ name = g_strdup (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selection)));
+#else
+ name = g_strdup (gtk_file_selection_get_filename(GTK_FILE_SELECTION (selection)));
+#endif
gtk_widget_destroy((GtkWidget *)selection);
}
@@ -119,22 +175,42 @@
GPtrArray *
e_msg_composer_select_file_attachments (EMsgComposer *composer, gboolean *showinline_p)
{
- GtkFileSelection *selection;
+ GtkWidget *selection;
GPtrArray *list = NULL;
- char **files;
- int i;
- selection = run_selector(composer, _("Attach file(s)"), TRUE, showinline_p);
+ selection = run_selector(composer, _("Attach file(s)"), TRUE, showinline_p, FALSE);
+
if (selection) {
- files = gtk_file_selection_get_selections(selection);
+#if GTK_CHECK_VERSION(2,4,0)
+ GSList *files, *l;
+
+ files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (selection));
+
+ if (files) {
+ list = g_ptr_array_new ();
+ l = files;
+
+ while (l) {
+ g_ptr_array_add (list, l->data);
+ l = l->next;
+ }
+
+ g_slist_free (files);
+ }
+#else
+ char **files;
+ int i;
+
+ files = gtk_file_selection_get_selections(GTK_FILE_SELECTION (selection));
- if (files != NULL) {
+ if (files) {
list = g_ptr_array_new ();
for (i = 0; files[i]; i++)
g_ptr_array_add (list, g_strdup (files[i]));
g_strfreev (files);
}
+#endif
gtk_widget_destroy((GtkWidget *)selection);
}
Index: composer/e-msg-composer-select-file.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-select-file.h,v
retrieving revision 1.5
diff -u -r1.5 e-msg-composer-select-file.h
--- composer/e-msg-composer-select-file.h 11 Dec 2001 01:01:05 -0000 1.5
+++ composer/e-msg-composer-select-file.h 22 Jul 2004 21:12:25 -0000
@@ -27,7 +27,8 @@
#include "e-msg-composer.h"
char *e_msg_composer_select_file (EMsgComposer *composer,
- const char *title);
+ const char *title,
+ gboolean save_mode);
GPtrArray *e_msg_composer_select_file_attachments (EMsgComposer *composer,
gboolean *inline_p);
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.475
diff -u -r1.475 e-msg-composer.c
--- composer/e-msg-composer.c 22 Jul 2004 16:36:15 -0000 1.475
+++ composer/e-msg-composer.c 22 Jul 2004 21:12:37 -0000
@@ -1172,7 +1172,7 @@
if (default_filename != NULL)
filename = g_strdup (default_filename);
else
- filename = e_msg_composer_select_file (composer, _("Save as..."));
+ filename = e_msg_composer_select_file (composer, _("Save as..."), TRUE);
if (filename == NULL)
return;
@@ -1570,7 +1570,7 @@
composer = E_MSG_COMPOSER (data);
- file_name = e_msg_composer_select_file (composer, _("Open file"));
+ file_name = e_msg_composer_select_file (composer, _("Open file"), FALSE);
if (file_name == NULL)
return;
Index: e-util/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.472
diff -u -r1.472 ChangeLog
--- e-util/ChangeLog 22 Jul 2004 03:35:11 -0000 1.472
+++ e-util/ChangeLog 22 Jul 2004 21:12:39 -0000
@@ -1,3 +1,8 @@
+2004-07-20 Carlos Garnacho Parro <carlosg gnome org>
+
+ * e-dialog-utils.c: Optionally use GtkFileChooser if compiled
+ against Gtk+ >= 2.4.0
+
2004-07-20 Not Zed <NotZed Ximian com>
* e-dialog-utils.c: include config.h. See #61395.
Index: e-util/e-dialog-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-dialog-utils.c,v
retrieving revision 1.19
diff -u -r1.19 e-dialog-utils.c
--- e-util/e-dialog-utils.c 22 Jul 2004 03:35:11 -0000 1.19
+++ e-util/e-dialog-utils.c 22 Jul 2004 21:12:40 -0000
@@ -30,9 +30,17 @@
#include <gdk/gdkx.h>
-#include <gtk/gtkfilesel.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkplug.h>
+#include <gtk/gtkversion.h>
+
+#if GTK_CHECK_VERSION(2,4,0)
+#include <gtk/gtkfilechooser.h>
+#include <gtk/gtkfilechooserdialog.h>
+#include <gtk/gtkstock.h>
+#else
+#include <gtk/gtkfilesel.h>
+#endif
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
@@ -242,7 +250,11 @@
int btn = GTK_RESPONSE_YES;
fs = gtk_widget_get_toplevel (widget);
+#if GTK_CHECK_VERSION(2,4,0)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs));
+#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
+#endif
if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
GtkWidget *dlg;
@@ -265,25 +277,49 @@
gtk_main_quit ();
}
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+filechooser_response (GtkWidget *fc, gint response_id, gpointer data)
+{
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ save_ok (fc, data);
+ else
+ gtk_widget_destroy (fc);
+}
+#endif
+
char *
e_file_dialog_save (const char *title)
{
- GtkFileSelection *fs;
+ GtkWidget *selection;
char *path, *filename = NULL;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (title));
+
+#if GTK_CHECK_VERSION(2,4,0)
+ selection = gtk_file_chooser_dialog_new (title,
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), g_get_home_dir ());
+
+ g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (filechooser_response), &filename);
+#else
+ selection = gtk_file_selection_new (title);
path = g_strdup_printf ("%s/", g_get_home_dir ());
- gtk_file_selection_set_filename (fs, path);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection), path);
g_free (path);
+
+ g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->ok_button), "clicked", G_CALLBACK (save_ok), &filename);
+ g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->cancel_button), "clicked", G_CALLBACK (gtk_main_quit), NULL);
+#endif
- g_signal_connect (fs->ok_button, "clicked", G_CALLBACK (save_ok), &filename);
- g_signal_connect (fs->cancel_button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs));
+ gtk_widget_show (GTK_WIDGET (selection));
+ gtk_grab_add (GTK_WIDGET (selection));
gtk_main ();
- gtk_widget_destroy (GTK_WIDGET (fs));
+ gtk_widget_destroy (GTK_WIDGET (selection));
return filename;
}
Index: filter/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/filter/ChangeLog,v
retrieving revision 1.416
diff -u -r1.416 ChangeLog
--- filter/ChangeLog 21 Jun 2004 18:53:07 -0000 1.416
+++ filter/ChangeLog 22 Jul 2004 21:12:42 -0000
@@ -1,3 +1,8 @@
+2004-07-22 Carlos Garnacho Parro <carlosg gnome org>
+
+ * filter-file.c: added the "use_filechooser" property to the
+ GnomeFileEntry
+
2004-06-21 Jeffrey Stedfast <fejj novell com>
* filter-input.c (xml_encode): encode entities. fixes bug #46677.
Index: filter/filter-file.c
===================================================================
RCS file: /cvs/gnome/evolution/filter/filter-file.c,v
retrieving revision 1.19
diff -u -r1.19 filter-file.c
--- filter/filter-file.c 28 Apr 2004 06:38:20 -0000 1.19
+++ filter/filter-file.c 22 Jul 2004 21:12:42 -0000
@@ -286,6 +286,7 @@
GtkWidget *fileentry, *entry;
fileentry = gnome_file_entry_new (NULL, _("Choose a file"));
+ g_object_set (G_OBJECT (fileentry), "use_filechooser", TRUE, NULL);
gnome_file_entry_set_default_path (GNOME_FILE_ENTRY (fileentry), file->path);
gnome_file_entry_set_modal (GNOME_FILE_ENTRY (fileentry), TRUE);
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3417
diff -u -r1.3417 ChangeLog
--- mail/ChangeLog 21 Jul 2004 15:54:00 -0000 1.3417
+++ mail/ChangeLog 22 Jul 2004 21:13:04 -0000
@@ -1,3 +1,10 @@
+2004-07-22 Carlos Garnacho Parro <carlosg gnome org>
+
+ * em-utils.c: Optionally use GtkFileChooser if compiled against
+ Gtk+ >= 2.4.0
+ * mail-config.glade: added the "use_filechooser" property to the
+ various GnomeFileEntries
+
2004-07-19 Jeffrey Stedfast <fejj novell com>
* em-migrate.c (em_migrate_folder): Free uri and name
Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.44
diff -u -r1.44 em-utils.c
--- mail/em-utils.c 14 Jul 2004 15:20:19 -0000 1.44
+++ mail/em-utils.c 22 Jul 2004 21:13:08 -0000
@@ -297,36 +297,53 @@
/* Saving messages... */
-static GtkFileSelection *
+static GtkWidget *
emu_get_save_filesel (GtkWidget *parent, const char *title, const char *name)
{
- GtkFileSelection *filesel;
- char *gdir, *mname = NULL, *filename;
- const char *realname, *dir;
+ GtkWidget *filesel;
+ const char *dir;
+ char *realname, *filename;
GConfClient *gconf;
- filesel = (GtkFileSelection *)gtk_file_selection_new(title);
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (title,
+ GTK_WINDOW (parent),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+#else
+ filesel = gtk_file_selection_new(title);
+#endif
+
if (parent)
e_dialog_set_transient_for((GtkWindow *)filesel, parent);
gconf = gconf_client_get_default();
- dir = gdir = gconf_client_get_string(gconf, "/apps/evolution/mail/save_dir", NULL);
+ dir = gconf_client_get_string(gconf, "/apps/evolution/mail/save_dir", NULL);
g_object_unref(gconf);
+
if (dir == NULL)
dir = g_get_home_dir();
if (name && name[0]) {
- realname = mname = g_strdup(name);
- e_filename_make_safe(mname);
+ realname = g_strdup(name);
+ e_filename_make_safe(realname);
} else {
- realname = "/";
+ realname = NULL;
}
- filename = g_build_filename(dir, realname, NULL);
- gtk_file_selection_set_filename(filesel, filename);
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), dir);
+
+ if (realname)
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), realname);
+#else
+ filename = g_build_filename(dir, G_DIR_SEPARATOR_S, realname, NULL);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION (filesel), filename);
g_free(filename);
- g_free(mname);
- g_free (gdir);
+#endif
return filesel;
}
@@ -367,10 +384,17 @@
}
static void
-emu_save_part_response(GtkFileSelection *filesel, int response, CamelMimePart *part)
+emu_save_part_response(GtkWidget *filesel, int response, CamelMimePart *part)
{
+ const char *path;
+
if (response == GTK_RESPONSE_OK) {
- const char *path = gtk_file_selection_get_filename(filesel);
+
+#if GTK_CHECK_VERSION(2,4,0)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
+ path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#endif
if (!emu_can_save((GtkWindow *)filesel, path))
return;
@@ -396,7 +420,7 @@
em_utils_save_part(GtkWidget *parent, const char *prompt, CamelMimePart *part)
{
const char *name;
- GtkFileSelection *filesel;
+ GtkWidget *filesel;
name = camel_mime_part_get_filename(part);
if (name == NULL) {
@@ -411,8 +435,8 @@
filesel = emu_get_save_filesel(parent, prompt, name);
camel_object_ref(part);
- g_signal_connect(filesel, "response", G_CALLBACK(emu_save_part_response), part);
- gtk_widget_show((GtkWidget *)filesel);
+ g_signal_connect(G_OBJECT (filesel), "response", G_CALLBACK(emu_save_part_response), part);
+ gtk_widget_show(filesel);
}
/**
@@ -468,10 +492,16 @@
};
static void
-emu_save_messages_response(GtkFileSelection *filesel, int response, struct _save_messages_data *data)
+emu_save_messages_response(GtkWidget *filesel, int response, struct _save_messages_data *data)
{
+ const char *path;
+
if (response == GTK_RESPONSE_OK) {
- const char *path = gtk_file_selection_get_filename(filesel);
+#if GTK_CHECK_VERSION(2,4,0)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
+ path = gtk_file_selection_get_filename(GTK_FILE_SELECTION (filesel));
+#endif
if (!emu_can_save((GtkWindow *)filesel, path))
return;
@@ -501,7 +531,7 @@
em_utils_save_messages (GtkWidget *parent, CamelFolder *folder, GPtrArray *uids)
{
struct _save_messages_data *data;
- GtkFileSelection *filesel;
+ GtkWidget *filesel;
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
Index: mail/mail-config.glade
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.glade,v
retrieving revision 1.147
diff -u -r1.147 mail-config.glade
--- mail/mail-config.glade 18 Jun 2004 04:43:59 -0000 1.147
+++ mail/mail-config.glade 22 Jul 2004 21:13:32 -0000
@@ -1230,7 +1230,7 @@
<property name="browse_dialog_title" translatable="yes">Mailbox location</property>
<property name="directory_entry">False</property>
<property name="modal">False</property>
- <property name="use_filechooser">False</property>
+ <property name="use_filechooser">True</property>
<child internal-child="entry">
<widget class="GtkEntry" id="source_path">
@@ -5229,7 +5229,7 @@
<property name="browse_dialog_title" translatable="yes">Execute Command...</property>
<property name="directory_entry">False</property>
<property name="modal">False</property>
- <property name="use_filechooser">False</property>
+ <property name="use_filechooser">True</property>
<child internal-child="entry">
<widget class="GtkEntry" id="txtNotifyPlaySound">
@@ -8325,7 +8325,7 @@
<property name="max_saved">10</property>
<property name="directory_entry">False</property>
<property name="modal">False</property>
- <property name="use_filechooser">False</property>
+ <property name="use_filechooser">True</property>
<child internal-child="entry">
<widget class="GtkEntry" id="combo-entry2">
Index: shell/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1461
diff -u -r1.1461 ChangeLog
--- shell/ChangeLog 9 Jul 2004 11:18:16 -0000 1.1461
+++ shell/ChangeLog 22 Jul 2004 21:13:38 -0000
@@ -1,3 +1,8 @@
+2004-07-22 Carlos Garnacho Parro <carlosg gnome org>
+
+ * e-shell-importer.c: added the "use_filechooser" property to the
+ GnomeFileEntry
+
2004-07-08 Frederic Crozat <fcrozat mandrakesoft com>
* Makefile.am:
Index: shell/e-shell-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-importer.c,v
retrieving revision 1.74
diff -u -r1.74 e-shell-importer.c
--- shell/e-shell-importer.c 1 Jun 2004 18:57:42 -0000 1.74
+++ shell/e-shell-importer.c 22 Jul 2004 21:13:40 -0000
@@ -629,6 +629,7 @@
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
page->filename = gnome_file_entry_new ("Evolution_Importer_FileName", _("Select a file"));
+ g_object_set (G_OBJECT (page->filename), "use_filechooser", TRUE, NULL);
entry = gnome_file_entry_gtk_entry((GnomeFileEntry *)page->filename);
g_signal_connect (entry, "changed", G_CALLBACK (filename_changed), data);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
Index: smime/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/smime/ChangeLog,v
retrieving revision 1.37
diff -u -r1.37 ChangeLog
--- smime/ChangeLog 19 Jul 2004 19:01:52 -0000 1.37
+++ smime/ChangeLog 22 Jul 2004 21:13:42 -0000
@@ -1,3 +1,8 @@
+2004-07-20 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/certificate-manager.c: Optionally use GtkFileChooser if
+ compiled against Gtk+ >= 2.4.0
+
2004-07-16 Chris Toshok <toshok ximian com>
[ fixes #61490 ]
Index: smime/gui/certificate-manager.c
===================================================================
RCS file: /cvs/gnome/evolution/smime/gui/certificate-manager.c,v
retrieving revision 1.13
diff -u -r1.13 certificate-manager.c
--- smime/gui/certificate-manager.c 28 May 2004 09:27:06 -0000 1.13
+++ smime/gui/certificate-manager.c 22 Jul 2004 21:13:44 -0000
@@ -127,10 +127,28 @@
static void
import_your (GtkWidget *widget, CertificateManagerData *cfm)
{
- GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
+ GtkWidget *filesel;
+ const char *filename;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (_("Select a cert to import..."),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+#else
+ filesel = gtk_file_selection_new (_("Select a cert to import..."));
+#endif
if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) {
- const char *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#if GTK_CHECK_VERSION(2,4,0)
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#endif
+
if (e_cert_db_import_pkcs12_file (e_cert_db_peek (),
filename, NULL /* XXX */)) {
/* there's no telling how many certificates were added during the import,
@@ -350,10 +368,27 @@
static void
import_contact (GtkWidget *widget, CertificateManagerData *cfm)
{
- GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
+ GtkWidget *filesel;
+ const char *filename;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (_("Select a cert to import..."),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+#else
+ filesel = gtk_file_selection_new (_("Select a cert to import..."));
+#endif
if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) {
- const char *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#if GTK_CHECK_VERSION(2,4,0)
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#endif
if (e_cert_db_import_certs_from_file (e_cert_db_peek (),
filename,
@@ -553,10 +588,27 @@
static void
import_ca (GtkWidget *widget, CertificateManagerData *cfm)
{
- GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import..."));
+ GtkWidget *filesel;
+ const char *filename;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ filesel = gtk_file_chooser_dialog_new (_("Select a cert to import..."),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+#else
+ filesel = gtk_file_selection_new (_("Select a cert to import..."));
+#endif
if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) {
- const char *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#if GTK_CHECK_VERSION(2,4,0)
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
+ filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#endif
if (e_cert_db_import_certs_from_file (e_cert_db_peek (),
filename,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]