[glade/popover: 6/17] Add an editor for GtkPopoverMenu



commit fc3922fd27d4400eb5566ba6c97340bcecbb9d52
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 19 08:09:35 2014 +0100

    Add an editor for GtkPopoverMenu

 plugins/gtk+/Makefile.am                       |    3 +
 plugins/gtk+/glade-gtk-popover-menu.c          |   12 ++
 plugins/gtk+/glade-gtk-resources.gresource.xml |    1 +
 plugins/gtk+/glade-popover-menu-editor.c       |   69 ++++++++++++
 plugins/gtk+/glade-popover-menu-editor.h       |   57 ++++++++++
 plugins/gtk+/glade-popover-menu-editor.ui      |  136 ++++++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in                       |    5 +-
 7 files changed, 281 insertions(+), 2 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 82b9a3f..30dc0af 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -137,6 +137,7 @@ libgladegtk_la_SOURCES =            \
        glade-model-data.c              \
        glade-notebook-editor.c         \
        glade-popover-editor.c          \
+       glade-popover-menu-editor.c     \
        glade-progress-bar-editor.c     \
        glade-real-tree-view-editor.c   \
        glade-recent-action-editor.c    \
@@ -217,6 +218,7 @@ noinst_HEADERS =                    \
        glade-model-data.h              \
        glade-notebook-editor.h         \
        glade-popover-editor.h          \
+       glade-popover-menu-editor.h     \
        glade-progress-bar-editor.h     \
        glade-real-tree-view-editor.h   \
        glade-recent-action-editor.h    \
@@ -295,6 +297,7 @@ UI_FILES =                          \
        glade-misc-editor.ui            \
        glade-notebook-editor.ui        \
        glade-popover-editor.ui         \
+       glade-popover-menu-editor.ui    \
        glade-progress-bar-editor.ui    \
        glade-real-tree-view-editor.ui  \
        glade-recent-action-editor.ui   \
diff --git a/plugins/gtk+/glade-gtk-popover-menu.c b/plugins/gtk+/glade-gtk-popover-menu.c
index dad55f4..d044b9a 100644
--- a/plugins/gtk+/glade-gtk-popover-menu.c
+++ b/plugins/gtk+/glade-gtk-popover-menu.c
@@ -25,6 +25,8 @@
 #include <glib/gi18n-lib.h>
 #include <gladeui/glade.h>
 
+#include "glade-popover-menu-editor.h"
+
 GObject *
 glade_gtk_popover_menu_constructor (GType type,
                                     guint n_construct_properties,
@@ -534,3 +536,13 @@ glade_gtk_popover_menu_get_child_property (GladeWidgetAdaptor * adaptor,
                                     GTK_WIDGET (child), id, value);
 }
 
+GladeEditable *
+glade_gtk_popover_menu_create_editable (GladeWidgetAdaptor * adaptor,
+                                        GladeEditorPageType  type)
+{
+  if (type == GLADE_PAGE_GENERAL)
+    return (GladeEditable *) glade_popover_menu_editor_new ();
+  else
+    return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+}
+
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index f3a9ec6..da3ffb8 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -32,6 +32,7 @@
     <file compressed="true" preprocess="xml-stripblanks">glade-progress-bar-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-notebook-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-popover-editor.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">glade-popover-menu-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-real-tree-view-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-recent-action-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-recent-chooser-dialog-editor.ui</file>
