[Xfce4-commits] <xfce4-profile-manager:master> Add some widgets to the main window
Stephan Arts
noreply at xfce.org
Sun Oct 9 15:26:01 CEST 2011
Updating branch refs/heads/master
to e9a14be4ec179bab315cfbe07dcda83a69d6b87a (commit)
from 0c7dfd1df84f34e765eabe0c59671db3f8856552 (commit)
commit e9a14be4ec179bab315cfbe07dcda83a69d6b87a
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Oct 8 18:18:47 2011 +0200
Add some widgets to the main window
- A GtkTextView widget for the profile-description
- A GtkTreeView widget for a list of profiles
- A GtkToolbar, with apply button for applying a profile
- A GtkLabel, for a description on how to use this dialog
src/Makefile.am | 6 ++-
src/main_window.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++--
src/main_window_ui.xml | 8 +++
3 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index f1ad722..7d7ec06 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,11 @@ xfce4_profile_manager_built_sources = \
marshal.c
BUILT_SOURCES = \
- $(xfce4_profile_manager_built_sources)
+ $(xfce4_profile_manager_built_sources) \
+ main_window_ui.h
+
+main_window_ui.h: main_window_ui.xml
+ xdt-csource --strip-comments --strip-content --static --name=main_window_ui $< > $@
marshal.h: stamp-marshal.h
@true
diff --git a/src/main_window.c b/src/main_window.c
index ab5005c..c11af9d 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Stephan Arts 2006-2011 <stephan at xfce.org>
+ * Copyright (c) Stephan Arts 2011 <stephan at xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
#include <libxfce4ui/libxfce4ui.h>
#include "main_window.h"
+#include "main_window_ui.h"
static void
xfpm_main_window_init (XfpmMainWindow *);
@@ -54,6 +55,14 @@ enum
struct _XfpmMainWindowPriv
{
+ GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+};
+
+static GtkActionEntry action_entries[] =
+{
+/* Profile Toolbar */
+ { "apply", "document-open", N_ ("_Apply"), NULL, N_ ("Apply the selected profile"), G_CALLBACK (NULL) }
};
GType
@@ -89,13 +98,115 @@ xfpm_main_window_get_type (void)
static void
xfpm_main_window_init (XfpmMainWindow *dialog)
{
- GtkWidget *display_main_hbox;
- GtkWidget *display_main_lbl;
+ GtkWidget *content_area;
+ GtkWidget *label;
+ GtkWidget *hpaned;
+ GtkWidget *text_view;
+ GtkWidget *vbox;
+ GtkWidget *treeview;
+ GtkWidget *toolbar;
+ GtkAccelGroup *accel_group;
dialog->priv = g_new0 (XfpmMainWindowPriv, 1);
+ dialog->priv->ui_manager = gtk_ui_manager_new ();
+
+ accel_group = gtk_ui_manager_get_accel_group (dialog->priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (dialog), accel_group);
+
+ dialog ->priv->action_group = gtk_action_group_new ("XfpmWindow");
+ gtk_action_group_set_translation_domain (
+ dialog->priv->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (
+ dialog->priv->action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ GTK_WIDGET (dialog));
+
+ gtk_ui_manager_insert_action_group (
+ dialog->priv->ui_manager,
+ dialog->priv->action_group,
+ 0);
+
+ gtk_ui_manager_add_ui_from_string (
+ dialog->priv->ui_manager,
+ main_window_ui,
+ main_window_ui_length,
+ NULL);
+
+ content_area = gtk_dialog_get_content_area (
+ GTK_DIALOG (dialog) );
+
+ label = gtk_label_new ( _("Some description\n") );
+
+ hpaned = gtk_hpaned_new ();
+
+/******************/
+ text_view = gtk_text_view_new ();
+
+ gtk_widget_set_size_request (text_view, 300, 200);
+
+ gtk_text_view_set_editable (
+ GTK_TEXT_VIEW (text_view),
+ FALSE );
+/******************/
+
+/******************/
+ vbox = gtk_vbox_new ( FALSE, 4 );
+ gtk_widget_set_size_request (vbox, 200, 200);
+
+ toolbar = gtk_ui_manager_get_widget (
+ dialog->priv->ui_manager,
+ "/profile-toolbar" );
+
+
+ gtk_box_pack_start (
+ GTK_BOX (vbox),
+ toolbar,
+ FALSE,
+ TRUE,
+ 0 );
+
+ treeview = gtk_tree_view_new ();
+
+ gtk_box_pack_end (
+ GTK_BOX (vbox),
+ treeview,
+ TRUE,
+ TRUE,
+ 0 );
+/******************/
+
+ gtk_box_pack_start (
+ GTK_BOX (content_area),
+ label,
+ FALSE,
+ TRUE,
+ 0 );
+ gtk_box_pack_start (
+ GTK_BOX (content_area),
+ hpaned,
+ TRUE,
+ TRUE,
+ 0 );
+
+ gtk_paned_pack1 (
+ GTK_PANED (hpaned),
+ text_view,
+ TRUE,
+ TRUE );
+
+ gtk_paned_pack2 (
+ GTK_PANED (hpaned),
+ vbox ,
+ FALSE,
+ FALSE );
+
+
+ gtk_widget_show_all (content_area);
gtk_dialog_add_button (
- GTK_DIALOG ( dialog ),
+ GTK_DIALOG (dialog),
GTK_STOCK_CLOSE,
GTK_RESPONSE_OK );
}
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
new file mode 100644
index 0000000..2e23fb5
--- /dev/null
+++ b/src/main_window_ui.xml
@@ -0,0 +1,8 @@
+<ui>
+ <!--
+
+ -->
+ <toolbar name="profile-toolbar">
+ <toolitem action="apply"/>
+ </toolbar>
+</ui>
More information about the Xfce4-commits
mailing list