[glade] Added GladeNotebookEditor



commit 021a0176cd5717d1eb124ad58a72944bf9182b0e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat May 11 19:03:06 2013 +0900

    Added GladeNotebookEditor

 plugins/gtk+/Makefile.am                       |    3 +
 plugins/gtk+/glade-gtk-notebook.c              |   12 +
 plugins/gtk+/glade-gtk-resources.gresource.xml |    1 +
 plugins/gtk+/glade-notebook-editor.c           |  108 +++++++++
 plugins/gtk+/glade-notebook-editor.h           |   56 +++++
 plugins/gtk+/glade-notebook-editor.ui          |  292 ++++++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in                       |   16 +-
 po/POTFILES.in                                 |    2 +
 8 files changed, 484 insertions(+), 6 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 11893d4..e5c811e 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -107,6 +107,7 @@ libgladegtk_la_SOURCES =            \
        glade-label-editor.c            \
        glade-message-dialog-editor.c   \
        glade-model-data.c              \
+       glade-notebook-editor.c         \
        glade-recent-action-editor.c \
        glade-recent-chooser-dialog-editor.c \
        glade-recent-chooser-editor.c   \
@@ -163,6 +164,7 @@ noinst_HEADERS =                    \
        glade-label-editor.h            \
        glade-message-dialog-editor.h   \
        glade-model-data.h              \
+       glade-notebook-editor.h         \
        glade-recent-action-editor.h \
        glade-recent-chooser-dialog-editor.h \
        glade-recent-chooser-editor.h   \
@@ -217,6 +219,7 @@ UI_FILES =                          \
        glade-image-editor.ui           \
        glade-label-editor.ui           \
        glade-message-dialog-editor.ui  \
+       glade-notebook-editor.ui        \
        glade-recent-action-editor.ui \
        glade-recent-chooser-dialog-editor.ui \
        glade-recent-chooser-editor.ui  \
diff --git a/plugins/gtk+/glade-gtk-notebook.c b/plugins/gtk+/glade-gtk-notebook.c
index e069d9d..8f5efc3 100644
--- a/plugins/gtk+/glade-gtk-notebook.c
+++ b/plugins/gtk+/glade-gtk-notebook.c
@@ -25,6 +25,7 @@
 #include <gladeui/glade.h>
 
 #include "glade-gtk-notebook.h"