diff --git a/plugins/gtk+/glade-popover-menu-editor.c b/plugins/gtk+/glade-popover-menu-editor.c
new file mode 100644
index 0000000..eb38d26
--- /dev/null
+++ b/plugins/gtk+/glade-popover-menu-editor.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Authors:
+ *   Matthias Clasen <mclasen redhat com>
+ */
+
+#include <config.h>
+#include <gladeui/glade.h>
+#include <glib/gi18n-lib.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "glade-popover-menu-editor.h"
+
+static void glade_popover_menu_editor_grab_focus (GtkWidget * widget);
+
+struct _GladePopoverMenuEditorPrivate
+{
+  GtkWidget *embed;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GladePopoverMenuEditor, glade_popover_menu_editor, GLADE_TYPE_EDITOR_SKELETON)
+
+static void
+glade_popover_menu_editor_class_init (GladePopoverMenuEditorClass * klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  widget_class->grab_focus = glade_popover_menu_editor_grab_focus;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/gladegtk/glade-popover-menu-editor.ui");
+  gtk_widget_class_bind_template_child_private (widget_class, GladePopoverMenuEditor, embed);
+}
+
+static void
+glade_popover_menu_editor_init (GladePopoverMenuEditor * self)
+{
+  self->priv = glade_popover_menu_editor_get_instance_private (self);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+glade_popover_menu_editor_grab_focus (GtkWidget * widget)
+{
+  GladePopoverMenuEditor *editor = GLADE_POPOVER_MENU_EDITOR (widget);
+
+  gtk_widget_grab_focus (editor->priv->embed);
+}
+
+GtkWidget *
+glade_popover_menu_editor_new (void)
+{
+  return g_object_new (GLADE_TYPE_POPOVER_MENU_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-popover-menu-editor.h b/plugins/gtk+/glade-popover-menu-editor.h
new file mode 100644
index 0000000..61b76d5
--- /dev/null
+++ b/plugins/gtk+/glade-popover-menu-editor.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Authors:
+ *   Matthias Clasen <mclasen redhat com>
+ */
+#ifndef _GLADE_POPOVER_MENU_EDITOR_H_
+#define _GLADE_POPOVER_MENU_EDITOR_H_
+
+#include <gtk/gtk.h>
+#include <gladeui/glade.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_POPOVER_MENU_EDITOR             (glade_popover_menu_editor_get_type ())
+#define GLADE_POPOVER_MENU_EDITOR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GLADE_TYPE_POPOVER_MENU_EDITOR, GladePopoverMenuEditor))
+#define GLADE_POPOVER_MENU_EDITOR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
GLADE_TYPE_POPOVER_MENU_EDITOR, GladePopoverMenuEditorClass))
+#define GLADE_IS_POPOVER_MENU_EDITOR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GLADE_TYPE_POPOVER_MENU_EDITOR))
+#define GLADE_IS_POPOVER_MENU_EDITOR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GLADE_TYPE_POPOVER_MENU_EDITOR))
+#define GLADE_POPOVER_MENU_EDITOR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GLADE_TYPE_POPOVER_MENU_EDITOR, GladePopoverMenuEditorClass))
+
+typedef struct _GladePopoverMenuEditor        GladePopoverMenuEditor;
+typedef struct _GladePopoverMenuEditorClass   GladePopoverMenuEditorClass;
+typedef struct _GladePopoverMenuEditorPrivate GladePopoverMenuEditorPrivate;
+
+struct _GladePopoverMenuEditor
+{
+  GladeEditorSkeleton  parent;
+
+  GladePopoverMenuEditorPrivate *priv;
+};
+
+struct _GladePopoverMenuEditorClass
+{
+  GladeEditorSkeletonClass parent;
+};
+
+GType            glade_popover_menu_editor_get_type       (void) G_GNUC_CONST;
+GtkWidget       *glade_popover_menu_editor_new            (void);
+
+G_END_DECLS
+
+#endif  /* _GLADE_POPOVER_MENU_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-popover-menu-editor.ui b/plugins/gtk+/glade-popover-menu-editor.ui
new file mode 100644
index 0000000..bd9fdad
--- /dev/null
+++ b/plugins/gtk+/glade-popover-menu-editor.ui
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.0 
+
+libgladegtk - Glade UI Designer Gtk+ support plugin
+Copyright (C) 2014 Red Hat, Inc.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Author: Matthias Clasen <mclasen redhat com>
+
+-->
+<interface domain="glade">
+  <requires lib="gtk+" version="3.10"/>
+  <requires lib="gladeui" version="0.0"/>
+  <template class="GladePopoverMenuEditor" parent="GladeEditorSkeleton">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkGrid" id="grid">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="row_spacing">6</property>
+        <property name="column_spacing">6</property>
+        <child>
+          <object class="GladePopoverEditor" id="popover_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">6</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="title">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">center</property>
+            <property name="label" translatable="yes">Menu Attributes</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">6</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="submenus_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">submenus</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="submenus_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">submenus</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">2</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="current_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">current</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="current_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">current</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">3</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child-editors>
+      <editor id="popover_editor"/>
+      <editor id="submenus_label"/>
+      <editor id="submenus_editor"/>
+      <editor id="current_label"/>
+      <editor id="current_editor"/>
+    </child-editors>
+  </template>
+</interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 63eb421..0209600 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -3376,6 +3376,7 @@
 
       <glade-widget-class name="GtkPopoverMenu" generic-name="popovermenu" _title="Popover Menu">
         <constructor-function>glade_gtk_popover_menu_constructor</constructor-function>
+        <create-editable-function>glade_gtk_popover_menu_create_editable</create-editable-function>
         <post-create-function>glade_gtk_popover_menu_post_create</post-create-function>
         <add-child-function>glade_gtk_popover_menu_add_child</add-child-function>
         <remove-child-function>glade_gtk_popover_menu_remove_child</remove-child-function>
@@ -3388,14 +3389,14 @@
 
         <properties>
           <property id="visible-submenu" disabled="True"/>
-          <property id="submenus" _name="Number of submenus" save="False" default="1"> <!-- 
custom-layout="True" -->
+          <property id="submenus" _name="Number of submenus" save="False" default="1" custom-layout="True">
             <parameter-spec>
               <type>GParamInt</type>
               <min>1</min>
             </parameter-spec>
             <_tooltip>The number of submenus in the popover menu</_tooltip>
           </property>
-          <property id="current" _name="Edit menu" save="False" default="0"> <!-- custom-layout="True" -->
+          <property id="current" _name="Edit menu" save="False" default="0" custom-layout="True">
             <parameter-spec>
               <type>GParamInt</type>
               <min>0</min>


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