[gnome-system-log] Use an ui file for the window structure
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-log] Use an ui file for the window structure
- Date: Fri, 19 Apr 2013 06:48:44 +0000 (UTC)
commit e2c495e38d1576355865a73accdc80a63386d216
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Apr 6 11:40:17 2013 +0200
Use an ui file for the window structure
libgd | 2 +-
po/POTFILES.in | 2 +-
src/logview-gear-menu.ui | 58 -------------
src/logview-window.c | 88 +++++--------------
src/logview-window.ui | 212 ++++++++++++++++++++++++++++++++++++++++++++++
src/logview.gresource.xml | 2 +-
6 files changed, 235 insertions(+), 129 deletions(-)
---
diff --git a/libgd b/libgd
index 801ddd1..77c6e0d 160000
--- a/libgd
+++ b/libgd
@@ -1 +1 @@
-Subproject commit 801ddd1edd4c88f07468938bd6166e3b2a433730
+Subproject commit 77c6e0dad29c244d9a353e2b86abc21552930474
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0a76413..24c2958 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,10 +7,10 @@ src/logview-app.c
[type: gettext/glade]src/logview-app-menu.ui
src/logview-filter-manager.c
[type: gettext/glade]src/logview-filter.ui
-[type: gettext/glade]src/logview-gear-menu.ui
src/logview-findbar.c
src/logview-log.c
src/logview-loglist.c
src/logview-main.c
src/logview-utils.c
src/logview-window.c
+[type: gettext/glade]src/logview-window.ui
diff --git a/src/logview-window.c b/src/logview-window.c
index ab3b85a..7c5221c 100644
--- a/src/logview-window.c
+++ b/src/logview-window.c
@@ -41,13 +41,11 @@
struct _LogviewWindowPrivate {
PangoFontDescription *monospace_description;
+ GtkWidget *header_bar;
GtkWidget *find_bar_revealer;
GtkWidget *find_bar;
GtkWidget *loglist;
- GtkWidget *sidebar;
- GtkWidget *hpaned;
GtkWidget *text_view;
- GtkWidget *header_bar;
GtkWidget *message_area;
GtkWidget *message_primary;
@@ -108,7 +106,6 @@ populate_tag_table (GtkTextTagTable *tag_table)
gtk_text_tag_table_add (tag_table, tag);
}
-
static void
populate_style_tag_table (LogviewWindow *logview)
{
@@ -1196,10 +1193,11 @@ logview_window_init_actions (LogviewWindow *window)
static void
logview_window_init (LogviewWindow *logview)
{
- GtkWidget *hpaned, *main_view, *vbox, *w;
+ GtkWidget *content, *w;
gchar *monospace_font_name;
LogviewWindowPrivate *priv;
int width, height;
+ GError *err = NULL;
GtkBuilder *builder;
GMenuModel *menu;
@@ -1217,36 +1215,21 @@ logview_window_init (LogviewWindow *logview)
logview_prefs_get_stored_window_size (priv->prefs, &width, &height);
gtk_window_set_default_size (GTK_WINDOW (logview), width, height);
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (logview), vbox);
-
- /* create header bar and menus */
- priv->header_bar = gd_header_bar_new ();
- gtk_box_pack_start (GTK_BOX (vbox), priv->header_bar, FALSE, FALSE, 0);
-
- w = gd_header_toggle_button_new ();
- gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (w), "edit-find-symbolic");
- gtk_actionable_set_action_name (GTK_ACTIONABLE (w), "win.search");
- gd_header_bar_pack_end (GD_HEADER_BAR (priv->header_bar), w);
+ gd_ensure_types ();
- w = gd_header_menu_button_new ();
- gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (w), "emblem-system-symbolic");
- gd_header_bar_pack_end (GD_HEADER_BAR (priv->header_bar), w);
+ builder = gtk_builder_new ();
- gtk_widget_show_all (priv->header_bar);
+ if (!gtk_builder_add_from_resource (builder, "/org/gnome/logview/logview-window.ui", &err)) {
+ g_error ("failed to load ui: %s", err->message);
+ }
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder, "/org/gnome/logview/logview-gear-menu.ui", NULL);
- menu = G_MENU_MODEL (gtk_builder_get_object (builder, "gear-menu"));
- gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (w), menu);
- gtk_actionable_set_action_name (GTK_ACTIONABLE (w), "win.gear-menu");
+ content = GTK_WIDGET (gtk_builder_get_object (builder, "window-content"));
+ gtk_container_add (GTK_CONTAINER (logview), content);
+ /* header bar and menus */
+ priv->header_bar = GTK_WIDGET (gtk_builder_get_object (builder, "headerbar"));
priv->filters_placeholder = G_MENU_MODEL (gtk_builder_get_object (builder, "filters-placeholder"));
- g_object_unref (builder);
-
- priv->find_bar_revealer = gd_revealer_new ();
- gtk_widget_show (priv->find_bar_revealer);
- gtk_box_pack_start (GTK_BOX (vbox), priv->find_bar_revealer, FALSE, FALSE, 0);
+ priv->find_bar_revealer = GTK_WIDGET (gtk_builder_get_object (builder, "find-bar-revealer"));
priv->find_bar = logview_findbar_new ();
gtk_widget_show (priv->find_bar);
@@ -1261,27 +1244,12 @@ logview_window_init (LogviewWindow *logview)
g_signal_connect (priv->find_bar, "close",
G_CALLBACK (findbar_close_cb), logview);
- /* panes */
- hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
- priv->hpaned = hpaned;
- gtk_widget_show (hpaned);
-
- /* first pane : sidebar (list of logs) */
- priv->sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_widget_show (priv->sidebar);
-
- /* first pane: log list */
- w = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ /* sidebar (list of logs) */
+ w = GTK_WIDGET (gtk_builder_get_object (builder, "sidebar-scrolledwindow"));
priv->loglist = logview_loglist_new ();
- gtk_container_add (GTK_CONTAINER (w), priv->loglist);
- gtk_box_pack_start (GTK_BOX (priv->sidebar), w, TRUE, TRUE, 0);
- gtk_paned_pack1 (GTK_PANED (hpaned), priv->sidebar, FALSE, FALSE);
- gtk_widget_show (w);
gtk_widget_show (priv->loglist);
+ gtk_container_add (GTK_CONTAINER (w), priv->loglist);
g_signal_connect (priv->loglist, "day_selected",
G_CALLBACK (loglist_day_selected_cb), logview);
@@ -1289,33 +1257,18 @@ logview_window_init (LogviewWindow *logview)
G_CALLBACK (loglist_day_cleared_cb), logview);
/* second pane: log */
- main_view = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_paned_pack2 (GTK_PANED (hpaned), main_view, TRUE, TRUE);
-
- /* second pane: error message area */
- priv->message_area = gtk_info_bar_new ();
+ priv->message_area = GTK_WIDGET (gtk_builder_get_object (builder, "error-infobar"));
message_area_create_error_box (logview, priv->message_area);
gtk_info_bar_add_button (GTK_INFO_BAR (priv->message_area),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- gtk_box_pack_start (GTK_BOX (main_view), priv->message_area, FALSE, FALSE, 0);
- /* second pane: text view */
- w = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (main_view), w, TRUE, TRUE, 0);
- gtk_widget_show (w);
+ priv->text_view = GTK_WIDGET (gtk_builder_get_object (builder, "log-textview"));
priv->tag_table = gtk_text_tag_table_new ();
populate_tag_table (priv->tag_table);
- priv->text_view = gtk_text_view_new ();
- g_object_set (priv->text_view, "editable", FALSE, NULL);
populate_style_tag_table (logview);
- gtk_container_add (GTK_CONTAINER (w), priv->text_view);
- gtk_widget_show (priv->text_view);
-
/* use the desktop monospace font */
monospace_font_name = logview_prefs_get_monospace_font_name (priv->prefs);
logview_set_font (logview, monospace_font_name);
@@ -1339,9 +1292,8 @@ logview_window_init (LogviewWindow *logview)
G_CALLBACK (active_log_changed_cb), logview);
update_filter_menu (logview);
-
- gtk_widget_show (vbox);
- gtk_widget_show (main_view);
+
+ g_object_unref (builder);
}
static void
diff --git a/src/logview-window.ui b/src/logview-window.ui
new file mode 100644
index 0000000..ee826ed
--- /dev/null
+++ b/src/logview-window.ui
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="gear-menu">
+ <section>
+ <item>
+ <attribute name="action">win.open</attribute>
+ <attribute name="label" translatable="yes">Open...</attribute>
+ <attribute name="accel"><Primary>o</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.close</attribute>
+ <attribute name="label" translatable="yes">Close</attribute>
+ <attribute name="accel"><Primary>w</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="action">win.copy</attribute>
+ <attribute name="label" translatable="yes">Copy</attribute>
+ <attribute name="accel"><Primary>c</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.select_all</attribute>
+ <attribute name="label" translatable="yes">Select All</attribute>
+ <attribute name="accel"><Primary>a</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="action">win.zoom_in</attribute>
+ <attribute name="label" translatable="yes">Zoom In</attribute>
+ <attribute name="accel"><Primary>plus</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.zoom_out</attribute>
+ <attribute name="label" translatable="yes">Zoom Out</attribute>
+ <attribute name="accel"><Primary>minus</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.zoom_normal</attribute>
+ <attribute name="label" translatable="yes">Normal Size</attribute>
+ <attribute name="accel"><Primary>0</attribute>
+ </item>
+ </section>
+ <submenu>
+ <attribute name="label" translatable="yes">Filters</attribute>
+ <section id="filters-placeholder">
+ </section>
+ <item>
+ <attribute name="action">win.filters_match</attribute>
+ <attribute name="label" translatable="yes">Show Matches Only</attribute>
+ </item>
+ <item>
+ <attribute name="action">win.filters_manage</attribute>
+ <attribute name="label" translatable="yes">Manage Filters...</attribute>
+ </item>
+ </submenu>
+ </menu>
+ <object class="GtkGrid" id="window-content">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GdHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="vexpand">False</property>
+ <child>
+ <object class="GdHeaderSimpleButton" id="find-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="symbolic-icon-name">edit-find-symbolic</property>
+ <property name="action_name">win.search</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GdHeaderMenuButton" id="gear-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="symbolic-icon-name">emblem-system-symbolic</property>
+ <property name="menu-model">gear-menu</property>
+ <property name="action_name">win.gear-menu</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GdRevealer" id="find-bar-revealer">
+ <property name="visible">True</property>
+ <property name="reveal-child">false</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkPaned" id="paned1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="sidebar-scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">none</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="logpane">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkInfoBar" id="error-infobar">
+ <property name="visible">False</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="hexpand">True</property>
+ <child internal-child="content_area">
+ <object class="GtkBox" id="infobar-content_area1">
+ <property name="can_focus">False</property>
+ <property name="border_width">8</property>
+ <property name="spacing">16</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="infobar-action_area1">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="log-scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">none</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkTextView" id="log-textview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/src/logview.gresource.xml b/src/logview.gresource.xml
index 28d1273..801cad0 100644
--- a/src/logview.gresource.xml
+++ b/src/logview.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/logview">
<file preprocess="xml-stripblanks">logview-app-menu.ui</file>
- <file preprocess="xml-stripblanks">logview-gear-menu.ui</file>
+ <file preprocess="xml-stripblanks">logview-window.ui</file>
<file preprocess="xml-stripblanks">logview-filter.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]