[Xfce4-commits] [apps/xfce4-notifyd] 03/04: Make the "sliding out" animation optional
noreply at xfce.org
noreply at xfce.org
Thu Sep 7 00:40:51 CEST 2017
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-notifyd.
commit fb71d8e0c9332a926acc8ef01d9aef58b98071d4
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Wed Sep 6 21:38:21 2017 +0200
Make the "sliding out" animation optional
---
xfce4-notifyd-config/main.c | 7 +++-
xfce4-notifyd-config/xfce4-notifyd-config.glade | 28 +++++++++++++++-
xfce4-notifyd/xfce-notify-daemon.c | 10 +++++-
xfce4-notifyd/xfce-notify-window.c | 44 ++++++++++++++++---------
xfce4-notifyd/xfce-notify-window.h | 3 +-
5 files changed, 73 insertions(+), 19 deletions(-)
diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index 2f279fe..99a5491 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -729,6 +729,7 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
GtkWidget *icon;
GtkWidget *primary_monitor;
GtkWidget *do_fadeout;
+ GtkWidget *do_slideout;
GtkAdjustment *adj;
GError *error = NULL;
gchar *current_theme;
@@ -810,7 +811,11 @@ xfce4_notifyd_config_setup_dialog(GtkBuilder *builder)
do_fadeout = GTK_WIDGET(gtk_builder_get_object(builder, "do_fadeout"));
xfconf_g_property_bind(channel, "/do-fadeout", G_TYPE_BOOLEAN,
- G_OBJECT(do_fadeout), "active");
+ G_OBJECT(do_fadeout), "active");
+
+ do_slideout = GTK_WIDGET(gtk_builder_get_object(builder, "do_slideout"));
+ xfconf_g_property_bind(channel, "/do-slideout", G_TYPE_BOOLEAN,
+ G_OBJECT(do_slideout), "active");
btn = GTK_WIDGET(gtk_builder_get_object(builder, "preview_button"));
g_signal_connect(G_OBJECT(btn), "clicked",
diff --git a/xfce4-notifyd-config/xfce4-notifyd-config.glade b/xfce4-notifyd-config/xfce4-notifyd-config.glade
index ffc4956..b52785f 100644
--- a/xfce4-notifyd-config/xfce4-notifyd-config.glade
+++ b/xfce4-notifyd-config/xfce4-notifyd-config.glade
@@ -362,7 +362,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -462,6 +462,32 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="label" translatable="yes">_Sliding out animation</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="do_slideout">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index 87d5bff..bc534fd 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -61,6 +61,7 @@ struct _XfceNotifyDaemon
gdouble initial_opacity;
GtkCornerType notify_location;
gboolean do_fadeout;
+ gboolean do_slideout;
gboolean do_not_disturb;
gboolean notification_log;
gint primary_monitor;
@@ -1305,7 +1306,7 @@ notify_notify (XfceNotifyGBus *skeleton,
xfce_notify_window_set_icon_only(window, x_canonical);
- xfce_notify_window_set_do_fadeout(window, xndaemon->do_fadeout);
+ xfce_notify_window_set_do_fadeout(window, xndaemon->do_fadeout, xndaemon->do_slideout);
xfce_notify_window_set_notify_location(window, xndaemon->notify_location);
if(value_hint_set)
@@ -1454,6 +1455,10 @@ xfce_notify_daemon_settings_changed(XfconfChannel *channel,
xndaemon->do_fadeout = G_VALUE_TYPE(value)
? g_value_get_boolean(value)
: TRUE;
+ } else if(!strcmp(property, "/do-slideout")) {
+ xndaemon->do_slideout = G_VALUE_TYPE(value)
+ ? g_value_get_boolean(value)
+ : FALSE;
} else if(!strcmp(property, "/primary-monitor")) {
xndaemon->primary_monitor = G_VALUE_TYPE(value)
? g_value_get_uint(value)
@@ -1508,6 +1513,9 @@ xfce_notify_daemon_load_config (XfceNotifyDaemon *xndaemon,
xndaemon->do_fadeout = xfconf_channel_get_bool(xndaemon->settings,
"/do-fadeout", TRUE);
+ xndaemon->do_slideout = xfconf_channel_get_bool(xndaemon->settings,
+ "/do-slideout", FALSE);
+
xndaemon->primary_monitor = xfconf_channel_get_uint(xndaemon->settings,
"/primary-monitor", 0);
diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c
index 6f6e352..fbded55 100644
--- a/xfce4-notifyd/xfce-notify-window.c
+++ b/xfce4-notifyd/xfce-notify-window.c
@@ -37,8 +37,9 @@
#define DEFAULT_EXPIRE_TIMEOUT 10000
#define DEFAULT_NORMAL_OPACITY 0.85
#define DEFAULT_DO_FADEOUT TRUE
+#define DEFAULT_DO_SLIDEOUT FALSE
#define FADE_TIME 800
-#define FADE_CHANGE_TIMEOUT 25
+#define FADE_CHANGE_TIMEOUT 50
#define DEFAULT_RADIUS 10
#define DEFAULT_PADDING 14.0
@@ -76,6 +77,7 @@ struct _XfceNotifyWindow
guint op_change_steps;
gdouble op_change_delta;
gboolean do_fadeout;
+ gboolean do_slideout;
GtkCornerType notify_location;
};
@@ -179,6 +181,7 @@ xfce_notify_window_init(XfceNotifyWindow *window)
window->expire_timeout = DEFAULT_EXPIRE_TIMEOUT;
window->normal_opacity = DEFAULT_NORMAL_OPACITY;
window->do_fadeout = DEFAULT_DO_FADEOUT;
+ window->do_slideout = DEFAULT_DO_SLIDEOUT;
gtk_widget_set_name (GTK_WIDGET(window), "XfceNotifyWindow");
gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
@@ -528,7 +531,8 @@ xfce_notify_window_enter_leave(GtkWidget *widget,
g_source_remove(window->fade_id);
window->fade_id = 0;
/* reset the sliding-out window to its original position */
- gtk_window_move (GTK_WINDOW (window), window->original_x, window->original_y);
+ if (window->do_slideout)
+ gtk_window_move (GTK_WINDOW (window), window->original_x, window->original_y);
}
}
gtk_widget_set_opacity(GTK_WIDGET(widget), 1.0);
@@ -576,6 +580,7 @@ xfce_notify_window_expire_timeout(gpointer data)
{
XfceNotifyWindow *window = data;
gboolean fade_transparent;
+ gint animation_timeout;
g_return_val_if_fail(XFCE_IS_NOTIFY_WINDOW(data), FALSE);
@@ -586,8 +591,13 @@ xfce_notify_window_expire_timeout(gpointer data)
if(fade_transparent && window->do_fadeout) {
/* remember the original position of the window before we slide it out */
- gtk_window_get_position (GTK_WINDOW (window), &window->original_x, &window->original_y);
- window->fade_id = g_timeout_add(FADE_CHANGE_TIMEOUT,
+ if (window->do_slideout) {
+ gtk_window_get_position (GTK_WINDOW (window), &window->original_x, &window->original_y);
+ animation_timeout = FADE_CHANGE_TIMEOUT / 2;
+ }
+ else
+ animation_timeout = FADE_CHANGE_TIMEOUT;
+ window->fade_id = g_timeout_add(animation_timeout,
xfce_notify_window_fade_timeout,
window);
} else {
@@ -609,16 +619,18 @@ xfce_notify_window_fade_timeout(gpointer data)
g_return_val_if_fail(XFCE_IS_NOTIFY_WINDOW(data), FALSE);
/* slide out animation */
- gtk_window_get_position (GTK_WINDOW (window), &x, &y);
- if (window->notify_location == GTK_CORNER_TOP_RIGHT ||
- window->notify_location == GTK_CORNER_BOTTOM_RIGHT)
- x = x + 10;
- else if (window->notify_location == GTK_CORNER_TOP_LEFT ||
- window->notify_location == GTK_CORNER_BOTTOM_LEFT)
- x = x - 10;
- else
- g_warning("Invalid notify location: %d", window->notify_location);
- gtk_window_move (GTK_WINDOW (window), x, y);
+ if (window->do_slideout) {
+ gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+ if (window->notify_location == GTK_CORNER_TOP_RIGHT ||
+ window->notify_location == GTK_CORNER_BOTTOM_RIGHT)
+ x = x + 10;
+ else if (window->notify_location == GTK_CORNER_TOP_LEFT ||
+ window->notify_location == GTK_CORNER_BOTTOM_LEFT)
+ x = x - 10;
+ else
+ g_warning("Invalid notify location: %d", window->notify_location);
+ gtk_window_move (GTK_WINDOW (window), x, y);
+ }
/* fade-out animation */
op = gtk_widget_get_opacity(GTK_WIDGET(window));
@@ -1140,11 +1152,13 @@ xfce_notify_window_unset_gauge_value(XfceNotifyWindow *window)
void
xfce_notify_window_set_do_fadeout(XfceNotifyWindow *window,
- gboolean do_fadeout)
+ gboolean do_fadeout,
+ gboolean do_slideout)
{
g_return_if_fail(XFCE_IS_NOTIFY_WINDOW(window));
window->do_fadeout = do_fadeout;
+ window->do_slideout = do_slideout;
}
void xfce_notify_window_set_notify_location(XfceNotifyWindow *window,
diff --git a/xfce4-notifyd/xfce-notify-window.h b/xfce4-notifyd/xfce-notify-window.h
index 093717c..404cba9 100644
--- a/xfce4-notifyd/xfce-notify-window.h
+++ b/xfce4-notifyd/xfce-notify-window.h
@@ -101,7 +101,8 @@ void xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
void xfce_notify_window_unset_gauge_value(XfceNotifyWindow *window);
void xfce_notify_window_set_do_fadeout(XfceNotifyWindow *window,
- gboolean do_fadeout);
+ gboolean do_fadeout,
+ gboolean do_slideout);
void xfce_notify_window_set_notify_location(XfceNotifyWindow *window,
GtkCornerType notify_location);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list