[glade/popover: 8/17] Initial GtkModelButton support



commit b02df0cb5e9a3d9c028bd4e7181799f6098574ea
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 19 12:56:38 2014 +0100

    Initial GtkModelButton support

 plugins/gtk+/Makefile.am                       |    4 +
 plugins/gtk+/glade-gtk-model-button.c          |   40 ++++
 plugins/gtk+/glade-gtk-resources.gresource.xml |    1 +
 plugins/gtk+/glade-model-button-editor.c       |   69 +++++++
 plugins/gtk+/glade-model-button-editor.h       |   57 ++++++
 plugins/gtk+/glade-model-button-editor.ui      |  253 ++++++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in                       |   34 ++++
 7 files changed, 458 insertions(+), 0 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 30dc0af..6139d28 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -88,6 +88,7 @@ libgladegtk_la_SOURCES =              \
        glade-gtk-menu-shell.c          \
        glade-gtk-menu-tool-button.c    \
        glade-gtk-message-dialog.c      \
+       glade-gtk-model-button.c        \
        glade-gtk-notebook.c            \
        glade-gtk-overlay.c             \
        glade-gtk-paned.c               \
@@ -134,6 +135,7 @@ libgladegtk_la_SOURCES =            \
        glade-level-bar-editor.c        \
        glade-message-dialog-editor.c   \
        glade-misc-editor.c             \
+       glade-model-button-editor.c     \
        glade-model-data.c              \
        glade-notebook-editor.c         \
        glade-popover-editor.c          \
@@ -215,6 +217,7 @@ noinst_HEADERS =                    \
        glade-level-bar-editor.h        \
        glade-message-dialog-editor.h   \
        glade-misc-editor.h             \
+       glade-model-button-editor.h     \
        glade-model-data.h              \
        glade-notebook-editor.h         \
        glade-popover-editor.h          \
@@ -295,6 +298,7 @@ UI_FILES =                          \
        glade-level-bar-editor.ui       \
        glade-message-dialog-editor.ui  \
        glade-misc-editor.ui            \
+       glade-model-button-editor.ui    \
        glade-notebook-editor.ui        \
        glade-popover-editor.ui         \
        glade-popover-menu-editor.ui    \
