Implement Compact Add button, and readjust the Hildon toolbar
Actions AddNewsFeed and AddDesktopShortcut are introduced and the toolbar layout for Hildon is changed. Desktop shortcuts are not implemented yet.
This commit is contained in:
parent
7e8f6d5633
commit
8fdb284b54
2 changed files with 117 additions and 22 deletions
|
@ -336,11 +336,21 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
|
|
||||||
action = _action_by_name (browser, "Location");
|
action = _action_by_name (browser, "Location");
|
||||||
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
|
if (g_object_get_data (G_OBJECT (view), "news-feeds"))
|
||||||
|
{
|
||||||
midori_location_action_set_secondary_icon (
|
midori_location_action_set_secondary_icon (
|
||||||
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
|
MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED);
|
||||||
|
#if HAVE_HILDON
|
||||||
|
gtk_action_set_sensitive (_action_by_name (browser, "AddNewsFeed"), TRUE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
midori_location_action_set_secondary_icon (
|
midori_location_action_set_secondary_icon (
|
||||||
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
MIDORI_LOCATION_ACTION (action), GTK_STOCK_JUMP_TO);
|
||||||
|
#if HAVE_HILDON
|
||||||
|
gtk_action_set_sensitive (_action_by_name (browser, "AddNewsFeed"), FALSE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2125,6 +2135,92 @@ _action_add_speed_dial_activate (GtkAction* action,
|
||||||
midori_browser_add_speed_dial (browser);
|
midori_browser_add_speed_dial (browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_action_add_desktop_shortcut_activate (GtkAction* action,
|
||||||
|
MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
#if defined (GDK_WINDOWING_X11)
|
||||||
|
/* TODO: Implement */
|
||||||
|
#elif defined(GDK_WINDOWING_QUARTZ)
|
||||||
|
/* TODO: Implement */
|
||||||
|
#elif defined (GDK_WINDOWING_WIN32)
|
||||||
|
/* TODO: Implement */
|
||||||
|
#elif HAVE_HILDON
|
||||||
|
/* TODO: Implement */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_action_add_news_feed_activate (GtkAction* action,
|
||||||
|
MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
GtkWidget* view;
|
||||||
|
const gchar* uri;
|
||||||
|
|
||||||
|
if (!(view = midori_browser_get_current_tab (browser)))
|
||||||
|
return;
|
||||||
|
if (!(uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (browser->news_aggregator && *browser->news_aggregator)
|
||||||
|
sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_action_compact_add_activate (GtkAction* action,
|
||||||
|
MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
GtkStockItem item;
|
||||||
|
GtkWidget* dialog;
|
||||||
|
GtkBox* box;
|
||||||
|
gchar* label = NULL;
|
||||||
|
GtkWidget* button;
|
||||||
|
|
||||||
|
if (!GTK_WIDGET_VISIBLE (browser))
|
||||||
|
return;
|
||||||
|
|
||||||
|
gtk_stock_lookup (GTK_STOCK_ADD, &item);
|
||||||
|
dialog = g_object_new (GTK_TYPE_DIALOG,
|
||||||
|
"transient-for", browser, "title", item.label, NULL); /* Add a new bookmark */
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_action_tab_close_activate (GtkAction* action,
|
_action_tab_close_activate (GtkAction* action,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
|
@ -2821,7 +2917,9 @@ _action_compact_menu_populate_popup (GtkAction* action,
|
||||||
{ "-" },
|
{ "-" },
|
||||||
#endif
|
#endif
|
||||||
{ "ClearPrivateData" },
|
{ "ClearPrivateData" },
|
||||||
|
#if !HAVE_HILDON
|
||||||
{ "Fullscreen" },
|
{ "Fullscreen" },
|
||||||
|
#endif
|
||||||
{ "Preferences" },
|
{ "Preferences" },
|
||||||
};
|
};
|
||||||
guint i;
|
guint i;
|
||||||
|
@ -3409,21 +3507,7 @@ _action_location_secondary_icon_released (GtkAction* action,
|
||||||
if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
|
if (gtk_window_get_focus (GTK_WINDOW (browser)) == widget)
|
||||||
_action_location_submit_uri (action, uri, FALSE, browser);
|
_action_location_submit_uri (action, uri, FALSE, browser);
|
||||||
else if ((uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
else if ((uri = g_object_get_data (G_OBJECT (view), "news-feeds")))
|
||||||
{
|
_action_add_news_feed_activate (action, browser);
|
||||||
if (browser->news_aggregator && *browser->news_aggregator)
|
|
||||||
sokoke_spawn_program (browser->news_aggregator, uri, TRUE);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
_action_location_submit_uri (action, uri, FALSE, browser);
|
_action_location_submit_uri (action, uri, FALSE, browser);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -4469,6 +4553,15 @@ static const GtkActionEntry entries[] = {
|
||||||
{ "AddSpeedDial", NULL,
|
{ "AddSpeedDial", NULL,
|
||||||
N_("Add to Speed _dial"), "<Ctrl>h",
|
N_("Add to Speed _dial"), "<Ctrl>h",
|
||||||
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
|
N_("Add shortcut to speed dial"), G_CALLBACK (_action_add_speed_dial_activate) },
|
||||||
|
{ "AddDesktopShortcut", NULL,
|
||||||
|
N_("Add Shortcut to the _desktop"), "<Ctrl>h",
|
||||||
|
N_("Add shortcut to the desktop"), G_CALLBACK (_action_add_desktop_shortcut_activate) },
|
||||||
|
{ "AddNewsFeed", NULL,
|
||||||
|
N_("Subscribe to News _feed"), NULL,
|
||||||
|
N_("Subscribe to this news feed"), G_CALLBACK (_action_add_news_feed_activate) },
|
||||||
|
{ "CompactAdd", GTK_STOCK_ADD,
|
||||||
|
NULL, NULL,
|
||||||
|
NULL, G_CALLBACK (_action_compact_add_activate) },
|
||||||
{ "TabClose", GTK_STOCK_CLOSE,
|
{ "TabClose", GTK_STOCK_CLOSE,
|
||||||
N_("_Close Tab"), "<Ctrl>w",
|
N_("_Close Tab"), "<Ctrl>w",
|
||||||
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
|
N_("Close the current tab"), G_CALLBACK (_action_tab_close_activate) },
|
||||||
|
@ -4777,6 +4870,7 @@ static const gchar* ui_markup =
|
||||||
"<separator/>"
|
"<separator/>"
|
||||||
"<menuitem action='SaveAs'/>"
|
"<menuitem action='SaveAs'/>"
|
||||||
"<menuitem action='AddSpeedDial'/>"
|
"<menuitem action='AddSpeedDial'/>"
|
||||||
|
"<menuitem action='AddDesktopShortcut'/>"
|
||||||
"<separator/>"
|
"<separator/>"
|
||||||
"<menuitem action='TabClose'/>"
|
"<menuitem action='TabClose'/>"
|
||||||
"<menuitem action='WindowClose'/>"
|
"<menuitem action='WindowClose'/>"
|
||||||
|
@ -5076,10 +5170,6 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
GtkWidget* homepage;
|
GtkWidget* homepage;
|
||||||
GtkWidget* back;
|
GtkWidget* back;
|
||||||
GtkWidget* forward;
|
GtkWidget* forward;
|
||||||
#if HAVE_HILDON
|
|
||||||
GtkWidget* menu;
|
|
||||||
GList* children;
|
|
||||||
#endif
|
|
||||||
GtkSettings* gtk_settings;
|
GtkSettings* gtk_settings;
|
||||||
GtkWidget* hpaned;
|
GtkWidget* hpaned;
|
||||||
GtkWidget* vpaned;
|
GtkWidget* vpaned;
|
||||||
|
@ -5302,14 +5392,14 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
g_object_unref (action);
|
g_object_unref (action);
|
||||||
|
|
||||||
/* Create the menubar */
|
/* Create the menubar */
|
||||||
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
|
|
||||||
#if HAVE_HILDON
|
#if HAVE_HILDON
|
||||||
browser->menubar = gtk_menu_new ();
|
browser->menubar = gtk_menu_new ();
|
||||||
_action_compact_menu_populate_popup (NULL, browser->menubar, browser);
|
_action_compact_menu_populate_popup (NULL, GTK_MENU (browser->menubar), browser);
|
||||||
hildon_window_set_menu (HILDON_WINDOW (browser), GTK_MENU (browser->menubar));
|
hildon_window_set_menu (HILDON_WINDOW (browser), GTK_MENU (browser->menubar));
|
||||||
hildon_program_add_window (hildon_program_get_instance (),
|
hildon_program_add_window (hildon_program_get_instance (),
|
||||||
HILDON_WINDOW (browser));
|
HILDON_WINDOW (browser));
|
||||||
#else
|
#else
|
||||||
|
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
|
||||||
gtk_widget_hide (browser->menubar);
|
gtk_widget_hide (browser->menubar);
|
||||||
g_signal_connect (browser->menubar, "button-press-event",
|
g_signal_connect (browser->menubar, "button-press-event",
|
||||||
|
@ -5354,6 +5444,8 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
_action_set_sensitive (browser, "EncodingCustom", FALSE);
|
_action_set_sensitive (browser, "EncodingCustom", FALSE);
|
||||||
_action_set_sensitive (browser, "SelectionSourceView", FALSE);
|
_action_set_sensitive (browser, "SelectionSourceView", FALSE);
|
||||||
_action_set_sensitive (browser, "LastSession", FALSE);
|
_action_set_sensitive (browser, "LastSession", FALSE);
|
||||||
|
/* FIXME: Enable once implemented */
|
||||||
|
_action_set_sensitive (browser, "AddDesktopShortcut", FALSE);
|
||||||
|
|
||||||
/* Create the navigationbar */
|
/* Create the navigationbar */
|
||||||
browser->navigationbar = gtk_ui_manager_get_widget (
|
browser->navigationbar = gtk_ui_manager_get_widget (
|
||||||
|
@ -5683,7 +5775,7 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
|
||||||
GtkWidget* toolitem;
|
GtkWidget* toolitem;
|
||||||
|
|
||||||
#if HAVE_HILDON
|
#if HAVE_HILDON
|
||||||
items = "Bookmarks,Window,Back,Forward,ReloadStop,Location,Panel,Trash";
|
items = "Bookmarks,CompactAdd,ReloadStop,Location,Back,Fullscreen";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
|
gtk_container_foreach (GTK_CONTAINER (browser->navigationbar),
|
||||||
|
|
|
@ -1932,6 +1932,9 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
|
||||||
gtk_action_group_get_action (actions, "AddSpeedDial"));
|
gtk_action_group_get_action (actions, "AddSpeedDial"));
|
||||||
gtk_menu_shell_append (menu_shell, menuitem);
|
gtk_menu_shell_append (menu_shell, menuitem);
|
||||||
}
|
}
|
||||||
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
|
gtk_action_group_get_action (actions, "AddDesktopShortcut"));
|
||||||
|
gtk_menu_shell_append (menu_shell, menuitem);
|
||||||
|
|
||||||
menuitem = sokoke_action_create_popup_menu_item (
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
gtk_action_group_get_action (actions, "SaveAs"));
|
gtk_action_group_get_action (actions, "SaveAs"));
|
||||||
|
|
Loading…
Reference in a new issue