[Xfce4-commits] [xfce/xfce4-panel] 01/01: Reimplement enter/leave opacity for Gtk3 plugins
noreply at xfce.org
noreply at xfce.org
Wed Apr 19 01:02:44 CEST 2017
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository xfce/xfce4-panel.
commit 4c73a6f67f53323543652d4a1434661ddb9e4d46
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Wed Apr 19 01:02:28 2017 +0200
Reimplement enter/leave opacity for Gtk3 plugins
---
libxfce4panel/xfce-panel-plugin-provider.h | 1 +
panel/panel-base-window.c | 92 ++++++++++++++++++++++++------
panel/panel-base-window.h | 4 ++
panel/panel-plugin-external.c | 20 +++++++
panel/panel-plugin-external.h | 3 +
panel/panel-window.c | 5 ++
wrapper/main.c | 7 +++
wrapper/wrapper-plug.c | 15 +++++
wrapper/wrapper-plug.h | 3 +
9 files changed, 134 insertions(+), 16 deletions(-)
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index e603986..d568e8a 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -107,6 +107,7 @@ typedef enum /*< skip >*/
PROVIDER_PROP_TYPE_SET_NROWS, /* gint */
PROVIDER_PROP_TYPE_SET_LOCKED, /* gboolean */
PROVIDER_PROP_TYPE_SET_SENSITIVE, /* gboolean */
+ PROVIDER_PROP_TYPE_SET_OPACITY, /* gdouble */
PROVIDER_PROP_TYPE_SET_BACKGROUND_COLOR, /* string, wrapper only */
PROVIDER_PROP_TYPE_SET_BACKGROUND_IMAGE, /* string, wrapper only */
PROVIDER_PROP_TYPE_ACTION_REMOVED, /* none */
diff --git a/panel/panel-base-window.c b/panel/panel-base-window.c
index 1e11889..63f1c5c 100644
--- a/panel/panel-base-window.c
+++ b/panel/panel-base-window.c
@@ -67,6 +67,13 @@ static void panel_base_window_set_background_css (PanelBaseWindow
gchar *css_string);
static void panel_base_window_set_plugin_data (PanelBaseWindow *window,
GtkCallback func);
+static void panel_base_window_set_plugin_opacity (GtkWidget *widget,
+ gpointer user_data,
+ gdouble opacity);
+static void panel_base_window_set_plugin_enter_opacity (GtkWidget *widget,
+ gpointer user_data);
+static void panel_base_window_set_plugin_leave_opacity (GtkWidget *widget,
+ gpointer user_data);
static void panel_base_window_set_plugin_background_color (GtkWidget *widget,
gpointer user_data);
static void panel_base_window_set_plugin_background_image (GtkWidget *widget,
@@ -94,10 +101,6 @@ struct _PanelBaseWindowPrivate
/* background css style provider */
GtkCssProvider *css_provider;
- /* transparency settings */
- gdouble enter_opacity;
- gdouble leave_opacity;
-
/* active window timeout id */
guint active_timeout_id;
};
@@ -201,10 +204,10 @@ panel_base_window_init (PanelBaseWindow *window)
window->background_style = PANEL_BG_STYLE_NONE;
window->background_image = NULL;
window->background_rgba = NULL;
+ window->enter_opacity = 1.00;
+ window->leave_opacity = 1.00;
window->priv->css_provider = gtk_css_provider_new ();
- window->priv->enter_opacity = 1.00;
- window->priv->leave_opacity = 1.00;
window->priv->borders = PANEL_BORDER_NONE;
window->priv->active_timeout_id = 0;
@@ -237,11 +240,11 @@ panel_base_window_get_property (GObject *object,
switch (prop_id)
{
case PROP_ENTER_OPACITY:
- g_value_set_uint (value, rint (priv->enter_opacity * 100.00));
+ g_value_set_uint (value, rint (window->enter_opacity * 100.00));
break;
case PROP_LEAVE_OPACITY:
- g_value_set_uint (value, rint (priv->leave_opacity * 100.00));
+ g_value_set_uint (value, rint (window->leave_opacity * 100.00));
break;
case PROP_BACKGROUND_STYLE:
@@ -300,14 +303,18 @@ panel_base_window_set_property (GObject *object,
{
case PROP_ENTER_OPACITY:
/* set the new enter opacity */
- priv->enter_opacity = g_value_get_uint (value) / 100.00;
+ window->enter_opacity = g_value_get_uint (value) / 100.00;
break;
case PROP_LEAVE_OPACITY:
/* set the new leave opacity */
- priv->leave_opacity = g_value_get_uint (value) / 100.00;
+ window->leave_opacity = g_value_get_uint (value) / 100.00;
if (window->is_composited)
- gtk_widget_set_opacity (GTK_WIDGET (object), priv->leave_opacity);
+ {
+ gtk_widget_set_opacity (GTK_WIDGET (object), window->leave_opacity);
+ panel_base_window_set_plugin_data (window,
+ panel_base_window_set_plugin_leave_opacity);
+ }
break;
case PROP_BACKGROUND_STYLE:
@@ -455,14 +462,19 @@ static gboolean
panel_base_window_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
+ PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
PanelBaseWindowPrivate *priv = PANEL_BASE_WINDOW (widget)->priv;
/* switch to enter opacity when compositing is enabled
* and the two values are different */
if (event->detail != GDK_NOTIFY_INFERIOR
&& PANEL_BASE_WINDOW (widget)->is_composited
- && priv->leave_opacity != priv->enter_opacity)
- gtk_widget_set_opacity (GTK_WIDGET (widget), priv->enter_opacity);
+ && window->leave_opacity != window->enter_opacity)
+ {
+ gtk_widget_set_opacity (GTK_WIDGET (widget), window->enter_opacity);
+ panel_base_window_set_plugin_data (window,
+ panel_base_window_set_plugin_enter_opacity);
+ }
return FALSE;
}
@@ -473,14 +485,19 @@ static gboolean
panel_base_window_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
+ PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
PanelBaseWindowPrivate *priv = PANEL_BASE_WINDOW (widget)->priv;
/* switch to leave opacity when compositing is enabled
* and the two values are different */
if (event->detail != GDK_NOTIFY_INFERIOR
&& PANEL_BASE_WINDOW (widget)->is_composited
- && priv->leave_opacity != priv->enter_opacity)
- gtk_widget_set_opacity (GTK_WIDGET (widget), priv->leave_opacity);
+ && window->leave_opacity != window->enter_opacity)
+ {
+ gtk_widget_set_opacity (GTK_WIDGET (widget), window->leave_opacity);
+ panel_base_window_set_plugin_data (window,
+ panel_base_window_set_plugin_leave_opacity);
+ }
return FALSE;
}
@@ -501,7 +518,12 @@ panel_base_window_composited_changed (GtkWidget *widget)
return;
if (window->is_composited)
- gtk_widget_set_opacity (GTK_WIDGET (widget), window->priv->leave_opacity);
+ {
+ gtk_widget_set_opacity (GTK_WIDGET (widget), window->leave_opacity);
+ panel_base_window_set_plugin_data (window,
+ panel_base_window_set_plugin_leave_opacity);
+
+ }
panel_debug (PANEL_DEBUG_BASE_WINDOW,
"%p: compositing=%s", window,
@@ -656,6 +678,44 @@ panel_base_window_set_plugin_data (PanelBaseWindow *window,
static void
+panel_base_window_set_plugin_enter_opacity (GtkWidget *widget,
+ gpointer user_data)
+{
+ PanelBaseWindow *window = PANEL_BASE_WINDOW (user_data);
+ PanelBaseWindowPrivate *priv = window->priv;
+
+ panel_base_window_set_plugin_opacity (widget, user_data, window->enter_opacity);
+}
+
+
+
+static void
+panel_base_window_set_plugin_leave_opacity (GtkWidget *widget,
+ gpointer user_data)
+{
+ PanelBaseWindow *window = PANEL_BASE_WINDOW (user_data);
+ PanelBaseWindowPrivate *priv = window->priv;
+
+ panel_base_window_set_plugin_opacity (widget, user_data, window->leave_opacity);
+}
+
+
+
+static void
+panel_base_window_set_plugin_opacity (GtkWidget *widget,
+ gpointer user_data,
+ gdouble opacity)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
+ panel_return_if_fail (PANEL_IS_BASE_WINDOW (user_data));
+
+ if (PANEL_IS_PLUGIN_EXTERNAL (widget))
+ panel_plugin_external_set_opacity (PANEL_PLUGIN_EXTERNAL (widget), opacity);
+}
+
+
+
+static void
panel_base_window_set_plugin_background_color (GtkWidget *widget,
gpointer user_data)
{
diff --git a/panel/panel-base-window.h b/panel/panel-base-window.h
index 04efd6d..33e9981 100644
--- a/panel/panel-base-window.h
+++ b/panel/panel-base-window.h
@@ -70,6 +70,10 @@ struct _PanelBaseWindow
GdkRGBA *background_rgba;
GdkColor *background_color;
gchar *background_image;
+
+ /* transparency settings */
+ gdouble enter_opacity;
+ gdouble leave_opacity;
};
GType panel_base_window_get_type (void) G_GNUC_CONST;
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 16ef221..e0cb011 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -1116,6 +1116,26 @@ panel_plugin_external_restart (PanelPluginExternal *external)
void
+panel_plugin_external_set_opacity (PanelPluginExternal *external,
+ gdouble opacity)
+{
+ GValue value = { 0, };
+
+ panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
+
+ g_value_init (&value, G_TYPE_DOUBLE);
+ g_value_set_double (&value, opacity);
+
+ panel_plugin_external_queue_add (external,
+ PROVIDER_PROP_TYPE_SET_OPACITY,
+ &value);
+
+ g_value_unset (&value);
+}
+
+
+
+void
panel_plugin_external_set_background_color (PanelPluginExternal *external,
const GdkRGBA *color)
{
diff --git a/panel/panel-plugin-external.h b/panel/panel-plugin-external.h
index e6606f0..1e48c97 100644
--- a/panel/panel-plugin-external.h
+++ b/panel/panel-plugin-external.h
@@ -86,6 +86,9 @@ GType panel_plugin_external_get_type (void) G_GNUC_CONST;
void panel_plugin_external_restart (PanelPluginExternal *external);
+void panel_plugin_external_set_opacity (PanelPluginExternal *external,
+ gdouble opacity);
+
void panel_plugin_external_set_background_color (PanelPluginExternal *external,
const GdkRGBA *color);
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 74d3a66..5c9599a 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -3023,6 +3023,11 @@ panel_window_set_povider_info (PanelWindow *window,
/* unset the background (PROVIDER_PROP_TYPE_ACTION_BACKGROUND_UNSET) */
panel_plugin_external_set_background_color (PANEL_PLUGIN_EXTERNAL (provider), NULL);
}
+ if (base_window->leave_opacity != 1.0)
+ {
+ panel_plugin_external_set_opacity (PANEL_PLUGIN_EXTERNAL (provider),
+ base_window->leave_opacity);
+ }
}
panel_window_plugin_set_mode (provider, window);
diff --git a/wrapper/main.c b/wrapper/main.c
index d766741..cdf7d68 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -109,6 +109,13 @@ wrapper_gproxy_set (DBusGProxy *dbus_gproxy,
gtk_widget_set_sensitive (GTK_WIDGET (provider), g_value_get_boolean (value));
break;
+ case PROVIDER_PROP_TYPE_SET_OPACITY:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ plug = g_object_get_qdata (G_OBJECT (provider), plug_quark);
+ wrapper_plug_set_opacity (plug, g_value_get_double (value));
+#endif
+ break;
+
case PROVIDER_PROP_TYPE_SET_BACKGROUND_COLOR:
case PROVIDER_PROP_TYPE_SET_BACKGROUND_IMAGE:
case PROVIDER_PROP_TYPE_ACTION_BACKGROUND_UNSET:
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index 7fad6eb..9bad4d2 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -373,6 +373,21 @@ wrapper_plug_new (GdkNativeWindow socket_id)
#if GTK_CHECK_VERSION (3, 0, 0)
void
+wrapper_plug_set_opacity (WrapperPlug *plug,
+ gdouble opacity)
+{
+
+ panel_return_if_fail (WRAPPER_IS_PLUG (plug));
+
+ if (gtk_widget_get_opacity (GTK_WIDGET (plug)) != opacity)
+ gtk_widget_set_opacity (GTK_WIDGET (plug), opacity);
+}
+#endif
+
+
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+void
wrapper_plug_set_background_color (WrapperPlug *plug,
const gchar *color_string)
{
diff --git a/wrapper/wrapper-plug.h b/wrapper/wrapper-plug.h
index 386367a..f4e7fc5 100644
--- a/wrapper/wrapper-plug.h
+++ b/wrapper/wrapper-plug.h
@@ -48,6 +48,9 @@ WrapperPlug *wrapper_plug_new (Window socket_id);
WrapperPlug *wrapper_plug_new (GdkNativeWindow socket_id);
#endif
+void wrapper_plug_set_opacity (WrapperPlug *plug,
+ gdouble opacity);
+
void wrapper_plug_set_background_alpha (WrapperPlug *plug,
gdouble alpha);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list