Browse Source

Add small property for plugins.

This properly will be used to pack a plugin only on a single row instead
of the whole panel height.
tags/xfce4-panel-4.10.0
Andrzej Nick Schermer 10 years ago
parent
commit
a2a8232e2f
5 changed files with 128 additions and 1 deletions
  1. +2
    -0
      libxfce4panel/xfce-panel-plugin-provider.h
  2. +90
    -0
      libxfce4panel/xfce-panel-plugin.c
  3. +5
    -0
      libxfce4panel/xfce-panel-plugin.h
  4. +10
    -0
      panel/panel-application.c
  5. +21
    -1
      panel/panel-itembar.c

+ 2
- 0
libxfce4panel/xfce-panel-plugin-provider.h View File

@@ -81,6 +81,8 @@ typedef enum /*< skip >*/
PROVIDER_SIGNAL_COLLAPSE_PLUGIN,
PROVIDER_SIGNAL_WRAP_PLUGIN,
PROVIDER_SIGNAL_UNWRAP_PLUGIN,
PROVIDER_SIGNAL_SMALL_PLUGIN,
PROVIDER_SIGNAL_UNSMALL_PLUGIN,
PROVIDER_SIGNAL_LOCK_PANEL,
PROVIDER_SIGNAL_UNLOCK_PANEL,
PROVIDER_SIGNAL_REMOVE_PLUGIN,


+ 90
- 0
libxfce4panel/xfce-panel-plugin.c View File

@@ -126,6 +126,7 @@ enum
PROP_UNIQUE_ID,
PROP_ORIENTATION,
PROP_SIZE,
PROP_SMALL,
PROP_SCREEN_POSITION,
PROP_EXPAND,
PROP_MODE,
@@ -174,6 +175,7 @@ struct _XfcePanelPluginPrivate
guint shrink : 1;
guint nrows;
XfcePanelPluginMode mode;
guint small : 1;
XfceScreenPosition screen_position;
guint locked : 1;
GSList *menu_items;
@@ -594,6 +596,24 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
G_PARAM_READABLE
| 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:
*
@@ -679,6 +699,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->property_base = NULL;
plugin->priv->arguments = NULL;
plugin->priv->size = 0;
plugin->priv->small = FALSE;
plugin->priv->expand = FALSE;
plugin->priv->shrink = FALSE;
plugin->priv->mode = XFCE_PANEL_PLUGIN_MODE_HORIZONTAL;
@@ -781,6 +802,14 @@ xfce_panel_plugin_get_property (GObject *object,
g_value_set_int (value, private->size);
break;

case PROP_NROWS:
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;
@@ -840,6 +869,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));
@@ -1856,6 +1890,62 @@ xfce_panel_plugin_set_shrink (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_UNSMALL_PLUGIN);

g_object_notify (G_OBJECT (plugin), "small");
}
}



/**
* xfce_panel_plugin_get_mode:


+ 5
- 0
libxfce4panel/xfce-panel-plugin.h View File

@@ -182,6 +182,11 @@ gboolean xfce_panel_plugin_get_shrink (XfcePanelPlugin *
void xfce_panel_plugin_set_shrink (XfcePanelPlugin *plugin,
gboolean shrink);

gboolean xfce_panel_plugin_get_small (XfcePanelPlugin *plugin) G_GNUC_PURE;

void xfce_panel_plugin_set_small (XfcePanelPlugin *plugin,
gboolean small);

GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin) G_GNUC_PURE;

XfcePanelPluginMode xfce_panel_plugin_get_mode (XfcePanelPlugin *plugin) G_GNUC_PURE;


+ 10
- 0
panel/panel-application.c View File

@@ -643,6 +643,16 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
NULL);
break;

case PROVIDER_SIGNAL_SMALL_PLUGIN:
case PROVIDER_SIGNAL_UNSMALL_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_LOCK_PANEL:
/* increase window's autohide counter */
panel_window_freeze_autohide (window);


+ 21
- 1
panel/panel-itembar.c View File

@@ -102,6 +102,7 @@ struct _PanelItembarChild
guint expand : 1;
guint shrink : 1;
guint wrap : 1;
guint small : 1;
};

enum
@@ -117,7 +118,8 @@ enum
CHILD_PROP_0,
CHILD_PROP_EXPAND,
CHILD_PROP_SHRINK,
CHILD_PROP_WRAP
CHILD_PROP_WRAP,
CHILD_PROP_SMALL
};

enum
@@ -211,6 +213,13 @@ panel_itembar_class_init (PanelItembarClass *klass)
NULL, NULL,
FALSE,
EXO_PARAM_READWRITE));

gtk_container_class_install_child_property (gtkcontainer_class,
CHILD_PROP_SMALL,
g_param_spec_boolean ("small",
NULL, NULL,
FALSE,
EXO_PARAM_READWRITE));
}


@@ -704,6 +713,13 @@ panel_itembar_set_child_property (GtkContainer *container,
child->wrap = boolean;
break;

case CHILD_PROP_SMALL:
boolean = g_value_get_boolean (value);
if (child->small == boolean)
return;
child->small = boolean;
break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (container, prop_id, pspec);
break;
@@ -741,6 +757,10 @@ panel_itembar_get_child_property (GtkContainer *container,
g_value_set_boolean (value, child->wrap);
break;

case CHILD_PROP_SMALL:
g_value_set_boolean (value, child->small);
break;

default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (container, prop_id, pspec);
break;


Loading…
Cancel
Save