[glade] Move GladeWidgetAdaptor code for GtkMenuBar into it's own C file
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Move GladeWidgetAdaptor code for GtkMenuBar into it's own C file
- Date: Sat, 4 May 2013 07:24:47 +0000 (UTC)
commit 3f55af70725a6365302a3f89ac3f440f24d687ee
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat May 4 14:43:14 2013 +0900
Move GladeWidgetAdaptor code for GtkMenuBar into it's own C file
plugins/gtk+/Makefile.am | 1 +
plugins/gtk+/glade-gtk-menu-bar.c | 140 +++++++++++++++++++++++++++++++++++++
plugins/gtk+/glade-gtk.c | 114 ------------------------------
po/POTFILES.in | 2 +
4 files changed, 143 insertions(+), 114 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 76acff7..a637d49 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -49,6 +49,7 @@ libgladegtk_la_SOURCES = \
glade-gtk-image-menu-item.c \
glade-gtk-info-bar.c \
glade-gtk-menu.c \
+ glade-gtk-menu-bar.c \
glade-gtk-menu-item.c \
glade-gtk-menu-shell.c \
glade-gtk-message-dialog.c \
diff --git a/plugins/gtk+/glade-gtk-menu-bar.c b/plugins/gtk+/glade-gtk-menu-bar.c
new file mode 100644
index 0000000..11be0b4
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-menu-bar.c
@@ -0,0 +1,140 @@
+/*
+ * glade-gtk-menu-bar.c - GladeWidgetAdaptor for GtkMenuBar
+ *
+ * Copyright (C) 2013 Tristan Van Berkom
+ *
+ * Authors:
+ * Tristan Van Berkom <tristan van berkom gmail com>
+ *
+ * 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.
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+static GladeWidget *
+glade_gtk_menu_bar_append_new_submenu (GladeWidget * parent,
+ GladeProject * project)
+{
+ static GladeWidgetAdaptor *submenu_adaptor = NULL;
+ GladeWidget *gsubmenu;
+
+ if (submenu_adaptor == NULL)
+ submenu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
+
+ gsubmenu = glade_widget_adaptor_create_widget (submenu_adaptor, FALSE,
+ "parent", parent,
+ "project", project, NULL);
+
+ glade_widget_add_child (parent, gsubmenu, FALSE);
+
+ return gsubmenu;
+}
+
+static GladeWidget *
+glade_gtk_menu_bar_append_new_item (GladeWidget * parent,
+ GladeProject * project,
+ const gchar * label, gboolean use_stock)
+{
+ static GladeWidgetAdaptor *item_adaptor =
+ NULL, *image_item_adaptor, *separator_adaptor;
+ GladeWidget *gitem;
+
+ if (item_adaptor == NULL)
+ {
+ item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM);
+ image_item_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM);
+ separator_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM);
+ }
+
+ if (label)
+ {
+ gitem =
+ glade_widget_adaptor_create_widget ((use_stock) ? image_item_adaptor :
+ item_adaptor, FALSE, "parent",
+ parent, "project", project, NULL);
+
+ glade_widget_property_set (gitem, "use-underline", TRUE);
+
+ if (use_stock)
+ {
+ glade_widget_property_set (gitem, "use-stock", TRUE);
+ glade_widget_property_set (gitem, "stock", label);
+ }
+ else
+ glade_widget_property_set (gitem, "label", label);
+ }
+ else
+ {
+ gitem = glade_widget_adaptor_create_widget (separator_adaptor,
+ FALSE, "parent", parent,
+ "project", project, NULL);
+ }
+
+ glade_widget_add_child (parent, gitem, FALSE);
+
+ return gitem;
+}
+
+void
+glade_gtk_menu_bar_post_create (GladeWidgetAdaptor *adaptor,
+ GObject *object,
+ GladeCreateReason reason)
+{
+ GladeProject *project;
+ GladeWidget *gmenubar, *gitem, *gsubmenu;
+
+ g_return_if_fail (GTK_IS_MENU_BAR (object));
+ gmenubar = glade_widget_get_from_gobject (object);
+ g_return_if_fail (GLADE_IS_WIDGET (gmenubar));
+
+ if (reason != GLADE_CREATE_USER)
+ return;
+
+ project = glade_widget_get_project (gmenubar);
+
+ /* File */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_File"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-new", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-open", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save-as", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, NULL, FALSE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-quit", TRUE);
+
+ /* Edit */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Edit"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-cut", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-copy", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-paste", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-delete", TRUE);
+
+ /* View */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_View"), FALSE);
+
+ /* Help */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Help"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-about", TRUE);
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index d717b85..c04f952 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -82,120 +82,6 @@ glade_gtk_init (const gchar * name)
}
-/* ----------------------------- GtkMenuBar ------------------------------ */
-static GladeWidget *
-glade_gtk_menu_bar_append_new_submenu (GladeWidget * parent,
- GladeProject * project)
-{
- static GladeWidgetAdaptor *submenu_adaptor = NULL;
- GladeWidget *gsubmenu;
-
- if (submenu_adaptor == NULL)
- submenu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
-
- gsubmenu = glade_widget_adaptor_create_widget (submenu_adaptor, FALSE,
- "parent", parent,
- "project", project, NULL);
-
- glade_widget_add_child (parent, gsubmenu, FALSE);
-
- return gsubmenu;
-}
-
-static GladeWidget *
-glade_gtk_menu_bar_append_new_item (GladeWidget * parent,
- GladeProject * project,
- const gchar * label, gboolean use_stock)
-{
- static GladeWidgetAdaptor *item_adaptor =
- NULL, *image_item_adaptor, *separator_adaptor;
- GladeWidget *gitem;
-
- if (item_adaptor == NULL)
- {
- item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM);
- image_item_adaptor =
- glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM);
- separator_adaptor =
- glade_widget_adaptor_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM);
- }
-
- if (label)
- {
- gitem =
- glade_widget_adaptor_create_widget ((use_stock) ? image_item_adaptor :
- item_adaptor, FALSE, "parent",
- parent, "project", project, NULL);
-
- glade_widget_property_set (gitem, "use-underline", TRUE);
-
- if (use_stock)
- {
- glade_widget_property_set (gitem, "use-stock", TRUE);
- glade_widget_property_set (gitem, "stock", label);
- }
- else
- glade_widget_property_set (gitem, "label", label);
- }
- else
- {
- gitem = glade_widget_adaptor_create_widget (separator_adaptor,
- FALSE, "parent", parent,
- "project", project, NULL);
- }
-
- glade_widget_add_child (parent, gitem, FALSE);
-
- return gitem;
-}
-
-void
-glade_gtk_menu_bar_post_create (GladeWidgetAdaptor * adaptor,
- GObject * object, GladeCreateReason reason)
-{
- GladeProject *project;
- GladeWidget *gmenubar, *gitem, *gsubmenu;
-
- g_return_if_fail (GTK_IS_MENU_BAR (object));
- gmenubar = glade_widget_get_from_gobject (object);
- g_return_if_fail (GLADE_IS_WIDGET (gmenubar));
-
- if (reason != GLADE_CREATE_USER)
- return;
-
- project = glade_widget_get_project (gmenubar);
-
- /* File */
- gitem =
- glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_File"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-new", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-open", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save-as", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, NULL, FALSE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-quit", TRUE);
-
- /* Edit */
- gitem =
- glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Edit"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-cut", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-copy", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-paste", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-delete", TRUE);
-
- /* View */
- gitem =
- glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_View"), FALSE);
-
- /* Help */
- gitem =
- glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Help"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-about", TRUE);
-}
-
/* ----------------------------- GtkToolBar ------------------------------ */
/* need to unset/reset toolbar-style/icon-size when property is disabled/enabled */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9f4b9a6..ad140be 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -75,7 +75,9 @@ plugins/gtk+/glade-gtk-frame.c
plugins/gtk+/glade-gtk-grid.c
plugins/gtk+/glade-gtk-image.c
plugins/gtk+/glade-gtk-image-menu-item.c
+plugins/gtk+/glade-gtk-info-bar.c
plugins/gtk+/glade-gtk-menu.c
+plugins/gtk+/glade-gtk-menu-bar.c
plugins/gtk+/glade-gtk-menu-item.c
plugins/gtk+/glade-gtk-menu-shell.c
plugins/gtk+/glade-gtk-message-dialog.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]