summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserutils.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2005-07-15 04:55:56 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2005-07-15 04:55:56 +0000
commitfb7d6ac4fdbbc2804f3e3dbd87244e5605d6b9d0 (patch)
tree768c291ffb7f5bbd98c1d597014597d9a94f9283 /gtk/gtkfilechooserutils.c
parent7158c558ae285d95d830c0430334484b73ceb97a (diff)
downloadgtk+-fb7d6ac4fdbbc2804f3e3dbd87244e5605d6b9d0.tar.gz
Add overwrite confirmation for SAVE mode. Fixes bug #152850:
2005-07-14 Federico Mena Quintero <federico@ximian.com> Add overwrite confirmation for SAVE mode. Fixes bug #152850: * gtk/gtkfilechooser.h: Add prototypes for gtk_file_chooser_set/get_do_overwrite_confirmation(). (GtkFileChooserConfirmation): New enum for the result of the "confirm-overwrite" signal. * gtk/gtkmarshalers.list: Add ENUM:VOID. * gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a "do-overwrite-confirmation" boolean property. (gtk_file_chooser_set_do_overwrite_confirmation): Implement. (gtk_file_chooser_get_do_overwrite_confirmation): Implement. (confirm_overwrite_accumulator): New accumulator for the signal. * gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION. * gtk/gtkfilechooserutils.c (_gtk_file_chooser_install_properties): Override the do-overwrite-confirmation property. * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add a confirm_overwrite signal to the vtable. * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property): Handle the new property. (gtk_file_chooser_default_get_property): Likewise. (get_selected_file_info_from_file_list): New helper function; code taken from list_selection_changed(). (list_selection_changed): Use get_selected_file_info_from_file_list(). (should_respond_after_confirm_overwrite): New function. (gtk_file_chooser_default_should_respond): Confirm when necessary.
Diffstat (limited to 'gtk/gtkfilechooserutils.c')
-rw-r--r--gtk/gtkfilechooserutils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index 91275db9b2..c8d303dab0 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -66,6 +66,9 @@ static void delegate_update_preview (GtkFileChooser *choose
static void delegate_file_activated (GtkFileChooser *chooser,
gpointer data);
+static GtkFileChooserConfirmation delegate_confirm_overwrite (GtkFileChooser *chooser,
+ gpointer data);
+
/**
* _gtk_file_chooser_install_properties:
* @klass: the class structure for a type deriving from #GObject
@@ -110,6 +113,9 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN,
"show-hidden");
+ g_object_class_override_property (klass,
+ GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION,
+ "do-overwrite-confirmation");
}
/**
@@ -173,6 +179,8 @@ _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
G_CALLBACK (delegate_update_preview), receiver);
g_signal_connect (delegate, "file-activated",
G_CALLBACK (delegate_file_activated), receiver);
+ g_signal_connect (delegate, "confirm-overwrite",
+ G_CALLBACK (delegate_confirm_overwrite), receiver);
}
GQuark
@@ -342,5 +350,15 @@ delegate_file_activated (GtkFileChooser *chooser,
g_signal_emit_by_name (data, "file-activated");
}
+static GtkFileChooserConfirmation
+delegate_confirm_overwrite (GtkFileChooser *chooser,
+ gpointer data)
+{
+ GtkFileChooserConfirmation conf;
+
+ g_signal_emit_by_name (data, "confirm-overwrite", &conf);
+ return conf;
+}
+
#define __GTK_FILE_CHOOSER_UTILS_C__
#include "gtkaliasdef.c"