[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-github> Added plugin property "small".
Andrzej
noreply at xfce.org
Mon Dec 12 11:40:07 CET 2011
Updating branch refs/heads/andrzejr/deskbar-github
to 860755c34a18d77392b06453af4b2b28d2f3cdc2 (commit)
from c1bb27bc4194b2f96ae519cbf1359961cbe770cf (commit)
commit 860755c34a18d77392b06453af4b2b28d2f3cdc2
Author: Andrzej <ndrwrdck at gmail.com>
Date: Fri Nov 11 04:58:12 2011 +0900
Added plugin property "small".
libxfce4panel/xfce-panel-plugin-provider.h | 2 +
libxfce4panel/xfce-panel-plugin.c | 88 ++++++++++++++++++++++++++++
libxfce4panel/xfce-panel-plugin.h | 5 ++
panel/panel-application.c | 10 +++
panel/panel-itembar.c | 21 +++++++
5 files changed, 126 insertions(+), 0 deletions(-)
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 57e238d..cec8ba2 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -94,6 +94,8 @@ typedef enum /*< skip >*/
PROVIDER_SIGNAL_SHOW_CONFIGURE,
PROVIDER_SIGNAL_SHOW_ABOUT,
PROVIDER_SIGNAL_FOCUS_PLUGIN,
+ PROVIDER_SIGNAL_SMALL_PLUGIN,
+ PROVIDER_SIGNAL_NOT_SMALL_PLUGIN,
PROVIDER_SIGNAL_SHRINK_PLUGIN,
PROVIDER_SIGNAL_UNSHRINK_PLUGIN
}
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 36d66cc..7d100fb 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -130,6 +130,7 @@ enum
PROP_SIZE,
PROP_NROWS,
PROP_DESKBAR_MODE,
+ PROP_SMALL,
PROP_SCREEN_POSITION,
PROP_EXPAND,
PROP_SHRINK
@@ -177,6 +178,7 @@ struct _XfcePanelPluginPrivate
GtkOrientation orientation;
guint nrows;
gboolean deskbar_mode : 1;
+ gboolean small : 1;
XfceScreenPosition screen_position;
guint locked : 1;
GSList *menu_items;
@@ -630,6 +632,25 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
| G_PARAM_STATIC_STRINGS));
/**
+ * XfcePanelPlugin:small:
+ *
+ * Wether the #XfcePanelPlugin is small enough to fit a single row of a multi-row panel.
+ * Plugin writes can use it to read or set this property, but xfce_panel_plugin_set_small()
+ * is recommended.
+ *
+ * Since: 4.10
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_SMALL,
+ g_param_spec_boolean ("small",
+ "Small",
+ "Is this plugin small, e.g. a single button?",
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+
+ /**
* XfcePanelPlugin:expand:
*
* Wether the #XfcePanelPlugin expands on the panel. Plugin writes can use it
@@ -683,6 +704,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->size = 0;
plugin->priv->nrows = 1;
plugin->priv->deskbar_mode = FALSE;
+ plugin->priv->small = FALSE;
plugin->priv->expand = FALSE;
plugin->priv->shrink = FALSE;
plugin->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
@@ -793,6 +815,10 @@ xfce_panel_plugin_get_property (GObject *object,
g_value_set_uint (value, private->nrows);
break;
+ case PROP_SMALL:
+ g_value_set_boolean (value, private->small);
+ break;
+
case PROP_SCREEN_POSITION:
g_value_set_enum (value, private->screen_position);
break;
@@ -852,6 +878,11 @@ xfce_panel_plugin_set_property (GObject *object,
private->arguments = g_value_dup_boxed (value);
break;
+ case PROP_SMALL:
+ xfce_panel_plugin_set_small (XFCE_PANEL_PLUGIN (object),
+ g_value_get_boolean (value));
+ break;
+
case PROP_EXPAND:
xfce_panel_plugin_set_expand (XFCE_PANEL_PLUGIN (object),
g_value_get_boolean (value));
@@ -1788,6 +1819,63 @@ xfce_panel_plugin_get_size (XfcePanelPlugin *plugin)
/**
+ * xfce_panel_plugin_get_small:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Whether the plugin is small enough to fit in a single row of a multi-row panel.
+ * E.g. if it is a button-like applet.
+ *
+ * Returns: %TRUE when the plugin is small,
+ * %FALSE otherwise.
+ *
+ * Since: 4.10
+ **/
+gboolean
+xfce_panel_plugin_get_small (XfcePanelPlugin *plugin)
+{
+ g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE);
+ g_return_val_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin), FALSE);
+
+ return plugin->priv->small;
+}
+
+
+
+/**
+ * xfce_panel_plugin_set_small:
+ * @plugin : an #XfcePanelPlugin.
+ * @small : whether the plugin is a small button-like applet.
+ *
+ * Whether the plugin is small enough to fit in a single row of a multi-row panel.
+ * E.g. if it is a button-like applet.
+ **/
+void
+xfce_panel_plugin_set_small (XfcePanelPlugin *plugin,
+ gboolean small)
+{
+ g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ g_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
+
+ /* normalize the value */
+ small = !!small;
+
+ /* check if update is required */
+ if (G_LIKELY (xfce_panel_plugin_get_small (plugin) != small))
+ {
+ plugin->priv->small = small;
+
+ /* emit signal (in provider) */
+ xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+ small ? PROVIDER_SIGNAL_SMALL_PLUGIN :
+ PROVIDER_SIGNAL_NOT_SMALL_PLUGIN);
+
+ g_object_notify (G_OBJECT (plugin), "small");
+ }
+}
+
+
+
+/**
* xfce_panel_plugin_get_expand:
* @plugin : an #XfcePanelPlugin.
*
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index f6716a0..3b88164 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -176,6 +176,11 @@ guint xfce_panel_plugin_get_nrows (XfcePanelPlugin *
gboolean xfce_panel_plugin_get_deskbar_mode (XfcePanelPlugin *plugin) G_GNUC_PURE;
+gboolean xfce_panel_plugin_get_small (XfcePanelPlugin *plugin) G_GNUC_PURE;
+
+void xfce_panel_plugin_set_small (XfcePanelPlugin *plugin,
+ gboolean small);
+
gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin) G_GNUC_PURE;
void xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin,
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 0b69b52..53222a7 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -614,6 +614,16 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
panel_application_plugin_move (GTK_WIDGET (provider), application);
break;
+ case PROVIDER_SIGNAL_SMALL_PLUGIN:
+ case PROVIDER_SIGNAL_NOT_SMALL_PLUGIN:
+ itembar = gtk_bin_get_child (GTK_BIN (window));
+ gtk_container_child_set (GTK_CONTAINER (itembar),
+ GTK_WIDGET (provider),
+ "small",
+ provider_signal == PROVIDER_SIGNAL_SMALL_PLUGIN,
+ NULL);
+ break;
+
case PROVIDER_SIGNAL_EXPAND_PLUGIN:
case PROVIDER_SIGNAL_COLLAPSE_PLUGIN:
itembar = gtk_bin_get_child (GTK_BIN (window));
diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c
index e8b5cd7..8b65182 100644
--- a/panel/panel-itembar.c
+++ b/panel/panel-itembar.c
@@ -100,6 +100,7 @@ struct _PanelItembarChild
GtkWidget *widget;
guint expand : 1;
guint shrink : 1;
+ guint small : 1;
guint wrap : 1;
};
@@ -117,6 +118,7 @@ enum
CHILD_PROP_0,
CHILD_PROP_EXPAND,
CHILD_PROP_SHRINK,
+ CHILD_PROP_SMALL,
CHILD_PROP_WRAP
};
@@ -196,6 +198,14 @@ panel_itembar_class_init (PanelItembarClass *klass)
NULL, NULL,
FALSE,
EXO_PARAM_WRITABLE));
+
+ gtk_container_class_install_child_property (gtkcontainer_class,
+ CHILD_PROP_SMALL,
+ g_param_spec_boolean ("small",
+ NULL, NULL,
+ FALSE,
+ EXO_PARAM_READWRITE));
+
gtk_container_class_install_child_property (gtkcontainer_class,
CHILD_PROP_EXPAND,
g_param_spec_boolean ("expand",
@@ -693,6 +703,13 @@ panel_itembar_set_child_property (GtkContainer *container,
switch (prop_id)
{
+ case CHILD_PROP_SMALL:
+ boolean = g_value_get_boolean (value);
+ if (child->small == boolean)
+ return;
+ child->small = boolean;
+ break;
+
case CHILD_PROP_EXPAND:
boolean = g_value_get_boolean (value);
if (child->expand == boolean)
@@ -739,6 +756,10 @@ panel_itembar_get_child_property (GtkContainer *container,
switch (prop_id)
{
+ case CHILD_PROP_SMALL:
+ g_value_set_boolean (value, child->small);
+ break;
+
case CHILD_PROP_EXPAND:
g_value_set_boolean (value, child->expand);
break;
More information about the Xfce4-commits
mailing list