[Xfce4-commits] [xfce/garcon] 01/06: Port Garcon to Gtk3
noreply at xfce.org
noreply at xfce.org
Sun Apr 5 14:23:38 CEST 2015
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository xfce/garcon.
commit 4f746d15a648984bfe7fffe81a988a4c834b59d8
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Thu Mar 26 14:18:27 2015 +0300
Port Garcon to Gtk3
This adds Gtk3 support. Currently, both Gtk2 and Gtk3 are built
at the same time until the consumers of Garcon have all been
ported over. It uses the same codebase for both to assist with
troubleshooting issues. Note, this means the GtkImageMenuItems
are now an image + label packed into a box, so the padding
increased slightly.
---
.gitignore | 21 ++++++++++++
configure.ac.in | 4 +++
garcon-gtk/Makefile.am | 47 +++++++++++++++++++++++--
garcon-gtk/garcon-gtk-menu.c | 74 +++++++++++++++++++++++++++++-----------
garcon-gtk/garcon-gtk3-1.pc.in | 13 +++++++
garcon/Makefile.am | 37 ++++++++++++++++++--
garcon/garcon-2.pc.in | 13 +++++++
7 files changed, 185 insertions(+), 24 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7d2e52b..5a365c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,24 @@ depcomp
garcon-1.pc
garcon-config.h
POTFILES
+data/xfce/xfce-accessories.directory
+data/xfce/xfce-development.directory
+data/xfce/xfce-education.directory
+data/xfce/xfce-games.directory
+data/xfce/xfce-graphics.directory
+data/xfce/xfce-hardware.directory
+data/xfce/xfce-multimedia.directory
+data/xfce/xfce-network.directory
+data/xfce/xfce-office.directory
+data/xfce/xfce-other.directory
+data/xfce/xfce-personal.directory
+data/xfce/xfce-screensavers.directory
+data/xfce/xfce-settings.directory
+data/xfce/xfce-system.directory
+garcon-gtk/garcon-gtk2-1.pc
+garcon-gtk/garcon-gtk3-1.pc
+garcon/garcon-2.pc
+garcon/garcon-marshal.c
+garcon/garcon-marshal.h
+gtk-doc.m4
+tests/test-display-menu
diff --git a/configure.ac.in b/configure.ac.in
index e8cf2f6..ef8ecbc 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -125,6 +125,8 @@ XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GTK2], [gtk+-2.0], [2.24.0])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.10.0])
+XDT_CHECK_PACKAGE([GTK3], [gtk+-3.0], [3.14.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI2], [libxfce4ui-2], [4.11.1])
dnl *************************
dnl *** Check for gtk-doc ***
@@ -150,9 +152,11 @@ docs/reference/Makefile
docs/reference/version.xml
garcon/Makefile
garcon/garcon-1.pc
+garcon/garcon-2.pc
garcon/garcon-config.h
garcon-gtk/Makefile
garcon-gtk/garcon-gtk2-1.pc
+garcon-gtk/garcon-gtk3-1.pc
po/Makefile.in
tests/Makefile
])
diff --git a/garcon-gtk/Makefile.am b/garcon-gtk/Makefile.am
index 43fa9d2..1f5d9b6 100644
--- a/garcon-gtk/Makefile.am
+++ b/garcon-gtk/Makefile.am
@@ -26,7 +26,8 @@ AM_CPPFLAGS = \
$(PLATFORM_CFLAGS)
lib_LTLIBRARIES = \
- libgarcon-gtk2-1.la
+ libgarcon-gtk2-1.la \
+ libgarcon-gtk3-1.la
libgarcon_gtk_headers = \
garcon-gtk.h \
@@ -75,8 +76,50 @@ libgarcon_gtk2_1_la_LIBADD = \
libgarcon_gtk2_DEPENDENCIES = \
$(top_builddir)/garcon/libgarcon-$(GARCON_VERSION_API).la
+
+libgarcon_gtk3includedir = \
+ $(includedir)/garcon-gtk2-1/garcon-gtk
+
+libgarcon_gtk3include_HEADERS = \
+ $(libgarcon_gtk_headers)
+
+libgarcon_gtk3_1_la_SOURCES = \
+ $(libgarcon_gtk_sources) \
+ $(libgarcon_gtk_headers)
+
+libgarcon_gtk3_1_la_CFLAGS = \
+ $(GIO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GTK3_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(GOBJECT_CFLAGS) \
+ $(GTHREAD_CFLAGS) \
+ $(LIBXFCE4UI2_CFLAGS) \
+ $(PLATFORM_CFLAGS)
+
+libgarcon_gtk3_1_la_LDFLAGS = \
+ -no-undefined \
+ -export-dynamic \
+ -version-info $(GARCON_VERINFO) \
+ -export-symbols-regex "^[^_].*" \
+ $(PLATFORM_LDFLAGS)
+
+libgarcon_gtk3_1_la_LIBADD = \
+ $(top_builddir)/garcon/libgarcon-$(GARCON_VERSION_API).la \
+ $(GIO_LIBS) \
+ $(GLIB_LIBS) \
+ $(GTK3_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(GOBJECT_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(LIBXFCE4UI2_LIBS)
+
+libgarcon_gtk3_DEPENDENCIES = \
+ $(top_builddir)/garcon/libgarcon-$(GARCON_VERSION_API).la
+
+
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = garcon-gtk2-1.pc
+pkgconfig_DATA = garcon-gtk2-1.pc garcon-gtk3-1.pc
# Required for gtk-doc and make distcheck
dist-hook: all
diff --git a/garcon-gtk/garcon-gtk-menu.c b/garcon-gtk/garcon-gtk-menu.c
index 21b5ec4..57d188f 100644
--- a/garcon-gtk/garcon-gtk-menu.c
+++ b/garcon-gtk/garcon-gtk-menu.c
@@ -586,6 +586,8 @@ garcon_gtk_menu_add (GarconGtkMenu *menu,
if (GARCON_IS_MENU_ITEM (li->data))
{
+ GtkWidget *box, *label;
+
/* watch for changes */
g_signal_connect_swapped (G_OBJECT (li->data), "changed",
G_CALLBACK (garcon_gtk_menu_reload), menu);
@@ -605,7 +607,34 @@ garcon_gtk_menu_add (GarconGtkMenu *menu,
continue;
/* create item */
- mi = gtk_image_menu_item_new_with_label (name);
+ mi = gtk_menu_item_new ();
+ label = gtk_label_new (name);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+#else
+ box = gtk_hbox_new (FALSE, 0);
+#endif
+
+ if (menu->priv->show_menu_icons)
+ {
+ icon_name = garcon_menu_item_get_icon_name (li->data);
+ if (STR_IS_EMPTY (icon_name))
+ icon_name = "applications-other";
+
+ image = garcon_gtk_menu_load_icon (icon_name);
+ gtk_widget_show (image);
+ }
+ else
+ {
+ image = gtk_image_new ();
+ }
+
+ /* Add the image and label to the box, add the box to the menu item */
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ gtk_widget_show_all (box);
+ gtk_container_add (GTK_CONTAINER (mi), box);
+
gtk_menu_shell_append (GTK_MENU_SHELL (gtk_menu), mi);
g_signal_connect (G_OBJECT (mi), "activate",
G_CALLBACK (garcon_gtk_menu_item_activate), li->data);
@@ -633,17 +662,6 @@ garcon_gtk_menu_add (GarconGtkMenu *menu,
if (STR_IS_EMPTY (command))
gtk_widget_set_sensitive (mi, FALSE);
- if (menu->priv->show_menu_icons)
- {
- icon_name = garcon_menu_item_get_icon_name (li->data);
- if (STR_IS_EMPTY (icon_name))
- icon_name = "applications-other";
-
- image = garcon_gtk_menu_load_icon (icon_name);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
- gtk_widget_show (image);
- }
-
/* atleast 1 visible child */
has_children = TRUE;
}
@@ -667,14 +685,17 @@ garcon_gtk_menu_add (GarconGtkMenu *menu,
submenu = gtk_menu_new ();
if (garcon_gtk_menu_add (menu, GTK_MENU (submenu), li->data))
{
+ GtkWidget *box, *label;
+
/* attach submenu */
name = garcon_menu_element_get_name (li->data);
- mi = gtk_image_menu_item_new_with_label (name);
- gtk_menu_shell_append (GTK_MENU_SHELL (gtk_menu), mi);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu);
- g_signal_connect (G_OBJECT (submenu), "selection-done",
- G_CALLBACK (garcon_gtk_menu_deactivate), menu);
- gtk_widget_show (mi);
+ mi = gtk_menu_item_new ();
+ label = gtk_label_new (name);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+#else
+ box = gtk_hbox_new (FALSE, 0);
+#endif
if (menu->priv->show_menu_icons)
{
@@ -683,9 +704,24 @@ garcon_gtk_menu_add (GarconGtkMenu *menu,
icon_name = "applications-other";
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
gtk_widget_show (image);
}
+ else
+ {
+ image = gtk_image_new ();
+ }
+
+ /* Add the image and label to the box, add the box to the menu item */
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ gtk_widget_show_all (box);
+ gtk_container_add (GTK_CONTAINER (mi), box);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (gtk_menu), mi);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu);
+ g_signal_connect (G_OBJECT (submenu), "selection-done",
+ G_CALLBACK (garcon_gtk_menu_deactivate), menu);
+ gtk_widget_show (mi);
}
else
{
diff --git a/garcon-gtk/garcon-gtk3-1.pc.in b/garcon-gtk/garcon-gtk3-1.pc.in
new file mode 100644
index 0000000..33d3b3b
--- /dev/null
+++ b/garcon-gtk/garcon-gtk3-1.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+garcon_api_version=@GARCON_VERSION_API@
+
+Name: @PACKAGE_TARNAME@
+Description: Freedesktop.org compliant menu library
+Requires: garcon-2 gtk+-3.0 libxfce4ui-2
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lgarcon-gtk3-${garcon_api_version}
+Cflags: -I${includedir}/garcon-gtk3-${garcon_api_version}
diff --git a/garcon/Makefile.am b/garcon/Makefile.am
index 6ead847..c9941b1 100644
--- a/garcon/Makefile.am
+++ b/garcon/Makefile.am
@@ -26,7 +26,8 @@ AM_CPPFLAGS = \
$(PLATFORM_CFLAGS)
lib_LTLIBRARIES = \
- libgarcon-1.la
+ libgarcon-1.la \
+ libgarcon-2.la
libgarcon_built_public_sources = \
garcon-marshal.h
@@ -93,7 +94,7 @@ libgarcon_1_la_LDFLAGS = \
-version-info $(GARCON_VERINFO) \
-export-symbols-regex "^[^_].*" \
$(PLATFORM_LDFLAGS)
-
+
libgarcon_1_la_LIBADD = \
$(GIO_LIBS) \
$(GLIB_LIBS) \
@@ -101,12 +102,42 @@ libgarcon_1_la_LIBADD = \
$(GOBJECT_LIBS) \
$(GTHREAD_LIBS)
+libgarcon2_includedir = $(includedir)/garcon-2/garcon
+
+libgarcon2_include_HEADERS = $(libgarcon_headers)
+
+libgarcon_2_la_SOURCES = \
+ $(libgarcon_sources) \
+ $(libgarcon_headers)
+
+libgarcon_2_la_CFLAGS = \
+ $(GIO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(GOBJECT_CFLAGS) \
+ $(GTHREAD_CFLAGS) \
+ $(PLATFORM_CFLAGS)
+
+libgarcon_2_la_LDFLAGS = \
+ -no-undefined \
+ -export-dynamic \
+ -version-info $(GARCON_VERINFO) \
+ -export-symbols-regex "^[^_].*" \
+ $(PLATFORM_LDFLAGS)
+
+libgarcon_2_la_LIBADD = \
+ $(GIO_LIBS) \
+ $(GLIB_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(GOBJECT_LIBS) \
+ $(GTHREAD_LIBS)
+
EXTRA_DIST = \
garcon-config.h.in \
garcon-marshal.list
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = garcon-1.pc
+pkgconfig_DATA = garcon-1.pc garcon-2.pc
DISTCLEANFILES = \
stamp-garcon-marshal.h \
diff --git a/garcon/garcon-2.pc.in b/garcon/garcon-2.pc.in
new file mode 100644
index 0000000..10e4356
--- /dev/null
+++ b/garcon/garcon-2.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+garcon_api_version=@GARCON_VERSION_API@
+
+Name: @PACKAGE_TARNAME@
+Description: Freedesktop.org compliant menu library
+Requires: glib-2.0 gio-2.0 gthread-2.0 gobject-2.0
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lgarcon-${garcon_api_version}
+Cflags: -I${includedir}/garcon-${garcon_api_version}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list