diff --git a/plugins/gtk+/glade-gtk-model-button.c b/plugins/gtk+/glade-gtk-model-button.c
new file mode 100644
index 0000000..c42216a
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-model-button.c
@@ -0,0 +1,40 @@
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+#include "glade-gtk.h"
+
+#include "glade-model-button-editor.h"
+
+void
+glade_gtk_model_button_post_create (GladeWidgetAdaptor *adaptor,
+                                    GObject *container,
+                                    GladeCreateReason reason)
+{
+}
+
+void
+glade_gtk_model_button_read_widget (GladeWidgetAdaptor * adaptor,
+                                    GladeWidget * widget,
+                                    GladeXmlNode * node)
+{
+  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_widget (adaptor, widget, node);
+}
+
+void
+glade_gtk_model_button_write_widget (GladeWidgetAdaptor * adaptor,
+                                     GladeWidget * widget,
+                                     GladeXmlContext * context,
+                                     GladeXmlNode * node)
+{
+  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context, node);
+}
+
+GladeEditable *
+glade_gtk_model_button_create_editable (GladeWidgetAdaptor * adaptor,
+                                        GladeEditorPageType type)
+{
+  if (type == GLADE_PAGE_GENERAL)
+    return (GladeEditable *) glade_model_button_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 da3ffb8..75c53b1 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -29,6 +29,7 @@
     <file compressed="true" preprocess="xml-stripblanks">glade-level-bar-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-message-dialog-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-misc-editor.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">glade-model-button-editor.ui</file>
     <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>
diff --git a/plugins/gtk+/glade-model-button-editor.c b/plugins/gtk+/glade-model-button-editor.c
new file mode 100644
index 0000000..43a428c
--- /dev/null
+++ b/plugins/gtk+/glade-model-button-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-model-button-editor.h"
+
+static void glade_model_button_editor_grab_focus (GtkWidget * widget);
+
+struct _GladeModelButtonEditorPrivate
+{
+  GtkWidget *embed;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GladeModelButtonEditor, glade_model_button_editor, GLADE_TYPE_EDITOR_SKELETON)
+
+static void
+glade_model_button_editor_class_init (GladeModelButtonEditorClass * klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  widget_class->grab_focus = glade_model_button_editor_grab_focus;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/gladegtk/glade-model-button-editor.ui");
+  gtk_widget_class_bind_template_child_private (widget_class, GladeModelButtonEditor, embed);
+}
+
+static void
+glade_model_button_editor_init (GladeModelButtonEditor * self)
+{
+  self->priv = glade_model_button_editor_get_instance_private (self);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+glade_model_button_editor_grab_focus (GtkWidget * widget)
+{
+  GladeModelButtonEditor *editor = GLADE_MODEL_BUTTON_EDITOR (widget);
+
+  gtk_widget_grab_focus (editor->priv->embed);
+}
+
+GtkWidget *
+glade_model_button_editor_new (void)
+{
+  return g_object_new (GLADE_TYPE_MODEL_BUTTON_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-model-button-editor.h b/plugins/gtk+/glade-model-button-editor.h
new file mode 100644
index 0000000..235caa3
--- /dev/null
+++ b/plugins/gtk+/glade-model-button-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_MODEL_BUTTON_EDITOR_H_
+#define _GLADE_MODEL_BUTTON_EDITOR_H_
+
+#include <gtk/gtk.h>
+#include <gladeui/glade.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_MODEL_BUTTON_EDITOR             (glade_model_button_editor_get_type ())
+#define GLADE_MODEL_BUTTON_EDITOR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GLADE_TYPE_MODEL_BUTTON_EDITOR, GladeModelButtonEditor))
+#define GLADE_MODEL_BUTTON_EDITOR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
GLADE_TYPE_MODEL_BUTTON_EDITOR, GladeModelButtonEditorClass))
+#define GLADE_IS_MODEL_BUTTON_EDITOR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GLADE_TYPE_MODEL_BUTTON_EDITOR))
+#define GLADE_IS_MODEL_BUTTON_EDITOR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GLADE_TYPE_MODEL_BUTTON_EDITOR))
+#define GLADE_MODEL_BUTTON_EDITOR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GLADE_TYPE_MODEL_BUTTON_EDITOR, GladeModelButtonEditorClass))
+
+typedef struct _GladeModelButtonEditor        GladeModelButtonEditor;
+typedef struct _GladeModelButtonEditorClass   GladeModelButtonEditorClass;
+typedef struct _GladeModelButtonEditorPrivate GladeModelButtonEditorPrivate;
+
+struct _GladeModelButtonEditor
+{
+  GladeEditorSkeleton  parent;
+
+  GladeModelButtonEditorPrivate *priv;
+};
+
+struct _GladeModelButtonEditorClass
+{
+  GladeEditorSkeletonClass parent;
+};
+
+GType            glade_model_button_editor_get_type       (void) G_GNUC_CONST;
+GtkWidget       *glade_model_button_editor_new            (void);
+
+G_END_DECLS
+
+#endif  /* _GLADE_MODEL_BUTTON_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-model-button-editor.ui b/plugins/gtk+/glade-model-button-editor.ui
new file mode 100644
index 0000000..fc97d72
--- /dev/null
+++ b/plugins/gtk+/glade-model-button-editor.ui
@@ -0,0 +1,253 @@
+<?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="GladeModelButtonEditor" 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="GladeEditorTable" id="embed">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">6</property>
+            <property name="height">1</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">Model Button 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="action_name_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">action-name</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="action_name_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">action-name</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="text_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">text</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="text_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">text</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">3</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="icon_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">icon</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="icon_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">icon</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">4</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="iconic_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">iconic</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">5</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="menu_name_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">menu-name</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">6</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="menu_name_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">menu-name</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">6</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="inverted_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">inverted</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">7</property>
+            <property name="width">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="centered_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">centered</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">8</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="centered_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">centered</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">8</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="embed"/>
+      <editor id="action_name_label"/>
+      <editor id="action_name_editor"/>
+      <editor id="text_label"/>
+      <editor id="text_editor"/>
+      <editor id="icon_label"/>
+      <editor id="icon_editor"/>
+      <editor id="iconic_editor"/>
+      <editor id="menu_name_label"/>
+      <editor id="menu_name_editor"/>
+      <editor id="inverted_editor"/>
+      <editor id="centered_label"/>
+      <editor id="centered_editor"/>
+    </child-editors>
+  </template>
+</interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 0209600..9643d49 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -3406,6 +3406,39 @@
         </properties>
       </glade-widget-class>
 
+      <glade-widget-class name="GtkModelButton" generic-name="modelbutton" _title="Model Button">
+        <post-create-function>glade_gtk_model_button_post_create</post-create-function>
+        <read-widget-function>glade_gtk_model_button_read_widget</read-widget-function>
+        <write-widget-function>glade_gtk_model_button_write_widget</write-widget-function>
+        <create-editable-function>glade_gtk_model_button_create_editable</create-editable-function>
+        <properties>
+          <property id="role" disabled="True"/>
+          <property id="active" disabled="True"/>
+          <property id="action-name" custom-layout="True"/>
+          <property id="text" translatable="True" custom-layout="True"/>
+          <property id="icon" custom-layout="True"/>
+          <property id="iconic" custom-layout="True"/>
+          <property id="menu-name" custom-layout="True"/>
+          <property id="inverted" custom-layout="True"/>
+          <property id="centered" custom-layout="True"/>
+
+          <!-- disable GtkButton properties -->
+          <property id="always-show-image" disabled="True"/>
+          <property id="image" disabled="True"/>
+          <property id="image-position" disabled="True"/>
+          <property id="use-stock" disabled="True"/>
+          <property id="label" disabled="True"/>
+          <property id="use-underline" disabled="True"/>
+          <property id="xalign" disabled="True"/>
+          <property id="yalign" disabled="True"/>
+          <property id="relief" disabled="True"/>
+          <property id="stock" disabled="True"/>
+          <property id="response-id" disabled="True"/>
+          <property id="related-action" disabled="True"/>
+          <property id="use-action-appearance" disabled="True"/>
+        </properties>
+      </glade-widget-class>
+    
       <glade-widget-class name="GtkLinkButton" generic-name="linkbutton" _title="Link Button">
         <properties>
           <!-- The pspec of this prop says that the default is http://www.gtk.org but gtk_link_button_init() 
does
@@ -5456,6 +5489,7 @@
       <glade-widget-class-ref name="GtkInfoBar"/>
       <glade-widget-class-ref name="GtkStackSwitcher" />
       <glade-widget-class-ref name="GtkSidebar" />
+      <glade-widget-class-ref name="GtkModelButton"/>
     </glade-widget-group>
     
     <glade-widget-group name="gtk-composite" _title="Composite Widgets">


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