Commit 7ab1c207 authored by afdw's avatar afdw
Browse files

Add hint `x-xfce4-full-with-value` that allows to show summary, body and...

Add hint `x-xfce4-full-with-value` that allows to show summary, body and actions together with a gauge (fixes #4)
parent b1ec634c
Pipeline #1465 passed with stages
in 1 minute and 20 seconds
......@@ -962,7 +962,7 @@ static gboolean notify_get_capabilities (XfceNotifyGBus *skeleton,
const gchar *const capabilities[] =
{
"actions", "body", "body-hyperlinks", "body-markup", "icon-static",
"x-canonical-private-icon-only", NULL
"x-canonical-private-icon-only", "x-xfce4-full-with-value", NULL
};
xfce_notify_gbus_complete_get_capabilities(skeleton, invocation, capabilities);
......@@ -1138,6 +1138,7 @@ notify_notify (XfceNotifyGBus *skeleton,
gint value_hint = 0;
gboolean value_hint_set = FALSE;
gboolean x_canonical = FALSE;
gboolean full_with_value = FALSE;
gboolean transient = FALSE;
GVariant *item;
GVariantIter iter;
......@@ -1215,6 +1216,11 @@ notify_notify (XfceNotifyGBus *skeleton,
x_canonical = TRUE;
g_variant_unref(value);
}
else if (g_strcmp0 (key, "x-xfce4-full-with-value") == 0)
{
full_with_value = TRUE;
g_variant_unref(value);
}
else
{
g_variant_unref(value);
......@@ -1350,7 +1356,7 @@ notify_notify (XfceNotifyGBus *skeleton,
xfce_notify_window_set_notify_location(window, xndaemon->notify_location);
if (value_hint_set)
xfce_notify_window_set_gauge_value(window, value_hint, xndaemon->css_provider);
xfce_notify_window_set_gauge_value(window, value_hint, full_with_value, xndaemon->css_provider);
else
xfce_notify_window_unset_gauge_value(window);
......
......@@ -945,6 +945,7 @@ xfce_notify_window_set_icon_only(XfceNotifyWindow *window,
void
xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
gint value,
gboolean full_with_value,
GtkCssProvider *css_provider)
{
g_return_if_fail(XFCE_IS_NOTIFY_WINDOW(window));
......@@ -955,13 +956,27 @@ xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
else if(value < 0)
value = 0;
gtk_widget_hide(window->summary);
gtk_widget_hide(window->body);
gtk_widget_hide(window->button_box);
if(full_with_value) {
if(window->has_summary_text)
gtk_widget_show(window->summary);
if(window->has_body_text)
gtk_widget_show(window->body);
if(window->has_actions)
gtk_widget_show(window->button_box);
} else {
gtk_widget_hide(window->summary);
gtk_widget_hide(window->body);
gtk_widget_hide(window->button_box);
}
if(!window->gauge) {
GtkWidget *box;
gint width;
gdouble padding;
gtk_widget_style_get(GTK_WIDGET(window),
"padding", &padding,
NULL);
if(gtk_widget_get_visible(window->icon)) {
/* size the pbar in relation to the icon */
......@@ -984,6 +999,8 @@ xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
window->gauge = gtk_progress_bar_new();
gtk_widget_set_size_request(window->gauge, width, -1);
gtk_widget_show(window->gauge);
if(full_with_value && window->has_body_text)
gtk_widget_set_margin_top(window->gauge, padding / 2);
gtk_container_add(GTK_CONTAINER(box), window->gauge);
gtk_style_context_add_provider (gtk_widget_get_style_context (window->gauge),
GTK_STYLE_PROVIDER (css_provider),
......
......@@ -93,6 +93,7 @@ void xfce_notify_window_set_icon_only(XfceNotifyWindow *window,
void xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
gint value,
gboolean full_with_value,
GtkCssProvider *css_provider);
void xfce_notify_window_unset_gauge_value(XfceNotifyWindow *window);
......
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