MidoriBrowser* browser)
{
GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ gboolean can_undo = FALSE, can_redo = FALSE;
+ #endif
gboolean can_cut = FALSE, can_copy = FALSE, can_paste = FALSE;
gboolean has_selection, can_select_all = FALSE;
if (WEBKIT_IS_WEB_VIEW (widget))
{
WebKitWebView* view = WEBKIT_WEB_VIEW (widget);
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ can_undo = webkit_web_view_can_undo (view);
+ can_redo = webkit_web_view_can_redo (view);
+ #endif
can_cut = webkit_web_view_can_cut_clipboard (view);
can_copy = webkit_web_view_can_copy_clipboard (view);
can_paste = webkit_web_view_can_paste_clipboard (view);
can_select_all = TRUE;
}
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ _action_set_sensitive (browser, "Undo", can_undo);
+ _action_set_sensitive (browser, "Redo", can_redo);
+ #endif
_action_set_sensitive (browser, "Cut", can_cut);
_action_set_sensitive (browser, "Copy", can_copy);
_action_set_sensitive (browser, "Paste", can_paste);
_action_set_sensitive (browser, "SelectAll", can_select_all);
}
+#if WEBKIT_CHECK_VERSION (1, 1, 14)
+static void
+_action_undo_activate (GtkAction* action,
+ MidoriBrowser* browser)
+{
+ GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
+ if (WEBKIT_IS_WEB_VIEW (widget))
+ webkit_web_view_undo (WEBKIT_WEB_VIEW (widget));
+}
+
+static void
+_action_redo_activate (GtkAction* action,
+ MidoriBrowser* browser)
+{
+ GtkWidget* widget = gtk_window_get_focus (GTK_WINDOW (browser));
+ if (WEBKIT_IS_WEB_VIEW (widget))
+ webkit_web_view_redo (WEBKIT_WEB_VIEW (widget));
+}
+#endif
+
static void
_action_cut_activate (GtkAction* action,
MidoriBrowser* browser)
N_("Quit the application"), G_CALLBACK (_action_quit_activate) },
{ "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (_action_edit_activate) },
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ { "Undo", GTK_STOCK_UNDO,
+ NULL, "<Ctrl>z",
+ N_("Undo the last modification"), G_CALLBACK (_action_undo_activate) },
+ { "Redo", GTK_STOCK_REDO,
+ NULL, "<Ctrl><Shift>z",
+ N_("Redo the last modification"), G_CALLBACK (_action_redo_activate) },
+ #endif
{ "Cut", GTK_STOCK_CUT,
NULL, "<Ctrl>x",
N_("Cut the selected text"), G_CALLBACK (_action_cut_activate) },
"<menuitem action='Quit'/>"
"</menu>"
"<menu action='Edit'>"
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ "<menuitem action='Undo'/>"
+ "<menuitem action='Redo'/>"
+ "<separator/>"
+ #endif
"<menuitem action='Cut'/>"
"<menuitem action='Copy'/>"
"<menuitem action='Paste'/>"
icon = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (menuitem));
gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
if (!strcmp (stock_id, GTK_STOCK_CUT))
+ {
+ #if WEBKIT_CHECK_VERSION (1, 1, 14)
+ if (!strcmp (stock_id, GTK_STOCK_UNDO))
+ return;
+ menuitem = gtk_separator_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
+ gtk_widget_show (menuitem);
+ menuitem = sokoke_action_create_popup_menu_item (
+ gtk_action_group_get_action (actions, "Redo"));
+ gtk_widget_set_sensitive (menuitem,
+ webkit_web_view_can_redo (web_view));
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
+ menuitem = sokoke_action_create_popup_menu_item (
+ gtk_action_group_get_action (actions, "Undo"));
+ gtk_widget_set_sensitive (menuitem,
+ webkit_web_view_can_undo (web_view));
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
return;
+ }
+ #endif
if (strcmp (stock_id, GTK_STOCK_FIND))
has_selection = FALSE;
}