[Xfce4-commits] <squeeze:stephan/new-ui> Add menu
Stephan Arts
noreply at xfce.org
Fri May 10 10:48:01 CEST 2013
Updating branch refs/heads/stephan/new-ui
to 598b63a1f455e998f23d89308a4ca2a4c5a70bfd (commit)
from 509b18fe45dfa1a36c3f01054d407a4aa942a249 (commit)
commit 598b63a1f455e998f23d89308a4ca2a4c5a70bfd
Author: Stephan Arts <stephan at xfce.org>
Date: Fri May 10 10:17:27 2013 +0200
Add menu
src/Makefile.am | 4 +
src/main_window.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++-
src/main_window.h | 3 +
src/main_window_ui.xml | 21 +++++
4 files changed, 219 insertions(+), 3 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 3ac044c..8c7cd67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,8 +38,12 @@ DISTCLEANFILES = \
BUILT_SOURCES = \
throbber-fallback.c
+ main_window_ui.h
throbber-fallback.c: $(srcdir)/throbber-fallback.png Makefile
(echo "#include \"throbber-fallback.h\"" && gdk-pixbuf-csource --extern --raw --stream --name=sq_throbber_fallback $(srcdir)/throbber-fallback.png) > throbber-fallback.c
+main_window_ui.h: main_window_ui.xml
+ exo-csource --strip-comments --strip-content --static --name=main_window_ui $< > $@
+
endif
diff --git a/src/main_window.c b/src/main_window.c
index 290bef5..7bf094b 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -26,6 +26,7 @@
#include <libsqueeze/libsqueeze.h>
#include "main_window.h"
+#include "main_window_ui.h"
#ifndef SQUEEZE_APP_TITLE
#define SQUEEZE_APP_TITLE _("Archive Manager")
@@ -43,7 +44,54 @@ sq_main_window_dispose(GObject *object);
static GObjectClass *parent_class;
-#if 0
+static void
+cb_sq_main_window_open_archive (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_save_copy (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_properties (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_close (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_quit (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_preferences (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_contents (
+ GtkWidget *,
+ gpointer
+ );
+
+static void
+cb_sq_main_window_about (
+ GtkWidget *,
+ gpointer
+ );
+
static GtkActionEntry action_entries[] =
{
/* File Menu */
@@ -56,7 +104,7 @@ static GtkActionEntry action_entries[] =
N_ ("_Open..."), /* Label-text */
"<control>O", /* Keyboard shortcut */
N_ ("Open an archive"), /* Tooltip text */
- G_CALLBACK (cb_sq_main_window_open_image), },
+ G_CALLBACK (cb_sq_main_window_open_archive), },
{ "save-copy",
GTK_STOCK_SAVE_AS, /* Icon-name */
N_ ("_Save copy..."), /* Label-text */
@@ -114,7 +162,16 @@ static GtkActionEntry action_entries[] =
NULL,
NULL, }
};
-#endif
+
+
+struct _SQMainWindowPriv
+{
+ GtkWidget *menubar;
+
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GtkRecentManager *recent_manager;
+};
GType
sq_main_window_get_type (void)
@@ -155,13 +212,62 @@ sq_main_window_class_init(SQMainWindowClass *window_class)
static void
sq_main_window_dispose(GObject *object)
{
+ SQMainWindow *window = SQ_MAIN_WINDOW (object);
+
+ if (window->priv)
+ {
+ if (window->priv->ui_manager)
+ {
+ g_object_unref (window->priv->ui_manager);
+ window->priv->ui_manager = NULL;
+ }
+
+ g_free (window->priv);
+ window->priv = NULL;
+ }
parent_class->dispose(object);
}
static void
sq_main_window_init(SQMainWindow *window)
{
+ GtkAccelGroup *accel_group;
+ GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);
+
gtk_window_set_title (GTK_WINDOW (window), SQUEEZE_APP_TITLE);
+
+ window->priv = g_new0(SQMainWindowPriv, 1);
+ window->priv->ui_manager = gtk_ui_manager_new ();
+ window->priv->recent_manager = gtk_recent_manager_get_default();
+ window->priv->action_group = gtk_action_group_new ("RsttoWindow");
+
+ gtk_action_group_set_translation_domain (
+ window->priv->action_group,
+ GETTEXT_PACKAGE );
+ gtk_action_group_add_actions (
+ window->priv->action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ GTK_WIDGET (window) );
+
+
+ accel_group = gtk_ui_manager_get_accel_group (window->priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+ gtk_ui_manager_insert_action_group (
+ window->priv->ui_manager,
+ window->priv->action_group,
+ 0);
+ gtk_ui_manager_add_ui_from_string (
+ window->priv->ui_manager,
+ main_window_ui,
+ main_window_ui_length,
+ NULL );
+
+ window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
+
+ gtk_container_add (GTK_CONTAINER (window), main_vbox);
+ gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menubar, FALSE, FALSE, 0);
}
GtkWidget *
@@ -173,3 +279,85 @@ sq_main_window_new (void)
return GTK_WIDGET(window);
}
+
+/** STATIC CALLBACKS **/
+
+/**
+ * cb_sq_main_window_open_archive:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_sq_main_window_open_archive (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_save_copy (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_properties (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+
+static void
+cb_sq_main_window_close (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_quit (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_preferences (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_contents (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
+
+static void
+cb_sq_main_window_about (
+ GtkWidget *widget,
+ gpointer user_data
+ )
+{
+ return;
+}
diff --git a/src/main_window.h b/src/main_window.h
index 036c2f7..2e7baae 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -39,11 +39,14 @@ G_BEGIN_DECLS
G_TYPE_CHECK_CLASS_TYPE ((klass), \
sq_main_window_get_type()))
+typedef struct _SQMainWindowPriv SQMainWindowPriv;
+
typedef struct _SQMainWindow SQMainWindow;
struct _SQMainWindow
{
GtkWindow parent;
+ SQMainWindowPriv *priv;
};
typedef struct _SQMainWindowClass SQMainWindowClass;
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
new file mode 100644
index 0000000..a6cfdc4
--- /dev/null
+++ b/src/main_window_ui.xml
@@ -0,0 +1,21 @@
+<ui>
+ <menubar name="main-menu">
+ <menu action="file-menu">
+ <menuitem action="open"/>
+ <placeholder name="placeholder-open-recent"/>
+ <separator/>
+ <menuitem action="save-copy"/>
+ <separator/>
+ <menuitem action="properties"/>
+ <menuitem action="close"/>
+ <menuitem action="quit"/>
+ </menu>
+ <menu action="edit-menu">
+ <menuitem action="preferences"/>
+ </menu>
+ <menu action="help-menu">
+ <menuitem action="contents"/>
+ <menuitem action="about"/>
+ </menu>
+ </menubar>
+</ui>
More information about the Xfce4-commits
mailing list