[Xfce4-commits] <midori:master> Refactor compact add and error message dialogues
Christian Dywan
noreply at xfce.org
Sun Nov 29 14:12:14 CET 2009
Updating branch refs/heads/master
to dd97edf8565148246435a6b36885b1d66906d9e3 (commit)
from a589c2a5bcf03fe9b6de2a2fc7f6e39f6c108628 (commit)
commit dd97edf8565148246435a6b36885b1d66906d9e3
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Nov 29 14:08:52 2009 +0100
Refactor compact add and error message dialogues
midori/midori-browser.c | 63 ++++++++++++++++++----------------------------
midori/sokoke.c | 39 +++++++++++++++++++---------
midori/sokoke.h | 3 +-
3 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index c2e3fdb..8afd16a 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2258,16 +2258,7 @@ midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
if (browser->news_aggregator && *browser->news_aggregator)
sokoke_spawn_program (browser->news_aggregator, uri, FALSE);
else
- {
- GtkWidget* dialog = gtk_message_dialog_new (
- GTK_WINDOW (browser), 0, GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK, "%s", _("New feed"));
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog), "%s", uri);
- gtk_widget_show (dialog);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
- }
+ sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), uri);
}
static void
@@ -2291,8 +2282,9 @@ _action_compact_add_activate (GtkAction* action,
{
GtkWidget* dialog;
GtkBox* box;
- gchar* label = NULL;
- GtkWidget* button;
+ const gchar* actions[] = { "BookmarkAdd", "AddSpeedDial",
+ "AddDesktopShortcut", "AddNewsFeed" };
+ guint i;
if (!GTK_WIDGET_VISIBLE (browser))
return;
@@ -2302,30 +2294,25 @@ _action_compact_add_activate (GtkAction* action,
"title", _("Add a new bookmark"), NULL);
box = GTK_BOX (GTK_DIALOG (dialog)->vbox);
- action = _action_by_name (browser, "BookmarkAdd");
- katze_assign (label, katze_object_get_string (action, "label"));
- button = gtk_button_new_with_mnemonic (label);
- gtk_box_pack_start (box, button, TRUE, TRUE, 4);
- gtk_action_connect_proxy (action, button);
- action = _action_by_name (browser, "AddSpeedDial");
- katze_assign (label, katze_object_get_string (action, "label"));
- button = gtk_button_new_with_mnemonic (label);
- gtk_box_pack_start (box, button, TRUE, TRUE, 4);
- gtk_action_connect_proxy (action, button);
- action = _action_by_name (browser, "AddDesktopShortcut");
- katze_assign (label, katze_object_get_string (action, "label"));
- button = gtk_button_new_with_mnemonic (label);
- gtk_box_pack_start (box, button, TRUE, TRUE, 4);
- gtk_action_connect_proxy (action, button);
- action = _action_by_name (browser, "AddNewsFeed");
- katze_assign (label, katze_object_get_string (action, "label"));
- button = gtk_button_new_with_mnemonic (label);
- gtk_box_pack_start (box, button, TRUE, TRUE, 4);
- gtk_action_connect_proxy (action, button);
-
- g_free (label);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
+ for (i = 0; i < G_N_ELEMENTS (actions); i++)
+ {
+ gchar* label;
+ GtkWidget* button;
+
+ action = _action_by_name (browser, actions[i]);
+ label = katze_object_get_string (action, "label");
+ button = gtk_button_new_with_mnemonic (label);
+ g_free (label);
+ gtk_widget_set_name (button, "GtkButton-thumb");
+ gtk_box_pack_start (box, button, TRUE, TRUE, 4);
+ gtk_action_connect_proxy (action, button);
+ g_signal_connect_swapped (button, "clicked",
+ G_CALLBACK (gtk_widget_destroy), dialog);
+ }
+
+ gtk_widget_show (dialog);
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), dialog);
}
static void
@@ -3455,8 +3442,8 @@ _action_source_view_activate (GtkAction* action,
{
if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
uri, "text/plain", gtk_get_current_event_time (), &error))
- sokoke_error_dialog (_("Could not run external program."),
- error ? error->message : "");
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."), error ? error->message : "");
if (error)
g_error_free (error);
g_free (text_editor);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 373c52f..823662a 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -46,6 +46,7 @@
#if HAVE_HILDON
#include <libosso.h>
+ #include <hildon/hildon.h>
#include <hildon-mime.h>
#include <hildon-uri.h>
#endif
@@ -97,16 +98,23 @@ sokoke_js_script_eval (JSContextRef js_context,
}
void
-sokoke_error_dialog (const gchar* short_message,
- const gchar* detailed_message)
+sokoke_message_dialog (GtkMessageType message_type,
+ const gchar* short_message,
+ const gchar* detailed_message)
{
GtkWidget* dialog = gtk_message_dialog_new (
- NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", short_message);
+ NULL, 0, message_type,
+ #if HAVE_HILDON
+ GTK_BUTTONS_NONE,
+ #else
+ GTK_BUTTONS_OK,
+ #endif
+ "%s", short_message);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", detailed_message);
- gtk_widget_show (dialog);
g_signal_connect_swapped (dialog, "response",
G_CALLBACK (gtk_widget_destroy), dialog);
+ gtk_widget_show (dialog);
}
/**
@@ -263,8 +271,9 @@ sokoke_spawn_program (const gchar* command,
osso = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
if (!osso)
{
- sokoke_error_dialog (_("Could not run external program."),
- "Failed to initialize libosso");
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."),
+ "Failed to initialize libosso");
return FALSE;
}
@@ -272,8 +281,9 @@ sokoke_spawn_program (const gchar* command,
if (!dbus)
{
osso_deinitialize (osso);
- sokoke_error_dialog (_("Could not run external program."),
- "Failed to get dbus connection from osso context");
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."),
+ "Failed to get dbus connection from osso context");
return FALSE;
}
@@ -299,7 +309,8 @@ sokoke_spawn_program (const gchar* command,
if (!success)
{
- sokoke_error_dialog (_("Could not run external program."),
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."),
error ? error->message : "");
if (error)
g_error_free (error);
@@ -320,8 +331,9 @@ sokoke_spawn_program (const gchar* command,
error = NULL;
if (!g_shell_parse_argv (command_ready, NULL, &argv, &error))
{
- sokoke_error_dialog (_("Could not run external program."),
- error->message);
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."),
+ error->message);
g_error_free (error);
g_free (command_ready);
return FALSE;
@@ -333,8 +345,9 @@ sokoke_spawn_program (const gchar* command,
(GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, NULL, &error))
{
- sokoke_error_dialog (_("Could not run external program."),
- error->message);
+ sokoke_message_dialog (GTK_MESSAGE_ERROR,
+ _("Could not run external program."),
+ error->message);
g_error_free (error);
}
diff --git a/midori/sokoke.h b/midori/sokoke.h
index c16e284..5f805a3 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -27,7 +27,8 @@ sokoke_js_script_eval (JSContextRef js_context,
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
void
-sokoke_error_dialog (const gchar* short_message,
+sokoke_message_dialog (GtkMessageType message_type,
+ const gchar* short_message,
const gchar* detailed_message);
gboolean
More information about the Xfce4-commits
mailing list