[eog] Make it possible to build with a simple Hildon-based UI
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [eog] Make it possible to build with a simple Hildon-based UI
- Date: Thu, 5 Nov 2009 17:29:12 +0000 (UTC)
commit 08041a2e4935a46cc97e344f92fccc29aadade3d
Author: Gustavo Noronha Silva <kov debian org>
Date: Wed Nov 4 19:48:19 2009 -0200
Make it possible to build with a simple Hildon-based UI
configure.ac | 21 +++++++++++++++++++++
src/eog-window.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
src/eog-window.h | 9 +++++++++
src/main.c | 4 ++++
4 files changed, 84 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 59db69c..8d4a1c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,27 @@ fi
AM_CONDITIONAL([WITH_CLUTTER_BACKEND], [test "x$have_clutter" = "xyes"])
+# ******************
+# Hildon (optional)
+# ******************
+
+HILDON_REQUIRED=1.99.0
+
+AC_ARG_WITH([hildon], AC_HELP_STRING([--with-hildon], [enable Hildon UI]),
+ [with_hildon=$withval], [with_hildon=no])
+have_hildon=no
+if test "x$with_hildon" != "xno"; then
+ PKG_CHECK_MODULES(HILDON,
+ hildon-1 >= $HILDON_REQUIRED,
+ have_hildon=yes, have_hildon=no)
+fi
+if test "x$have_hildon" = "xyes"; then
+ AC_DEFINE(WITH_HILDON_UI, 1, [Hildon UI.])
+ EOG_MODULES="$EOG_MODULES hildon-1 >= $HILDON_REQUIRED"
+fi
+
+AM_CONDITIONAL([WITH_HILDON_UI], [test "x$have_hildon" = "xyes"])
+
# ****************
# D-Bus activation
# ****************
diff --git a/src/eog-window.c b/src/eog-window.c
index 34b89a8..d3799ad 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -70,6 +70,9 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
+#ifdef WITH_HILDON_UI
+#include <hildon/hildon.h>
+#endif
#if HAVE_LCMS
#include <X11/Xlib.h>
@@ -83,7 +86,11 @@
#define EOG_WINDOW_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EOG_TYPE_WINDOW, EogWindowPrivate))
+#ifdef WITH_HILDON_UI
+G_DEFINE_TYPE (EogWindow, eog_window, HILDON_TYPE_STACKABLE_WINDOW);
+#else
G_DEFINE_TYPE (EogWindow, eog_window, GTK_TYPE_WINDOW);
+#endif
#define EOG_WINDOW_MIN_WIDTH 440
#define EOG_WINDOW_MIN_HEIGHT 350
@@ -4018,6 +4025,28 @@ eog_window_finish_saving (EogWindow *window)
} while (priv->save_job != NULL);
}
+#ifdef WITH_HILDON_UI
+static GtkWidget *
+get_menu_from_menu_bar (GtkWidget *menu_bar) {
+ GtkWidget *main_menu;
+ GList *item;
+
+ main_menu = gtk_menu_new ();
+
+ item = gtk_container_get_children (GTK_CONTAINER (menu_bar));
+ while (item) {
+ GtkWidget *menu;
+
+ menu = GTK_WIDGET (item->data);
+ gtk_widget_reparent (menu, main_menu);
+
+ item = g_list_next (item);
+ }
+
+ return main_menu;
+}
+#endif
+
static void
eog_window_construct_ui (EogWindow *window)
{
@@ -4111,8 +4140,6 @@ eog_window_construct_ui (EogWindow *window)
menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
g_assert (GTK_IS_WIDGET (menubar));
- gtk_box_pack_start (GTK_BOX (priv->box), menubar, FALSE, FALSE, 0);
- gtk_widget_show (menubar);
menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
"/MainMenu/Image/EditFlipHorizontal");
@@ -4134,6 +4161,23 @@ eog_window_construct_ui (EogWindow *window)
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
+#ifdef WITH_HILDON_UI
+ {
+ GtkWidget *menu = get_menu_from_menu_bar (menubar);
+
+ hildon_window_set_menu(HILDON_WINDOW (window), GTK_MENU (menu));
+ }
+#else
+ gtk_box_pack_start (GTK_BOX (priv->box), menubar, FALSE, FALSE, 0);
+ gtk_widget_show (menubar);
+#endif
+
+#ifdef WITH_HILDON_UI
+ priv-> toolbar = gtk_ui_manager_get_widget (priv->ui_mgr,
+ "/FullscreenToolbar");
+
+ hildon_window_add_toolbar (HILDON_WINDOW (window), GTK_TOOLBAR (priv->toolbar));
+#else
priv->toolbar = GTK_WIDGET
(g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
"ui-manager", priv->ui_mgr,
@@ -4148,6 +4192,7 @@ eog_window_construct_ui (EogWindow *window)
FALSE,
FALSE,
0);
+#endif
gtk_widget_show (priv->toolbar);
@@ -4171,10 +4216,13 @@ eog_window_construct_ui (EogWindow *window)
gtk_widget_show (priv->cbox);
priv->statusbar = eog_statusbar_new ();
+
+#ifndef WITH_HILDON_UI
gtk_box_pack_end (GTK_BOX (priv->box),
GTK_WIDGET (priv->statusbar),
FALSE, FALSE, 0);
gtk_widget_show (priv->statusbar);
+#endif
priv->image_info_message_cid =
gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
diff --git a/src/eog-window.h b/src/eog-window.h
index d5839ec..f125646 100644
--- a/src/eog-window.h
+++ b/src/eog-window.h
@@ -34,6 +34,7 @@
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
+#include <hildon/hildon.h>
G_BEGIN_DECLS
@@ -75,13 +76,21 @@ typedef enum {
} EogStartupFlags;
struct _EogWindow {
+#ifdef WITH_HILDON_UI
+ HildonStackableWindow win;
+#else
GtkWindow win;
+#endif
EogWindowPrivate *priv;
};
struct _EogWindowClass {
+#ifdef WITH_HILDON_UI
+ HildonStackableWindowClass parent_class;
+#else
GtkWindowClass parent_class;
+#endif
void (* prepared) (EogWindow *window);
};
diff --git a/src/main.c b/src/main.c
index bdf1f30..ca5da0d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -223,6 +223,10 @@ main (int argc, char **argv)
gtk_clutter_init (&argc, &argv);
#endif
+#if WITH_HILDON_UI
+ hildon_init ();
+#endif
+
#ifdef HAVE_EXEMPI
xmp_init();
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]