Re: [Fwd: Re: [evolution-patches] Patch for #ifdef'ed GtkFileChooser support]
- From: Carlos Garnacho <garnacho tuxerver net>
- To: Jeffrey Stedfast <fejj ximian com>
- Cc: Chris Toshok <toshok ximian com>, evolution-patches ximian com
- Subject: Re: [Fwd: Re: [evolution-patches] Patch for #ifdef'ed GtkFileChooser support]
- Date: Thu, 12 Aug 2004 16:50:15 +0200
On Fri, 2004-08-06 at 00:45 -0400, Jeffrey Stedfast wrote:
> [commenting on mailer parts of the patch]
>
> [composer]
>
> I think I'd prefer it if run_selector() took a single 'flags' argument
> that was a set of bit-flags.
>
> run_selector (composer, title, SELECTOR_OPEN | SELECTOR_MULTI,
> &show_inline);
This function is declared static and is only used twice in the file, I
don't thing that this is necessary unless it has a wider use, do you
really think it's necessary?
>
> or some such.
>
> + 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);
> + }
>
> can you make sure that the indents here are all tabs? the way they are
> offset from each other suggests that some are spaced over and some are
> tabbed over.
fixed, sorry
>
> in em-utils.c, you end up leaking memory:
>
> 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);
> +#ifdef USE_GTKFILECHOOSER
> + 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;
> }
>
> both realname and dir are leaked (except when dir is init'd using
> g_get_home_dir). this is why there were 2 dir variables :)
You're right, fixed
>
> @@ -398,7 +422,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) {
> @@ -413,8 +437,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);
>
> no need for this G_OBJECT() cast.
>
> + gtk_widget_show(filesel);
> }
>
>
> I think the rest of composer/filter/mail changes look ok.
I'm attaching the patch, hopefully this time it's nice for you :)
Carlos
>
> Jeff
>
>
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.704
diff -u -r1.704 configure.in
--- configure.in 9 Aug 2004 04:56:55 -0000 1.704
+++ configure.in 12 Aug 2004 13:33:05 -0000
@@ -1007,6 +1007,11 @@
$1_LIBS="$EVOLUTION_LIBS $extra_libs"
])
+dnl enable USE_GTKFILECHOOSER if gtk version is > 2.4.0
+if pkg-config --atleast-version=2.4.0 gtk+-2.0; then
+ AC_DEFINE(USE_GTKFILECHOOSER,1,[Use new GtkFileChooser])
+fi
+
dnl --- Required version numbers
GAL_REQUIRED=2.1.13
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1808
diff -u -r1.1808 ChangeLog
--- addressbook/ChangeLog 12 Aug 2004 06:54:17 -0000 1.1808
+++ addressbook/ChangeLog 12 Aug 2004 13:33:23 -0000
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/widgets/eab-gui-util.c: Optionally use GtkFileChooser if
+ compiled against Gtk+ >= 2.4.0
+
2004-08-10 Not Zed <NotZed Ximian com>
* gui/component/addressbook.c (addressbook_authenticate): e
@@ -15,7 +20,6 @@
only in case of ldap
*gui/component/addresbook-view.c (book_open_cb) : no need to
display the error dialog when user cancels that
-
2004-08-04 Rodney Dawes <dobey novell com>
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 12 Aug 2004 13:33:26 -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);
+
+#ifdef USE_GTKFILECHOOSER
+ 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);
}
+#ifdef USE_GTKFILECHOOSER
+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);
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+#ifdef USE_GTKFILECHOOSER
+ 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"));
}
+#ifdef USE_GTKFILECHOOSER
+ 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",
+
+#ifdef USE_GTKFILECHOOSER
+ 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.2484
diff -u -r1.2484 ChangeLog
--- calendar/ChangeLog 12 Aug 2004 06:55:23 -0000 1.2484
+++ calendar/ChangeLog 12 Aug 2004 13:33:46 -0000
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/dialogs/alarm-dialog.glade: added the property "use_filechooser"
+ to the GnomeFileEntry
+
2004-08-10 Not Zed <NotZed Ximian com>
* gui/e-pub-utils.c (e_pub_publish):
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 12 Aug 2004 13:33:50 -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.655
diff -u -r1.655 ChangeLog
--- composer/ChangeLog 28 Jul 2004 18:06:31 -0000 1.655
+++ composer/ChangeLog 12 Aug 2004 13:33:55 -0000
@@ -1,3 +1,12 @@
+2004-07-29 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-28 Not Zed <NotZed Ximian com>
* e-msg-composer.c: Fixes for api changes in mail/ for 61940.
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 12 Aug 2004 13:33:56 -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>
+
+#ifdef USE_GTKFILECHOOSER
+#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");
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+#ifdef USE_GTKFILECHOOSER
+ 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);
+#ifdef USE_GTKFILECHOOSER
+ 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 12 Aug 2004 13:33:56 -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.477
diff -u -r1.477 e-msg-composer.c
--- composer/e-msg-composer.c 28 Jul 2004 18:06:31 -0000 1.477
+++ composer/e-msg-composer.c 12 Aug 2004 13:34:08 -0000
@@ -1175,7 +1175,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;
@@ -1573,7 +1573,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.477
diff -u -r1.477 ChangeLog
--- e-util/ChangeLog 12 Aug 2004 06:53:12 -0000 1.477
+++ e-util/ChangeLog 12 Aug 2004 13:34:11 -0000
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg gnome org>
+
+ * e-dialog-utils.c: Optionally use GtkFileChooser if compiled
+ against Gtk+ >= 2.4.0
+
2004-08-10 Not Zed <NotZed Ximian com>
** See bug #61840, and others.
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 12 Aug 2004 13:34:11 -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>
+
+#ifdef USE_GTKFILECHOOSER
+#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);
+#ifdef USE_GTKFILECHOOSER
+ 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 ();
}
+#ifdef USE_GTKFILECHOOSER
+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));
+
+#ifdef USE_GTKFILECHOOSER
+ 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 12 Aug 2004 13:34:13 -0000
@@ -1,3 +1,8 @@
+2004-07-29 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 12 Aug 2004 13:34:13 -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.3431
diff -u -r1.3431 ChangeLog
--- mail/ChangeLog 12 Aug 2004 06:53:45 -0000 1.3431
+++ mail/ChangeLog 12 Aug 2004 13:34:35 -0000
@@ -1,3 +1,10 @@
+2004-08-12 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-08-10 Not Zed <NotZed Ximian com>
* mail-session.c (get_password): just call
Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.47
diff -u -r1.47 em-utils.c
--- mail/em-utils.c 28 Jul 2004 14:38:50 -0000 1.47
+++ mail/em-utils.c 12 Aug 2004 13:34:39 -0000
@@ -299,35 +299,54 @@
/* 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, *gdir;
GConfClient *gconf;
- filesel = (GtkFileSelection *)gtk_file_selection_new(title);
+#ifdef USE_GTKFILECHOOSER
+ filesel = 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);
+ 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);
+ gdir = 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);
+#ifdef USE_GTKFILECHOOSER
+ 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);
+#endif
+ g_free (realname);
g_free (gdir);
return filesel;
@@ -369,10 +388,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);
+
+#ifdef USE_GTKFILECHOOSER
+ 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;
@@ -398,7 +424,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) {
@@ -413,8 +439,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);
}
/**
@@ -470,10 +496,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);
+#ifdef USE_GTKFILECHOOSER
+ 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;
@@ -503,7 +535,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 12 Aug 2004 13:35:03 -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.1465
diff -u -r1.1465 ChangeLog
--- shell/ChangeLog 12 Aug 2004 06:57:15 -0000 1.1465
+++ shell/ChangeLog 12 Aug 2004 13:35:08 -0000
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg gnome org>
+
+ * e-shell-importer.c: added the "use_filechooser" property to the
+ GnomeFileEntry
+
2004-08-10 Not Zed <NotZed Ximian com>
* main.c (main): init epasswords.
Index: shell/e-shell-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-importer.c,v
retrieving revision 1.75
diff -u -r1.75 e-shell-importer.c
--- shell/e-shell-importer.c 23 Jul 2004 16:44:13 -0000 1.75
+++ shell/e-shell-importer.c 12 Aug 2004 13:35:11 -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.39
diff -u -r1.39 ChangeLog
--- smime/ChangeLog 12 Aug 2004 06:55:36 -0000 1.39
+++ smime/ChangeLog 12 Aug 2004 13:35:13 -0000
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg gnome org>
+
+ * gui/certificate-manager.c: Optionally use GtkFileChooser if
+ compiled against Gtk+ >= 2.4.0
+
2004-08-10 Not Zed <NotZed Ximian com>
* gui/component.c (smime_pk11_passwd, smime_pk11_change_passwd):
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 12 Aug 2004 13:35:15 -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;
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+#ifdef USE_GTKFILECHOOSER
+ 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;
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+#ifdef USE_GTKFILECHOOSER
+ 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;
+
+#ifdef USE_GTKFILECHOOSER
+ 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));
+#ifdef USE_GTKFILECHOOSER
+ 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]