[gnome-logs] Display detailed event information in a GtkPopover
- From: Jonathan Kang <jonathankang src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] Display detailed event information in a GtkPopover
- Date: Thu, 29 Jun 2017 07:58:06 +0000 (UTC)
commit 2391b02c0a4cbde9ac1cf313c6ce7741c96be781
Author: Pranav Ganorkar <pranavg189 gmail com>
Date: Mon Jun 12 23:35:45 2017 +0530
Display detailed event information in a GtkPopover
A GtkPopover is shown when a row which is not a header is
activated. For handling very long messages, the message text is
wrapped to fit the size of the GtkPopover. Further, such long
messages are shown in a GtkScrolledWindow. All the earlier
available detail fields are shown in the GtkPopover.
https://bugzilla.gnome.org/show_bug.cgi?id=709294
data/gl-eventviewdetail.ui | 168 ++++++++++++++++++++++++++-----------------
data/gl-style.css | 7 +--
src/gl-eventview.c | 47 ------------
src/gl-eventviewdetail.c | 36 ++--------
src/gl-eventviewdetail.h | 2 +-
src/gl-eventviewlist.c | 24 +-----
6 files changed, 114 insertions(+), 170 deletions(-)
---
diff --git a/data/gl-eventviewdetail.ui b/data/gl-eventviewdetail.ui
index 56fa67a..df548af 100644
--- a/data/gl-eventviewdetail.ui
+++ b/data/gl-eventviewdetail.ui
@@ -1,69 +1,91 @@
<interface domain="gnome-logs">
- <template class="GlEventViewDetail" parent="GtkBin">
- <property name="visible">True</property>
+ <template class="GlEventViewDetail" parent="GtkPopover">
+ <!-- The popover size is set such that it does not go beyond the window -->
+ <property name="width-request">600</property>
+ <property name="height-request">300</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="expand">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkBox" id="top_box">
- <property name="visible">True</property>
+ <object class="GtkLabel" id="comm_field_label">
+ <property name="visible">False</property>
<property name="can_focus">False</property>
- <child>
- <object class="GtkBox" id="comm_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage" id="comm_image">
- <property name="visible">False</property>
- <property name="no_show_all">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="comm_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <style>
- <class name="detail-comm"/>
- </style>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="time_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="hexpand">True</property>
- <property name="selectable">True</property>
- <style>
- <class name="detail-time"/>
- </style>
- </object>
- </child>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Sender</property>
+ <style>
+ <class name="detail-field-label"/>
+ <class name="dim-label"/>
+ </style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="comm_label">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="selectable">True</property>
+ <style>
+ <class name="detail-comm"/>
+ <class name="event-monospace"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="time_field_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Time</property>
+ <style>
+ <class name="detail-field-label"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="time_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="selectable">True</property>
+ <style>
+ <class name="detail-time"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="message_field_label">
<property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
+ <property name="valign">baseline</property>
<property name="label" translatable="yes">Message</property>
<style>
<class name="detail-field-label"/>
@@ -72,25 +94,26 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="message_label">
<property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="wrap">True</property>
+ <property name="valign">baseline</property>
<property name="selectable">True</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
<style>
<class name="detail-message"/>
- <class name="event-monospace"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
@@ -107,7 +130,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -118,12 +141,12 @@
<property name="halign">start</property>
<property name="selectable">True</property>
<style>
- <class name="detail-kernel_device"/>
+ <class name="detail-audit_session"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -140,7 +163,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -156,12 +179,13 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="priority_field_label">
<property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Priority</property>
@@ -172,12 +196,13 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="priority_label">
<property name="visible">True</property>
+ <property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="selectable">True</property>
@@ -187,7 +212,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -196,6 +221,7 @@
<property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
+ <property name="valign">baseline</property>
<property name="label" translatable="yes">Subject</property>
<style>
<class name="detail-field-label"/>
@@ -204,7 +230,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -213,7 +239,10 @@
<property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
+ <property name="valign">baseline</property>
<property name="selectable">True</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
<style>
<class name="detail-subject"/>
<class name="event-monospace"/>
@@ -221,7 +250,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -238,7 +267,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -255,7 +284,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
<child>
@@ -264,6 +293,7 @@
<property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
+ <property name="valign">baseline</property>
<property name="label" translatable="yes">Support</property>
<style>
<class name="detail-field-label"/>
@@ -272,7 +302,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -281,7 +311,10 @@
<property name="no_show_all">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
+ <property name="valign">baseline</property>
<property name="selectable">True</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
<style>
<class name="detail-support"/>
<class name="event-monospace"/>
@@ -289,7 +322,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">7</property>
+ <property name="top_attach">8</property>
</packing>
</child>
<child>
@@ -306,9 +339,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
- </child>
+ </child>
<child>
<object class="GtkLabel" id="documentation_label">
<property name="visible">False</property>
@@ -323,7 +356,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">8</property>
+ <property name="top_attach">9</property>
</packing>
</child>
<child>
@@ -332,13 +365,14 @@
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="selectable">True</property>
+ <property name="wrap">True</property>
<style>
<class name="detail-message"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
<property name="width">2</property>
</packing>
</child>
diff --git a/data/gl-style.css b/data/gl-style.css
index ce48a7f..10562f4 100644
--- a/data/gl-style.css
+++ b/data/gl-style.css
@@ -8,12 +8,7 @@
padding-right: 30px;
}
-.detail-comm {
- font-weight: bold;
- padding: 10px;
-}
-
-.detail-audit_session, .detail-kernel_device, .detail-message, .detail-priority, .detail-time,
.detail-subject, .detail-definedby, .detail-support, .detail-documentation, .detail-message {
+.detail-comm, .detail-audit_session, .detail-kernel_device, .detail-message, .detail-priority, .detail-time,
.detail-subject, .detail-definedby, .detail-support, .detail-documentation {
padding: 10px;
}
diff --git a/src/gl-eventview.c b/src/gl-eventview.c
index 86ba415..e9b914b 100644
--- a/src/gl-eventview.c
+++ b/src/gl-eventview.c
@@ -173,50 +173,6 @@ gl_event_view_set_sort_order (GlEventView *view,
}
static void
-on_notify_mode (GlEventView *view,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GlEventViewPrivate *priv;
- GtkStack *stack;
- GtkWidget *detail;
-
- priv = gl_event_view_get_instance_private (view);
- stack = GTK_STACK (view);
-
- switch (priv->mode)
- {
- case GL_EVENT_VIEW_MODE_LIST:
- {
- GtkWidget *child;
-
- child = gtk_stack_get_child_by_name (stack, "detail");
-
- if (child)
- {
- gtk_container_remove (GTK_CONTAINER (stack), child);
- }
-
- gtk_stack_set_visible_child (stack, priv->events);
- }
- break;
- case GL_EVENT_VIEW_MODE_DETAIL:
- {
- gl_event_view_show_detail (view);
- detail = gl_event_view_detail_new (priv->entry,
- priv->clock_format);
- gtk_widget_show_all (detail);
- gtk_stack_add_named (stack, detail, "detail");
- gtk_stack_set_visible_child_name (stack, "detail");
- }
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
gl_event_view_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -296,9 +252,6 @@ gl_event_view_init (GlEventView *view)
priv->clock_format = g_settings_get_enum (settings, CLOCK_FORMAT);
g_object_unref (settings);
-
- g_signal_connect (view, "notify::mode", G_CALLBACK (on_notify_mode),
- NULL);
}
void
diff --git a/src/gl-eventviewdetail.c b/src/gl-eventviewdetail.c
index aaafad5..549af1f 100644
--- a/src/gl-eventviewdetail.c
+++ b/src/gl-eventviewdetail.c
@@ -34,7 +34,7 @@ enum
struct _GlEventViewDetail
{
/*< private >*/
- GtkBin parent_instance;
+ GtkPopover parent_instance;
};
typedef struct
@@ -42,7 +42,7 @@ typedef struct
GlRowEntry *entry;
GlUtilClockFormat clock_format;
GtkWidget *grid;
- GtkWidget *comm_image;
+ GtkWidget *comm_field_label;
GtkWidget *comm_label;
GtkWidget *time_label;
GtkWidget *message_label;
@@ -62,7 +62,7 @@ typedef struct
GtkWidget *detailed_message_label;
} GlEventViewDetailPrivate;
-G_DEFINE_TYPE_WITH_PRIVATE (GlEventViewDetail, gl_event_view_detail, GTK_TYPE_BIN)
+G_DEFINE_TYPE_WITH_PRIVATE (GlEventViewDetail, gl_event_view_detail, GTK_TYPE_POPOVER)
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
@@ -97,31 +97,9 @@ gl_event_view_detail_create_detail (GlEventViewDetail *detail)
if (gl_journal_entry_get_command_line (entry))
{
- /* Command-line, look for a desktop file. */
- GDesktopAppInfo *desktop;
-
- /* TODO: Use g_desktop_app_info_search? */
- str = g_strconcat (gl_journal_entry_get_command_line (entry), ".desktop", NULL);
- desktop = g_desktop_app_info_new (str);
- g_free (str);
-
- if (desktop)
- {
- GIcon *icon;
-
- icon = g_app_info_get_icon (G_APP_INFO (desktop));
- gtk_image_set_from_gicon (GTK_IMAGE (priv->comm_image),
- icon, GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (priv->comm_image);
- gtk_label_set_text (GTK_LABEL (priv->comm_label),
- g_app_info_get_name (G_APP_INFO (desktop)));
-
- g_object_unref (desktop);
- }
- else
- {
- gtk_label_set_text (GTK_LABEL (priv->comm_label), gl_journal_entry_get_command_line (entry));
- }
+ gtk_label_set_text (GTK_LABEL (priv->comm_label), gl_journal_entry_get_command_line (entry));
+ gtk_widget_show (priv->comm_field_label);
+ gtk_widget_show (priv->comm_label);
}
now = g_date_time_new_now_local ();
@@ -443,7 +421,7 @@ gl_event_view_detail_class_init (GlEventViewDetailClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GlEventViewDetail,
grid);
gtk_widget_class_bind_template_child_private (widget_class, GlEventViewDetail,
- comm_image);
+ comm_field_label);
gtk_widget_class_bind_template_child_private (widget_class, GlEventViewDetail,
comm_label);
gtk_widget_class_bind_template_child_private (widget_class, GlEventViewDetail,
diff --git a/src/gl-eventviewdetail.h b/src/gl-eventviewdetail.h
index 333aa8c..53a56a5 100644
--- a/src/gl-eventviewdetail.h
+++ b/src/gl-eventviewdetail.h
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
#include "gl-util.h"
#define GL_TYPE_EVENT_VIEW_DETAIL (gl_event_view_detail_get_type ())
-G_DECLARE_FINAL_TYPE (GlEventViewDetail, gl_event_view_detail, GL, EVENT_VIEW_DETAIL, GtkBin)
+G_DECLARE_FINAL_TYPE (GlEventViewDetail, gl_event_view_detail, GL, EVENT_VIEW_DETAIL, GtkPopover)
GtkWidget * gl_event_view_detail_new (GlRowEntry *result, GlUtilClockFormat clock_format);
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 1877083..9225214 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -211,28 +211,12 @@ on_listbox_row_activated (GtkListBox *listbox,
}
else
{
- GtkWidget *toplevel;
+ GtkWidget *event_detail_popover;
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ event_detail_popover = gl_event_view_detail_new (priv->entry, priv->clock_format);
+ gtk_popover_set_relative_to (GTK_POPOVER (event_detail_popover), GTK_WIDGET (row));
- if (gtk_widget_is_toplevel (toplevel))
- {
- GAction *mode;
- GEnumClass *eclass;
- GEnumValue *evalue;
-
- mode = g_action_map_lookup_action (G_ACTION_MAP (toplevel), "view-mode");
- eclass = g_type_class_ref (GL_TYPE_EVENT_VIEW_MODE);
- evalue = g_enum_get_value (eclass, GL_EVENT_VIEW_MODE_DETAIL);
-
- g_action_activate (mode, g_variant_new_string (evalue->value_nick));
-
- g_type_class_unref (eclass);
- }
- else
- {
- g_debug ("Widget not in toplevel window, not switching toolbar mode");
- }
+ gtk_widget_show (event_detail_popover);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]