+#include "glade-notebook-editor.h"
 
 typedef struct
 {
@@ -40,6 +41,17 @@ typedef struct
 
 static gboolean glade_gtk_notebook_setting_position = FALSE;
 
+
+GladeEditable *
+glade_gtk_notebook_create_editable (GladeWidgetAdaptor * adaptor,
+                                   GladeEditorPageType type)
+{
+  if (type == GLADE_PAGE_GENERAL)
+    return (GladeEditable *) glade_notebook_editor_new ();
+
+  return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+}
+
 static gint
 notebook_child_compare_func (GtkWidget * widget_a, GtkWidget * widget_b)
 {
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index cf87de7..fb0b527 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -19,6 +19,7 @@
     <file compressed="true" preprocess="xml-stripblanks">glade-image-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-label-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-message-dialog-editor.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">glade-notebook-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>
     <file compressed="true" preprocess="xml-stripblanks">glade-recent-chooser-editor.ui</file>
diff --git a/plugins/gtk+/glade-notebook-editor.c b/plugins/gtk+/glade-notebook-editor.c
new file mode 100644
index 0000000..516bec7
--- /dev/null
+++ b/plugins/gtk+/glade-notebook-editor.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2013 Tristan Van Berkom.
+ *
+ * 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:
+ *   Tristan Van Berkom <tvb gnome org>
+ */
+
+#include <config.h>
+#include <gladeui/glade.h>
+#include <glib/gi18n-lib.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "glade-notebook-editor.h"
+
+static void glade_notebook_editor_editable_init (GladeEditableIface * iface);
+static void glade_notebook_editor_grab_focus (GtkWidget * widget);
+
+struct _GladeNotebookEditorPrivate
+{
+  GtkWidget *embed;
+  GtkWidget *tabs_grid;
+};
+
+static GladeEditableIface *parent_editable_iface;
+
+G_DEFINE_TYPE_WITH_CODE (GladeNotebookEditor, glade_notebook_editor, GLADE_TYPE_EDITOR_SKELETON,
+                         G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
+                                                glade_notebook_editor_editable_init));
+
+static void
+glade_notebook_editor_class_init (GladeNotebookEditorClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  widget_class->grab_focus = glade_notebook_editor_grab_focus;
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-notebook-editor.ui");
+  gtk_widget_class_bind_child (widget_class, GladeNotebookEditorPrivate, embed);
+  gtk_widget_class_bind_child (widget_class, GladeNotebookEditorPrivate, tabs_grid);
+
+  g_type_class_add_private (object_class, sizeof (GladeNotebookEditorPrivate));  
+}
+
+static void
+glade_notebook_editor_init (GladeNotebookEditor * self)
+{
+  self->priv = 
+    G_TYPE_INSTANCE_GET_PRIVATE (self,
+                                GLADE_TYPE_NOTEBOOK_EDITOR,
+                                GladeNotebookEditorPrivate);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+glade_notebook_editor_load (GladeEditable * editable, GladeWidget * widget)
+{
+  GladeNotebookEditor *notebook_editor = GLADE_NOTEBOOK_EDITOR (editable);
+  GladeNotebookEditorPrivate *priv = notebook_editor->priv;
+  gboolean show_tabs = FALSE;
+
+  /* Chain up to default implementation */
+  parent_editable_iface->load (editable, widget);
+
+  if (widget)
+    {
+      glade_widget_property_get (widget, "show-tabs", &show_tabs);
+
+      gtk_widget_set_visible (priv->tabs_grid, show_tabs);
+    }
+}
+
+static void
+glade_notebook_editor_editable_init (GladeEditableIface * iface)
+{
+  parent_editable_iface = g_type_interface_peek_parent (iface);
+
+  iface->load = glade_notebook_editor_load;
+}
+
+static void
+glade_notebook_editor_grab_focus (GtkWidget * widget)
+{
+  GladeNotebookEditor *notebook_editor = GLADE_NOTEBOOK_EDITOR (widget);
+
+  gtk_widget_grab_focus (notebook_editor->priv->embed);
+}
+
+GtkWidget *
+glade_notebook_editor_new (void)
+{
+  return g_object_new (GLADE_TYPE_NOTEBOOK_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-notebook-editor.h b/plugins/gtk+/glade-notebook-editor.h
new file mode 100644
index 0000000..a3a29d9
--- /dev/null
+++ b/plugins/gtk+/glade-notebook-editor.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Tristan Van Berkom.
+ *
+ * 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:
+ *   Tristan Van Berkom <tvb gnome org>
+ */
+#ifndef _GLADE_NOTEBOOK_EDITOR_H_
+#define _GLADE_NOTEBOOK_EDITOR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_NOTEBOOK_EDITOR                 (glade_notebook_editor_get_type ())
+#define GLADE_NOTEBOOK_EDITOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GLADE_TYPE_NOTEBOOK_EDITOR, GladeNotebookEditor))
+#define GLADE_NOTEBOOK_EDITOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), 
GLADE_TYPE_NOTEBOOK_EDITOR, GladeNotebookEditorClass))
+#define GLADE_IS_NOTEBOOK_EDITOR(obj)      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_NOTEBOOK_EDITOR))
+#define GLADE_IS_NOTEBOOK_EDITOR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GLADE_TYPE_NOTEBOOK_EDITOR))
+#define GLADE_NOTEBOOK_EDITOR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GLADE_TYPE_NOTEBOOK_EDITOR, GladeNotebookEditorClass))
+
+typedef struct _GladeNotebookEditor        GladeNotebookEditor;
+typedef struct _GladeNotebookEditorClass   GladeNotebookEditorClass;
+typedef struct _GladeNotebookEditorPrivate GladeNotebookEditorPrivate;
+
+struct _GladeNotebookEditor
+{
+  GladeEditorSkeleton  parent;
+
+  GladeNotebookEditorPrivate *priv;
+};
+
+struct _GladeNotebookEditorClass
+{
+  GladeEditorSkeletonClass parent;
+};
+
+GType            glade_notebook_editor_get_type (void) G_GNUC_CONST;
+GtkWidget       *glade_notebook_editor_new      (void);
+
+G_END_DECLS
+
+#endif  /* _GLADE_NOTEBOOK_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-notebook-editor.ui b/plugins/gtk+/glade-notebook-editor.ui
new file mode 100644
index 0000000..3861130
--- /dev/null
+++ b/plugins/gtk+/glade-notebook-editor.ui
@@ -0,0 +1,292 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="glade">
+  <!-- interface-requires gladeui 0.0 -->
+  <!-- interface-requires gtk+ 3.10 -->
+  <template class="GladeNotebookEditor" 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">Notebook 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="page_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">page</property>
+            <property name="custom_text" translatable="yes">Edit page:</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="page_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">page</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">2</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="show_border_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">False</property>
+            <property name="property_name">show-border</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">3</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="show_tabs_editor">
+            <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">show-tabs</property>
+            <property name="editor_type">GladeEpropCheck</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="tabs_grid">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="hexpand">False</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="tabs_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">Tab Attributes</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </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="GladePropertyLabel" id="tab_pos_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">tab-pos</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GladePropertyShell" id="tab_pos_editor">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">False</property>
+                <property name="property_name">tab-pos</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GladePropertyLabel" id="group_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">group-name</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GladePropertyShell" id="group_name_editor">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">False</property>
+                <property name="property_name">group-name</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GladePropertyShell" id="scrollable_editor">
+                <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">scrollable</property>
+                <property name="editor_type">GladeEpropCheck</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">3</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GladePropertyShell" id="enable_popup_editor">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">False</property>
+                <property name="property_name">enable-popup</property>
+                <property name="editor_type">GladeEpropCheck</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+            <property name="width">6</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </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="page_label"/>
+      <editor id="page_editor"/>
+      <editor id="show_border_editor"/>
+      <editor id="show_tabs_editor"/>
+      <editor id="tab_pos_label"/>
+      <editor id="tab_pos_editor"/>
+      <editor id="group_name_label"/>
+      <editor id="group_name_editor"/>
+      <editor id="scrollable_editor"/>
+      <editor id="enable_popup_editor"/>
+    </child-editors>
+  </template>
+</interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 9dea75d..4d90789 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1810,6 +1810,7 @@ embedded in another object</_tooltip>
     </glade-widget-class>
   
     <glade-widget-class name="GtkNotebook" generic-name="notebook" _title="Notebook">
+      <create-editable-function>glade_gtk_notebook_create_editable</create-editable-function>
       <post-create-function>glade_gtk_notebook_post_create</post-create-function>
       <add-child-function>glade_gtk_notebook_add_child</add-child-function>
       <remove-child-function>glade_gtk_notebook_remove_child</remove-child-function>
@@ -1836,14 +1837,17 @@ embedded in another object</_tooltip>
       </packing-actions>
 
       <properties>
-       <property id="group" since="2.12"/>
-       <property id="group-name" since="2.24"/>
-       <property id="initial-gap" since="3.2"/>
-       <property id="page" save="False">
-         <_tooltip>Set the current page (strictly for editing purposes)</_tooltip>
+       <property id="group-name" since="2.24" custom-layout="True"/>
+       <property id="page" save="False" custom-layout="True">
+         <_tooltip>Set the currently active page to edit, this property will not be saved</_tooltip>
        </property>
+       <property id="show-tabs" custom-layout="True"/>
+       <property id="show-border" custom-layout="True"/>
+       <property id="tab-pos" custom-layout="True"/>
+       <property id="enable-popup" custom-layout="True"/>
+       <property id="scrollable" custom-layout="True"/>
 
-       <property id="pages" _name="Number of pages" visible="False" save="False" default="3">
+       <property id="pages" _name="Number of pages" visible="False" save="False" default="3" 
custom-layout="True">
          <parameter-spec>
            <type>GParamInt</type>
            <min>1</min>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 01ed76e..56606e1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -136,6 +136,7 @@ plugins/gtk+/glade-image-item-editor.c
 plugins/gtk+/glade-label-editor.c
 plugins/gtk+/glade-message-dialog-editor.c
 plugins/gtk+/glade-model-data.c
+plugins/gtk+/glade-notebook-editor.c
 plugins/gtk+/glade-recent-action-editor.c
 plugins/gtk+/glade-recent-chooser-dialog-editor.c
 plugins/gtk+/glade-recent-chooser-editor.c
@@ -168,6 +169,7 @@ plugins/gtk+/gtk+.xml.in
 [type: gettext/glade]plugins/gtk+/glade-image-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-label-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-message-dialog-editor.ui
+[type: gettext/glade]plugins/gtk+/glade-notebook-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-recent-action-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-recent-chooser-dialog-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-recent-chooser-editor.ui


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