summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid King <davidk@gnome.org>2013-09-28 23:14:07 +0100
committerDavid King <davidk@gnome.org>2013-09-30 11:27:19 +0100
commiteea86f06f7d6bd8c14d766f599a13cf6bfaaa37d (patch)
treedd50201690fe5c321d03835cb9a3e7343b44e849
parentabe91248244fea3909bd287f54026085758e8373 (diff)
downloadgnome-logs-eea86f06f7d6bd8c14d766f599a13cf6bfaaa37d.tar.gz
Move right toolbar to GlEventToolbar object
-rw-r--r--Makefile.am4
-rw-r--r--data/gl-eventtoolbar.ui43
-rw-r--r--data/gl-window.ui63
-rw-r--r--data/gnome-logs.gresource.xml1
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/gl-application.c2
-rw-r--r--src/gl-eventtoolbar.c155
-rw-r--r--src/gl-eventtoolbar.h61
8 files changed, 268 insertions, 62 deletions
diff --git a/Makefile.am b/Makefile.am
index f8ecf90..0eb2c36 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@ gnome_logs_LDADD = \
gnome_logs_SOURCES = \
src/gl-application.c \
src/gl-categorylist.c \
+ src/gl-eventtoolbar.c \
src/gl-eventview.c \
src/gl-main.c \
src/gl-window.c
@@ -35,11 +36,13 @@ enum_data = \
src/gl-enums.h
gnome_logs_enum_headers = \
+ $(srcdir)/src/gl-eventtoolbar.h \
$(srcdir)/src/gl-eventview.h
noinst_gnome_logs_headers = \
src/gl-application.h \
src/gl-categorylist.h \
+ src/gl-eventtoolbar.h \
src/gl-eventview.h \
src/gl-window.h
@@ -88,6 +91,7 @@ src/gl-enums.h: $(gnome_logs_enum_headers) Makefile
noinst_resource_files = \
data/appmenu.ui \
data/gl-categorylist.ui \
+ data/gl-eventtoolbar.ui \
data/gl-style.css \
data/gl-window.ui
diff --git a/data/gl-eventtoolbar.ui b/data/gl-eventtoolbar.ui
new file mode 100644
index 0000000..f04f2fc
--- /dev/null
+++ b/data/gl-eventtoolbar.ui
@@ -0,0 +1,43 @@
+<interface domain="gnome-logs">
+ <template class="GlEventToolbar" parent="GtkHeaderBar">
+ <property name="expand">True</property>
+ <property name="show-close-button">True</property>
+ <property name="title" translatable="yes">Logs</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="go_back">
+ <property name="sensitive">False</property>
+ <property name="tooltip-text" translatable="yes">Go back to the event view</property>
+ <property name="visible">True</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="go_back_icon">
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="search">
+ <property name="sensitive">False</property>
+ <property name="tooltip-text" translatable="yes">Search the displayed logs</property>
+ <property name="visible">True</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="search_icon">
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/data/gl-window.ui b/data/gl-window.ui
index d8a6a87..b0fda9a 100644
--- a/data/gl-window.ui
+++ b/data/gl-window.ui
@@ -27,69 +27,8 @@
</object>
</child>
<child>
- <object class="GtkHeaderBar" id="right_toolbar">
- <property name="show-close-button">True</property>
+ <object class="GlEventToolbar" id="right_toolbar">
<property name="visible">True</property>
- <child>
- <object class="GtkButton" id="go_back">
- <property name="sensitive">False</property>
- <property name="visible">True</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage" id="go_back_icon">
- <property name="icon-name">go-previous-symbolic</property>
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="title">
- <object class="GtkLabel" id="title">
- <property name="expand">True</property>
- <property name="label" translatable="yes">Logs</property>
- <property name="visible">True</property>
- <style>
- <class name="title"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="search">
- <property name="sensitive">False</property>
- <property name="visible">True</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage" id="search_icon">
- <property name="icon-name">edit-find-symbolic</property>
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkMenuButton" id="gear_menu">
- <property name="visible">True</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage" id="gear_image">
- <property name="icon-name">emblem-system-symbolic</property>
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
</object>
</child>
</object>
diff --git a/data/gnome-logs.gresource.xml b/data/gnome-logs.gresource.xml
index 4507b53..07ff551 100644
--- a/data/gnome-logs.gresource.xml
+++ b/data/gnome-logs.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix='/org/gnome/Logs'>
<file preprocess='xml-stripblanks'>appmenu.ui</file>
<file preprocess='xml-stripblanks'>gl-categorylist.ui</file>
+ <file preprocess='xml-stripblanks'>gl-eventtoolbar.ui</file>
<file>gl-style.css</file>
<file preprocess='xml-stripblanks'>gl-window.ui</file>
</gresource>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8b2328d..57d8a12 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,5 +1,6 @@
[type: gettext/glade]data/appmenu.ui
[type: gettext/glade]data/gl-categorylist.ui
+[type: gettext/glade]data/gl-eventtoolbar.ui
[type: gettext/glade]data/gl-window.ui
data/gnome-logs.desktop.in
src/gl-application.c
diff --git a/src/gl-application.c b/src/gl-application.c
index b7f8ab3..294f9d8 100644
--- a/src/gl-application.c
+++ b/src/gl-application.c
@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
#include "gl-categorylist.h"
+#include "gl-eventtoolbar.h"
#include "gl-eventview.h"
#include "gl-window.h"
@@ -98,6 +99,7 @@ gl_application_startup (GApplication *application)
/* Must register custom types before using them from GtkBuilder. */
gl_window_get_type ();
gl_category_list_get_type ();
+ gl_event_toolbar_get_type ();
gl_event_view_get_type ();
}
diff --git a/src/gl-eventtoolbar.c b/src/gl-eventtoolbar.c
new file mode 100644
index 0000000..a47dac4
--- /dev/null
+++ b/src/gl-eventtoolbar.c
@@ -0,0 +1,155 @@
+/*
+ * GNOME Logs - View and search logs
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gl-eventtoolbar.h"
+
+#include <glib/gi18n.h>
+
+#include "gl-enums.h"
+
+enum
+{
+ PROP_0,
+ PROP_MODE,
+ N_PROPERTIES
+};
+
+typedef struct
+{
+ GlEventToolbarMode mode;
+} GlEventToolbarPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GlEventToolbar, gl_event_toolbar, GTK_TYPE_HEADER_BAR)
+
+static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
+
+static void
+on_notify_mode (GlEventToolbar *toolbar,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GlEventToolbarPrivate *priv;
+
+ priv = gl_event_toolbar_get_instance_private (toolbar);
+
+ switch (priv->mode)
+ {
+ case GL_EVENT_TOOLBAR_MODE_LIST:
+ break;
+ case GL_EVENT_TOOLBAR_MODE_DETAIL:
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+gl_event_toolbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GlEventToolbar *toolbar = GL_EVENT_TOOLBAR (object);
+ GlEventToolbarPrivate *priv = gl_event_toolbar_get_instance_private (toolbar);
+
+ switch (prop_id)
+ {
+ case PROP_MODE:
+ g_value_set_enum (value, priv->mode);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gl_event_toolbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GlEventToolbar *view = GL_EVENT_TOOLBAR (object);
+ GlEventToolbarPrivate *priv = gl_event_toolbar_get_instance_private (view);
+
+ switch (prop_id)
+ {
+ case PROP_MODE:
+ priv->mode = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gl_event_toolbar_class_init (GlEventToolbarClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gobject_class->get_property = gl_event_toolbar_get_property;
+ gobject_class->set_property = gl_event_toolbar_set_property;
+
+ obj_properties[PROP_MODE] = g_param_spec_enum ("mode", "Mode",
+ "Mode to determine which buttons to show",
+ GL_TYPE_EVENT_TOOLBAR_MODE,
+ GL_EVENT_TOOLBAR_MODE_LIST,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, N_PROPERTIES,
+ obj_properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/Logs/gl-eventtoolbar.ui");
+}
+
+static void
+gl_event_toolbar_init (GlEventToolbar *toolbar)
+{
+ gtk_widget_init_template (GTK_WIDGET (toolbar));
+
+ g_signal_connect (toolbar, "notify::mode", G_CALLBACK (on_notify_mode),
+ NULL);
+}
+
+void
+gl_event_toolbar_set_mode (GlEventToolbar *toolbar, GlEventToolbarMode mode)
+{
+ GlEventToolbarPrivate *priv;
+
+ g_return_if_fail (GL_EVENT_TOOLBAR (toolbar));
+
+ priv = gl_event_toolbar_get_instance_private (toolbar);
+
+ if (priv->mode != mode)
+ {
+ priv->mode = mode;
+ g_object_notify_by_pspec (G_OBJECT (toolbar),
+ obj_properties[PROP_MODE]);
+ }
+}
+
+GtkWidget *
+gl_event_toolbar_new (void)
+{
+ return g_object_new (GL_TYPE_EVENT_TOOLBAR, NULL);
+}
diff --git a/src/gl-eventtoolbar.h b/src/gl-eventtoolbar.h
new file mode 100644
index 0000000..31f4bb6
--- /dev/null
+++ b/src/gl-eventtoolbar.h
@@ -0,0 +1,61 @@
+/*
+ * GNOME Logs - View and search logs
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GL_EVENT_TOOLBAR_H_
+#define GL_EVENT_TOOLBAR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+ /*< private >*/
+ GtkHeaderBar parent_instance;
+} GlEventToolbar;
+
+typedef struct
+{
+ /*< private >*/
+ GtkListBoxClass parent_class;
+} GlEventToolbarClass;
+
+/*
+ * GlEventToolbarMode:
+ * @GL_EVENT_TOOLBAR_MODE_LIST:
+ * @GL_EVENT_TOOLBAR_MODE_DETAIL:
+ *
+ * The mode, selected in #GlEventView, to show in the toolbar.
+ */
+typedef enum
+{
+ GL_EVENT_TOOLBAR_MODE_LIST,
+ GL_EVENT_TOOLBAR_MODE_DETAIL
+} GlEventToolbarMode;
+
+#define GL_TYPE_EVENT_TOOLBAR (gl_event_toolbar_get_type ())
+#define GL_EVENT_TOOLBAR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GL_TYPE_EVENT_TOOLBAR, GlEventToolbar))
+
+GType gl_event_toolbar_get_type (void);
+GtkWidget * gl_event_toolbar_new (void);
+void gl_event_toolbar_set_mode (GlEventToolbar *toolbar,
+ GlEventToolbarMode mode);
+
+G_END_DECLS
+
+#endif /* GL_EVENT_TOOLBAR_H_ */