Commit 7f722a48 authored by Guido Gunther's avatar Guido Gunther
Browse files

notification-frame: Add show-body property



This allows to show/hide the bodies of contained notifications
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 1a4573cc
......@@ -93,7 +93,7 @@ phosh_notification_banner_set_notification (PhoshNotificationBanner *self,
g_set_object (&self->notification, notification);
content = phosh_notification_frame_new ();
content = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (content),
self->notification);
gtk_container_add (GTK_CONTAINER (self), content);
......
......@@ -22,6 +22,14 @@
*/
enum {
PROP_0,
PROP_SHOW_BODY,
LAST_PROP
};
static GParamSpec *props[LAST_PROP];
struct _PhoshNotificationFrame {
GtkBox parent;
......@@ -36,6 +44,8 @@ struct _PhoshNotificationFrame {
GtkWidget *img_icon;
GtkWidget *list_notifs;
GtkWidget *updated;
gboolean show_body;
};
typedef struct _PhoshNotificationFrame PhoshNotificationFrame;
......@@ -50,6 +60,44 @@ enum {
static guint signals[N_SIGNALS] = { 0 };
static void
phosh_notification_frame_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PhoshNotificationFrame *self = PHOSH_NOTIFICATION_FRAME (object);
switch (property_id) {
case PROP_SHOW_BODY:
self->show_body = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
phosh_notification_frame_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
PhoshNotificationFrame *self = PHOSH_NOTIFICATION_FRAME (object);
switch (property_id) {
case PROP_SHOW_BODY:
g_value_set_boolean (value, self->show_body);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
phosh_notification_frame_finalize (GObject *object)
{
......@@ -109,6 +157,23 @@ phosh_notification_frame_class_init (PhoshNotificationFrameClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = phosh_notification_frame_finalize;
object_class->set_property = phosh_notification_frame_set_property;
object_class->get_property = phosh_notification_frame_get_property;
/**
* PhoshNotificationContent:show-body:
*
* Whether notificaions in this frame should show the notification body
*/
props[PROP_SHOW_BODY] =
g_param_spec_boolean ("show-body",
"",
"",
TRUE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, props);
signals[SIGNAL_EMPTY] = g_signal_new ("empty",
G_TYPE_FROM_CLASS (klass),
......@@ -138,14 +203,15 @@ phosh_notification_frame_class_init (PhoshNotificationFrameClass *klass)
static void
phosh_notification_frame_init (PhoshNotificationFrame *self)
{
self->show_body = TRUE;
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget *
phosh_notification_frame_new (void)
phosh_notification_frame_new (gboolean show_body)
{
return g_object_new (PHOSH_TYPE_NOTIFICATION_FRAME, NULL);
return g_object_new (PHOSH_TYPE_NOTIFICATION_FRAME, "show-body", show_body, NULL);
}
......@@ -153,8 +219,11 @@ static GtkWidget *
create_row (gpointer item, gpointer data)
{
PhoshNotification *notification = item;
PhoshNotificationFrame *self = PHOSH_NOTIFICATION_FRAME (data);
g_return_val_if_fail (PHOSH_IS_NOTIFICATION_FRAME (self), NULL);
return phosh_notification_content_new (notification, TRUE);
return phosh_notification_content_new (notification, self->show_body);
}
......
......@@ -21,7 +21,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PhoshNotificationFrame, phosh_notification_frame, PHOSH, NOTIFICATION_FRAME, GtkBox)
GtkWidget *phosh_notification_frame_new (void);
GtkWidget *phosh_notification_frame_new (gboolean show_body);
void phosh_notification_frame_bind_notification (PhoshNotificationFrame *self,
PhoshNotification *notification);
void phosh_notification_frame_bind_model (PhoshNotificationFrame *self,
......
......@@ -405,7 +405,7 @@ create_notification_row (gpointer item, gpointer data)
"visible", TRUE,
NULL);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_model (PHOSH_NOTIFICATION_FRAME (frame), item);
gtk_widget_show (frame);
......@@ -435,7 +435,7 @@ on_torch_scale_value_changed (PhoshSettings *self, GtkScale *scale_torch)
/* Only react to scale changes when torch is enabled */
if (!phosh_torch_manager_get_enabled (self->torch_manager))
return;
self->setting_torch = TRUE;
value = gtk_range_get_value (GTK_RANGE (self->scale_torch));
g_debug ("Setting torch brightness to %.2f", value);
......
......@@ -44,7 +44,7 @@ test_phosh_notification_frame_new (void)
NULL,
now);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (frame),
noti);
}
......@@ -71,7 +71,7 @@ test_phosh_notification_frame_header_activated (void)
NULL,
now);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (frame),
noti);
g_signal_connect (noti, "actioned", G_CALLBACK (actioned), NULL);
......@@ -107,7 +107,7 @@ test_phosh_notification_frame_notification_activated (void)
NULL,
now);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (frame),
noti);
g_signal_connect (noti, "actioned", G_CALLBACK (actioned), NULL);
......
......@@ -94,7 +94,7 @@ main (int argc, char **argv)
FALSE,
NULL,
now);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (frame),
notification);
g_signal_connect (frame, "empty", G_CALLBACK (empty), box);
......@@ -114,7 +114,7 @@ main (int argc, char **argv)
FALSE,
NULL,
now);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_notification (PHOSH_NOTIFICATION_FRAME (frame),
notification);
g_signal_connect (frame, "empty", G_CALLBACK (empty), box);
......
......@@ -28,7 +28,7 @@ create (gpointer item, gpointer data)
"visible", TRUE,
NULL);
frame = phosh_notification_frame_new ();
frame = phosh_notification_frame_new (TRUE);
phosh_notification_frame_bind_model (PHOSH_NOTIFICATION_FRAME (frame), item);
gtk_widget_show (frame);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment