[gnome-builder] devhelp: implement print



commit 5e3f4d90a5a9d0d09c475026ee56ae90acb5ea2a
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 8 05:39:05 2017 -0700

    devhelp: implement print
    
    Also remove things so we match the mockup.

 plugins/devhelp/gbp-devhelp-view.c |   32 ++++++++++++++++++++++++++++++++
 plugins/devhelp/gtk/menus.ui       |   10 ++--------
 2 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/plugins/devhelp/gbp-devhelp-view.c b/plugins/devhelp/gbp-devhelp-view.c
index 7086440..f11640f 100644
--- a/plugins/devhelp/gbp-devhelp-view.c
+++ b/plugins/devhelp/gbp-devhelp-view.c
@@ -98,6 +98,23 @@ gbp_devhelp_view_create_split_view (IdeLayoutView *view)
 }
 
 static void
+gbp_devhelp_view_actions_print (GSimpleAction *action,
+                                GVariant      *param,
+                                gpointer       user_data)
+{
+  GbpDevhelpView *self = user_data;
+  WebKitPrintOperation *operation;
+  GtkWidget *window;
+
+  g_assert (GBP_IS_DEVHELP_VIEW (self));
+
+  operation = webkit_print_operation_new (self->web_view1);
+  window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
+  webkit_print_operation_run_dialog (operation, GTK_WINDOW (window));
+  g_object_unref (operation);
+}
+
+static void
 gbp_devhelp_view_set_property (GObject      *object,
                                guint         prop_id,
                                const GValue *value,
@@ -175,9 +192,15 @@ gbp_devhelp_view_class_init (GbpDevhelpViewClass *klass)
   g_type_ensure (WEBKIT_TYPE_WEB_VIEW);
 }
 
+static const GActionEntry actions[] = {
+  { "print", gbp_devhelp_view_actions_print },
+};
+
 static void
 gbp_devhelp_view_init (GbpDevhelpView *self)
 {
+  g_autoptr(GSimpleActionGroup) group = NULL;
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
   ide_layout_view_set_can_split (IDE_LAYOUT_VIEW (self), TRUE);
@@ -206,4 +229,13 @@ gbp_devhelp_view_init (GbpDevhelpView *self)
                            G_CALLBACK (gbp_devhelp_focus_in_event),
                            self,
                            G_CONNECT_SWAPPED);
+
+  group = g_simple_action_group_new ();
+  g_action_map_add_action_entries (G_ACTION_MAP (group),
+                                   actions,
+                                   G_N_ELEMENTS (actions),
+                                   self);
+  gtk_widget_insert_action_group (GTK_WIDGET (self),
+                                  "devhelp-view",
+                                  G_ACTION_GROUP (group));
 }
diff --git a/plugins/devhelp/gtk/menus.ui b/plugins/devhelp/gtk/menus.ui
index 8d9065b..85179ae 100644
--- a/plugins/devhelp/gtk/menus.ui
+++ b/plugins/devhelp/gtk/menus.ui
@@ -4,16 +4,10 @@
     <section id="devhelp-document-section">
       <attribute name="label" translatable="yes">Documentation</attribute>
       <item>
-        <attribute name="label" translatable="yes">Open in New Frame</attribute>
-        <attribute name="action">layoutstack.open-in-new-frame</attribute>
+        <attribute name="label" translatable="yes">Print…</attribute>
+        <attribute name="action">devhelp-view.print</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">Split</attribute>
-        <attribute name="action">layoutstack.split-view</attribute>
-      </item>
-    </section>
-    <section id="devhelp-close-section">
-      <item>
         <attribute name="label" translatable="yes">Close</attribute>
         <attribute name="action">layoutstack.close-view</attribute>
       </item>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]