[gnome-system-log] window: use GdHeaderBar for the main toolbar
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-log] window: use GdHeaderBar for the main toolbar
- Date: Mon, 25 Mar 2013 20:19:19 +0000 (UTC)
commit 51bee11017e0bb15569e3d4c98be5d8a90c88467
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Mar 25 16:17:36 2013 -0400
window: use GdHeaderBar for the main toolbar
Like other GNOME3 applications.
configure.ac | 2 +-
libgd | 2 +-
src/logview-window.c | 90 ++++++++++++++++++++++++-------------------------
3 files changed, 46 insertions(+), 48 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5322b56..52f6fb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,7 @@ PKG_CHECK_MODULES(LOGVIEW,
gtk+-3.0 >= $GTK_MIN_VERSION)
LIBGD_INIT([
- main-toolbar
+ header-bar
revealer
static
])
diff --git a/libgd b/libgd
index 4cd7128..801ddd1 160000
--- a/libgd
+++ b/libgd
@@ -1 +1 @@
-Subproject commit 4cd7128e3b6c3dbafc4b1839585e69885b9f4741
+Subproject commit 801ddd1edd4c88f07468938bd6166e3b2a433730
diff --git a/src/logview-window.c b/src/logview-window.c
index 74c1f13..ef5c29f 100644
--- a/src/logview-window.c
+++ b/src/logview-window.c
@@ -25,8 +25,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
-#include <libgd/gd-main-toolbar.h>
-#include <libgd/gd-revealer.h>
+#include <libgd/gd.h>
#include "logview-window.h"
@@ -48,7 +47,7 @@ struct _LogviewWindowPrivate {
GtkWidget *sidebar;
GtkWidget *hpaned;
GtkWidget *text_view;
- GtkWidget *toolbar;
+ GtkWidget *header_bar;
GtkWidget *message_area;
GtkWidget *message_primary;
@@ -161,43 +160,39 @@ _gtk_text_buffer_apply_tag_to_rectangle (GtkTextBuffer *buffer, int line_start,
}
static void
-logview_update_toolbar (LogviewWindow *logview,
- LogviewLog *active,
- Day *selected_day)
+logview_update_header (LogviewWindow *logview,
+ LogviewLog *active,
+ Day *selected_day)
{
GString *string;
GDateTime *log_time;
- gchar *text;
+ gchar *title, *subtitle, *text;
time_t timestamp;
+ title = subtitle = NULL;
+
if (active == NULL) {
- gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (logview->priv->toolbar),
- NULL, NULL);
- return;
+ goto out;
}
if (gd_revealer_get_reveal_child (GD_REVEALER (logview->priv->find_bar_revealer))) {
- text = g_strdup_printf (_("Search in \"%s\""),
- logview_log_get_display_name (active));
- gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (logview->priv->toolbar),
- text, NULL);
- g_free (text);
- return;
+ title = g_strdup_printf (_("Search in \"%s\""),
+ logview_log_get_display_name (active));
+ goto out;
}
- if (selected_day != NULL) {
- text = logview_utils_format_date (selected_day->date);
- gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (logview->priv->toolbar),
- logview_log_get_display_name (active), text);
- g_free (text);
+ title = g_strdup (logview_log_get_display_name (active));
- return;
+ if (selected_day != NULL) {
+ subtitle = logview_utils_format_date (selected_day->date);
+ goto out;
}
timestamp = logview_log_get_timestamp (active);
log_time = g_date_time_new_from_unix_local (timestamp);
text = logview_utils_format_date (log_time);
+ g_date_time_unref (log_time);
/* translators: this is part of a label composed with
* a date string, for example "updated today 23:54"
@@ -212,11 +207,14 @@ logview_update_toolbar (LogviewWindow *logview,
g_string_append (string, text);
g_free (text);
- gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (logview->priv->toolbar),
- logview_log_get_display_name (active), string->str);
+ subtitle = g_string_free (string, FALSE);
- g_string_free (string, TRUE);
- g_date_time_unref (log_time);
+ out:
+ gd_header_bar_set_title (GD_HEADER_BAR (logview->priv->header_bar), title);
+ gd_header_bar_set_subtitle (GD_HEADER_BAR (logview->priv->header_bar), subtitle);
+
+ g_free (title);
+ g_free (subtitle);
}
#define DEFAULT_LOGVIEW_FONT "Monospace 10"
@@ -355,7 +353,10 @@ wrap:
primary = g_strdup_printf (_("Search in \"%s\""),
logview_log_get_display_name (active_log));
- gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (logview->priv->toolbar), primary, secondary);
+
+ gd_header_bar_set_title (GD_HEADER_BAR (logview->priv->header_bar), primary);
+ gd_header_bar_set_subtitle (GD_HEADER_BAR (logview->priv->header_bar), secondary);
+
g_free (primary);
}
@@ -621,7 +622,7 @@ loglist_day_selected_cb (LogviewLoglist *loglist,
LogviewLog *active_log = logview_manager_get_active_log (logview_manager_get ());
real_select_day (logview, day->first_line, day->last_line);
- logview_update_toolbar (logview, active_log, day);
+ logview_update_header (logview, active_log, day);
}
static void
@@ -640,7 +641,7 @@ loglist_day_cleared_cb (LogviewLoglist *loglist,
gtk_text_buffer_remove_tag_by_name (buffer, "invisible",
&start, &end);
- logview_update_toolbar (logview, active_log, NULL);
+ logview_update_header (logview, active_log, NULL);
}
static void
@@ -747,7 +748,7 @@ read_new_lines_cb (LogviewLog *log,
G_CALLBACK (log_monitor_changed_cb), window);
}
- logview_update_toolbar (window, log, NULL);
+ logview_update_header (window, log, NULL);
logview_loglist_update_lines (LOGVIEW_LOGLIST (window->priv->loglist), log);
}
@@ -764,7 +765,7 @@ active_log_changed_cb (LogviewManager *manager,
findbar_close_cb (LOGVIEW_FINDBAR (window->priv->find_bar),
window);
- logview_update_toolbar (window, log, NULL);
+ logview_update_header (window, log, NULL);
if (window->priv->monitor_id) {
g_signal_handler_disconnect (old_log, window->priv->monitor_id);
@@ -1110,7 +1111,7 @@ action_search_change_state (GSimpleAction *action,
gtk_widget_grab_focus (logview->priv->find_bar);
}
- logview_update_toolbar (logview, active_log, NULL);
+ logview_update_header (logview, active_log, NULL);
g_simple_action_set_state (action, state);
}
@@ -1187,20 +1188,20 @@ logview_window_init (LogviewWindow *logview)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (logview), vbox);
- /* create toolbar and menus */
- priv->toolbar = gd_main_toolbar_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->toolbar),
- "menubar");
- gtk_box_pack_start (GTK_BOX (vbox), priv->toolbar, FALSE, FALSE, 0);
- gtk_widget_show_all (priv->toolbar);
+ /* 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_main_toolbar_add_toggle (GD_MAIN_TOOLBAR (priv->toolbar),
- "edit-find-symbolic", NULL, FALSE);
+ 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);
- w = gd_main_toolbar_add_menu (GD_MAIN_TOOLBAR (priv->toolbar),
- "emblem-system-symbolic", NULL, FALSE);
- gtk_widget_show (w);
+ 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);
+
+ gtk_widget_show_all (priv->header_bar);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/org/gnome/logview/logview-gear-menu.ui", NULL);
@@ -1242,8 +1243,6 @@ logview_window_init (LogviewWindow *logview)
w = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w),
- GTK_SHADOW_ETCHED_IN);
priv->loglist = logview_loglist_new ();
gtk_container_add (GTK_CONTAINER (w), priv->loglist);
@@ -1272,7 +1271,6 @@ logview_window_init (LogviewWindow *logview)
w = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (main_view), w, TRUE, TRUE, 0);
gtk_widget_show (w);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]