Refactor compact add and error message dialogues
This commit is contained in:
parent
a589c2a5bc
commit
dd97edf856
3 changed files with 51 additions and 50 deletions
|
@ -2258,16 +2258,7 @@ midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
|
||||||
if (browser->news_aggregator && *browser->news_aggregator)
|
if (browser->news_aggregator && *browser->news_aggregator)
|
||||||
sokoke_spawn_program (browser->news_aggregator, uri, FALSE);
|
sokoke_spawn_program (browser->news_aggregator, uri, FALSE);
|
||||||
else
|
else
|
||||||
{
|
sokoke_message_dialog (GTK_MESSAGE_INFO, _("New feed"), uri);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2291,8 +2282,9 @@ _action_compact_add_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
GtkWidget* dialog;
|
GtkWidget* dialog;
|
||||||
GtkBox* box;
|
GtkBox* box;
|
||||||
gchar* label = NULL;
|
const gchar* actions[] = { "BookmarkAdd", "AddSpeedDial",
|
||||||
GtkWidget* button;
|
"AddDesktopShortcut", "AddNewsFeed" };
|
||||||
|
guint i;
|
||||||
|
|
||||||
if (!GTK_WIDGET_VISIBLE (browser))
|
if (!GTK_WIDGET_VISIBLE (browser))
|
||||||
return;
|
return;
|
||||||
|
@ -2302,30 +2294,25 @@ _action_compact_add_activate (GtkAction* action,
|
||||||
"title", _("Add a new bookmark"), NULL);
|
"title", _("Add a new bookmark"), NULL);
|
||||||
box = GTK_BOX (GTK_DIALOG (dialog)->vbox);
|
box = GTK_BOX (GTK_DIALOG (dialog)->vbox);
|
||||||
|
|
||||||
action = _action_by_name (browser, "BookmarkAdd");
|
for (i = 0; i < G_N_ELEMENTS (actions); i++)
|
||||||
katze_assign (label, katze_object_get_string (action, "label"));
|
{
|
||||||
button = gtk_button_new_with_mnemonic (label);
|
gchar* label;
|
||||||
gtk_box_pack_start (box, button, TRUE, TRUE, 4);
|
GtkWidget* button;
|
||||||
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);
|
|
||||||
|
|
||||||
|
action = _action_by_name (browser, actions[i]);
|
||||||
|
label = katze_object_get_string (action, "label");
|
||||||
|
button = gtk_button_new_with_mnemonic (label);
|
||||||
g_free (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_dialog_run (GTK_DIALOG (dialog));
|
gtk_widget_show (dialog);
|
||||||
|
g_signal_connect_swapped (dialog, "response",
|
||||||
|
G_CALLBACK (gtk_widget_destroy), dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3455,8 +3442,8 @@ _action_source_view_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
|
if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
|
||||||
uri, "text/plain", gtk_get_current_event_time (), &error))
|
uri, "text/plain", gtk_get_current_event_time (), &error))
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
error ? error->message : "");
|
_("Could not run external program."), error ? error->message : "");
|
||||||
if (error)
|
if (error)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (text_editor);
|
g_free (text_editor);
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
#if HAVE_HILDON
|
#if HAVE_HILDON
|
||||||
#include <libosso.h>
|
#include <libosso.h>
|
||||||
|
#include <hildon/hildon.h>
|
||||||
#include <hildon-mime.h>
|
#include <hildon-mime.h>
|
||||||
#include <hildon-uri.h>
|
#include <hildon-uri.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -97,16 +98,23 @@ sokoke_js_script_eval (JSContextRef js_context,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sokoke_error_dialog (const gchar* short_message,
|
sokoke_message_dialog (GtkMessageType message_type,
|
||||||
|
const gchar* short_message,
|
||||||
const gchar* detailed_message)
|
const gchar* detailed_message)
|
||||||
{
|
{
|
||||||
GtkWidget* dialog = gtk_message_dialog_new (
|
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),
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
"%s", detailed_message);
|
"%s", detailed_message);
|
||||||
gtk_widget_show (dialog);
|
|
||||||
g_signal_connect_swapped (dialog, "response",
|
g_signal_connect_swapped (dialog, "response",
|
||||||
G_CALLBACK (gtk_widget_destroy), dialog);
|
G_CALLBACK (gtk_widget_destroy), dialog);
|
||||||
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +271,8 @@ sokoke_spawn_program (const gchar* command,
|
||||||
osso = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
|
osso = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
|
||||||
if (!osso)
|
if (!osso)
|
||||||
{
|
{
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
_("Could not run external program."),
|
||||||
"Failed to initialize libosso");
|
"Failed to initialize libosso");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +281,8 @@ sokoke_spawn_program (const gchar* command,
|
||||||
if (!dbus)
|
if (!dbus)
|
||||||
{
|
{
|
||||||
osso_deinitialize (osso);
|
osso_deinitialize (osso);
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
_("Could not run external program."),
|
||||||
"Failed to get dbus connection from osso context");
|
"Failed to get dbus connection from osso context");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -299,7 +309,8 @@ sokoke_spawn_program (const gchar* command,
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
_("Could not run external program."),
|
||||||
error ? error->message : "");
|
error ? error->message : "");
|
||||||
if (error)
|
if (error)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
@ -320,7 +331,8 @@ sokoke_spawn_program (const gchar* command,
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!g_shell_parse_argv (command_ready, NULL, &argv, &error))
|
if (!g_shell_parse_argv (command_ready, NULL, &argv, &error))
|
||||||
{
|
{
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
_("Could not run external program."),
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (command_ready);
|
g_free (command_ready);
|
||||||
|
@ -333,7 +345,8 @@ sokoke_spawn_program (const gchar* command,
|
||||||
(GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
(GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
NULL, NULL, NULL, &error))
|
NULL, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
sokoke_error_dialog (_("Could not run external program."),
|
sokoke_message_dialog (GTK_MESSAGE_ERROR,
|
||||||
|
_("Could not run external program."),
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ sokoke_js_script_eval (JSContextRef js_context,
|
||||||
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
|
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
|
||||||
|
|
||||||
void
|
void
|
||||||
sokoke_error_dialog (const gchar* short_message,
|
sokoke_message_dialog (GtkMessageType message_type,
|
||||||
|
const gchar* short_message,
|
||||||
const gchar* detailed_message);
|
const gchar* detailed_message);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
Loading…
Reference in a new issue