diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-11-02 21:33:38 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-11-02 21:33:38 (EDT) |
commit | e14e45f1dd86488e886cc03d7dd14f5bc19a6f69 (patch) | |
tree | 9b82dc22c1124c9bbfebd1c50d148e05083ef31a /src/toolbars | |
parent | feae93a333d53e670a345638fb280dc0e47b6c87 (diff) | |
download | marquee-e14e45f1dd86488e886cc03d7dd14f5bc19a6f69.zip marquee-e14e45f1dd86488e886cc03d7dd14f5bc19a6f69.tar.gz marquee-e14e45f1dd86488e886cc03d7dd14f5bc19a6f69.tar.bz2 |
MqMainMenu: Add Cut, Copy, and Paste buttons
Diffstat (limited to 'src/toolbars')
-rw-r--r-- | src/toolbars/navigation/main-menu.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/toolbars/navigation/main-menu.c b/src/toolbars/navigation/main-menu.c index 30a8499..3ff844a 100644 --- a/src/toolbars/navigation/main-menu.c +++ b/src/toolbars/navigation/main-menu.c @@ -54,6 +54,38 @@ struct _MqMainMenuClass { G_DEFINE_TYPE(MqMainMenu, mq_main_menu, GTK_TYPE_TOOL_BUTTON) static void +can_edit_cb(WebKitWebView *web_view, GAsyncResult *result, GtkWidget *button) +{ + gtk_widget_set_sensitive(button, + webkit_web_view_can_execute_editing_command_finish(web_view, + result, NULL)); +} + +static void +cut_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu) +{ + webkit_web_view_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_CUT); +} + +static void +copy_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu) +{ + webkit_web_view_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_COPY); +} + +static void +paste_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu) +{ + webkit_web_view_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_PASTE); +} + +static void zoom_out_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu) { mq_web_view_zoom_out(main_menu->web_view); @@ -160,6 +192,43 @@ quit_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu) } G_STMT_END static GtkWidget * +create_edit_buttons(MqMainMenu *main_menu) +{ + GtkWidget *box; + GtkWidget *cut_button; + GtkWidget *copy_button; + GtkWidget *paste_button; + + box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(box), TRUE); + gtk_style_context_add_class(gtk_widget_get_style_context(box), + "linked"); + + NEW_BUTTON(cut, "edit-cut", "Cut"); + gtk_widget_set_sensitive(cut_button, FALSE); + webkit_web_view_can_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_CUT, + NULL, (GAsyncReadyCallback) can_edit_cb, cut_button); + + NEW_BUTTON(copy, "edit-copy", "Copy"); + gtk_widget_set_sensitive(copy_button, FALSE); + webkit_web_view_can_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_COPY, + NULL, (GAsyncReadyCallback) can_edit_cb, copy_button); + + NEW_BUTTON(paste, "edit-paste", "Paste"); + gtk_widget_set_sensitive(paste_button, FALSE); + webkit_web_view_can_execute_editing_command( + WEBKIT_WEB_VIEW(main_menu->web_view), + WEBKIT_EDITING_COMMAND_PASTE, + NULL, (GAsyncReadyCallback) can_edit_cb, paste_button); + + return box; +} + +static GtkWidget * create_zoom_buttons(MqMainMenu *main_menu) { GtkWidget *box; @@ -279,6 +348,8 @@ menu_clicked_cb(MqMainMenu *main_menu) gtk_box_pack_start(GTK_BOX(box), create_zoom_buttons(main_menu), TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), create_edit_buttons(main_menu), + TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(box), create_main_grid(main_menu), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(box), create_application_buttons(main_menu), |