[gnome-commander] Added overwrite warning dialog function for respecting text markup
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Added overwrite warning dialog function for respecting text markup
- Date: Wed, 5 Feb 2014 10:52:53 +0000 (UTC)
commit 9bc294f24817e76ef408ea65c5910c8456364d08
Author: Uwe Scholz <uwescholz src gnome org>
Date: Wed Feb 5 11:47:08 2014 +0100
Added overwrite warning dialog function for respecting text markup
src/gnome-cmd-xfer.cc | 18 ++++++++++++----
src/utils.cc | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
src/utils.h | 6 +++++
3 files changed, 71 insertions(+), 5 deletions(-)
---
diff --git a/src/gnome-cmd-xfer.cc b/src/gnome-cmd-xfer.cc
index 677383e..d28750e 100644
--- a/src/gnome-cmd-xfer.cc
+++ b/src/gnome-cmd-xfer.cc
@@ -180,17 +180,25 @@ static gint async_xfer_callback (GnomeVFSAsyncHandle *handle, GnomeVFSXferProgre
gchar *source_details = file_details (info->source_name);
gchar *target_details = file_details (info->target_name);
- gchar *msg = g_strdup_printf (_("Overwrite file:\n\n<b>%s</b>\n<span color='dimgray'
size='smaller'>%s</span>\n\nWith:\n\n<b>%s</b>\n<span color='dimgray' size='smaller'>%s</span>"),
- target_filename, target_details, source_filename, source_details);
+ gchar *msg1 = g_strdup_printf (_("Overwrite file:\n\n"));
+ gchar *msg2 = g_strdup_printf (_("%s\n"),target_filename);
+ gchar *msg3 = g_strdup_printf (_("%s\n\nWith:\n\n"),target_details);
+ gchar *msg4 = g_strdup_printf (_("%s\n"),source_filename);
+ gchar *msg5 = g_strdup_printf (_("%s"), source_details);
+
g_free (source_filename);
g_free (target_filename);
g_free (source_details);
g_free (target_details);
gdk_threads_enter ();
- gint ret = run_simple_dialog (*main_win, FALSE, GTK_MESSAGE_QUESTION, msg, " ",
- 1, _("Abort"), _("Replace"), _("Replace All"), _("Skip"), _("Skip
All"), NULL);
- g_free (msg);
+ gint ret = run_overwrite_warning_dialog (*main_win, FALSE, GTK_MESSAGE_QUESTION, msg1, msg2, msg3,
msg4, msg5, " ",
+ 1, _("Abort"), _("Replace"), _("Replace All"), _("Skip"),
_("Skip All"), NULL);
+ g_free (msg1);
+ g_free (msg2);
+ g_free (msg3);
+ g_free (msg4);
+ g_free (msg5);
data->prev_status = GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE;
gdk_threads_leave ();
return ret==-1 ? 0 : ret;
diff --git a/src/utils.cc b/src/utils.cc
index 2fbf814..82d5b9c 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -185,6 +185,58 @@ gint run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
va_end (button_title_args);
dialog = gtk_message_dialog_new_with_markup (*main_win, GTK_DIALOG_MODAL, msg_type, GTK_BUTTONS_NONE,
"%s", text);
+
+ if (title)
+ gtk_window_set_title (GTK_WINDOW (dialog), title);
+
+ for (int i=0; button_titles[i]; i++)
+ gtk_dialog_add_button (GTK_DIALOG (dialog), button_titles[i], i);
+
+ g_free (button_titles);
+
+ if (def_response>=0)
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), def_response);
+
+ // Allow close.
+ if (ignore_close_box)
+ g_signal_connect (dialog, "delete-event", G_CALLBACK (delete_event_callback), NULL);
+ else
+ g_signal_connect (dialog, "key-press-event", G_CALLBACK (on_run_dialog_keypress), dialog);
+
+ gtk_window_set_wmclass (GTK_WINDOW (dialog), "dialog", "Eel");
+
+ // Run it.
+ do
+ {
+ gtk_widget_show (dialog);
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+ }
+ while (ignore_close_box && result == GTK_RESPONSE_DELETE_EVENT);
+
+ gtk_widget_destroy (dialog);
+
+ return result;
+}
+
+gint run_overwrite_warning_dialog (GtkWidget *parent, gboolean ignore_close_box,
+ GtkMessageType msg_type,
+ const char *textmsg1, const char *textmsg2,
+ const char *textmsg3, const char *textmsg4,
+ const char *textmsg5, const char *title, gint def_response, ...)
+{
+ va_list button_title_args;
+ const char **button_titles;
+ GtkWidget *dialog;
+ // GtkWidget *top_widget;
+ int result;
+
+ // Create the dialog.
+ va_start (button_title_args, def_response);
+ button_titles = convert_varargs_to_name_array (button_title_args);
+ va_end (button_title_args);
+
+ dialog = gtk_message_dialog_new_with_markup (*main_win, GTK_DIALOG_MODAL, msg_type, GTK_BUTTONS_NONE,
"%s<b>%s</b><span color='dimgray' size='smaller'>%s</span><b>%s</b><span color='dimgray'
size='smaller'>%s</span>", textmsg1, textmsg2, textmsg3, textmsg4, textmsg5);
+
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
diff --git a/src/utils.h b/src/utils.h
index 792d264..abe4690 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -67,6 +67,12 @@ gint run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
GtkMessageType msg_type,
const char *text, const char *title, gint def_response, ...);
+gint run_overwrite_warning_dialog (GtkWidget *parent, gboolean ignore_close_box,
+ GtkMessageType msg_type,
+ const char *textmsg1, const char *textmsg2,
+ const char *textmsg3, const char *textmsg4,
+ const char *textmsg5, const char *title, gint def_response, ...);
+
inline gboolean string2int (const gchar *s, gint &i)
{
return sscanf (s, "%d", &i) == 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]