[Xfce4-commits] <xfce4-panel:nick/gtk3> Revert "Launcher: reworked sizing mechanism."
Andrzej
noreply at xfce.org
Wed Apr 17 22:16:03 CEST 2013
Updating branch refs/heads/nick/gtk3
to 197a1314279c79886d9d8887e8e673afbf5f45b0 (commit)
from f08482bfe0e0dbe5d6f114dc32b992491223202e (commit)
commit 197a1314279c79886d9d8887e8e673afbf5f45b0
Author: Andrzej <ndrwrdck at gmail.com>
Date: Wed Apr 17 20:13:15 2013 +0100
Revert "Launcher: reworked sizing mechanism."
This reverts commit c261aaa548b99d7facc09f4d7b58773e2b82766d.
plugins/launcher/launcher.c | 130 ++++++++++++++++++++++---------------------
1 files changed, 66 insertions(+), 64 deletions(-)
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index f591e8c..7f7e627 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -59,12 +59,6 @@ static void launcher_plugin_set_property (GObject
GParamSpec *pspec);
static void launcher_plugin_construct (XfcePanelPlugin *panel_plugin);
static void launcher_plugin_free_data (XfcePanelPlugin *panel_plugin);
-static void launcher_plugin_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static void launcher_plugin_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height);
static void launcher_plugin_removed (XfcePanelPlugin *panel_plugin);
static gboolean launcher_plugin_remote_event (XfcePanelPlugin *panel_plugin,
const gchar *name,
@@ -73,6 +67,8 @@ static gboolean launcher_plugin_save_delayed_timeout (gpointe
static void launcher_plugin_save_delayed (LauncherPlugin *plugin);
static void launcher_plugin_mode_changed (XfcePanelPlugin *panel_plugin,
XfcePanelPluginMode mode);
+static gboolean launcher_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size);
static void launcher_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
static void launcher_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
XfceScreenPosition position);
@@ -263,20 +259,16 @@ launcher_plugin_class_init (LauncherPluginClass *klass)
{
GObjectClass *gobject_class;
XfcePanelPluginClass *plugin_class;
- GtkWidgetClass *gtkwidget_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = launcher_plugin_get_property;
gobject_class->set_property = launcher_plugin_set_property;
- gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->get_preferred_width = launcher_plugin_get_preferred_width;
- gtkwidget_class->get_preferred_height = launcher_plugin_get_preferred_height;
-
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = launcher_plugin_construct;
plugin_class->free_data = launcher_plugin_free_data;
plugin_class->mode_changed = launcher_plugin_mode_changed;
+ plugin_class->size_changed = launcher_plugin_size_changed;
plugin_class->configure_plugin = launcher_plugin_configure_plugin;
plugin_class->screen_position_changed = launcher_plugin_screen_position_changed;
plugin_class->removed = launcher_plugin_removed;
@@ -887,6 +879,10 @@ launcher_plugin_set_property (GObject *object,
gtk_container_add (GTK_CONTAINER (plugin->button), plugin->child);
gtk_widget_show (plugin->child);
+ /* update size */
+ launcher_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
+ xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
+
/* update the button */
launcher_plugin_button_update (plugin);
break;
@@ -900,6 +896,10 @@ update_arrow:
/* repack the widgets */
launcher_plugin_pack_widgets (plugin);
+
+ /* update the plugin size */
+ launcher_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
+ xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
break;
default:
@@ -1244,74 +1244,76 @@ launcher_plugin_mode_changed (XfcePanelPlugin *panel_plugin,
/* update the arrow button */
launcher_plugin_screen_position_changed (panel_plugin,
xfce_panel_plugin_get_screen_position (panel_plugin));
+
+ /* update the plugin size */
+ launcher_plugin_size_changed (panel_plugin,
+ xfce_panel_plugin_get_size (panel_plugin));
}
-static void
-launcher_plugin_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+static gboolean
+launcher_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size)
{
- XfcePanelPlugin *panel_plugin = XFCE_PANEL_PLUGIN (widget);
- LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (widget);
- XfcePanelPluginMode mode;
- gint size;
+ LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin);
+ gint p_width, p_height;
+ gint a_width, a_height;
+ gboolean horizontal;
+ LauncherArrowType arrow_position;
- mode = xfce_panel_plugin_get_mode (XFCE_PANEL_PLUGIN (plugin));
+ /* initialize the plugin size */
+ size /= xfce_panel_plugin_get_nrows (panel_plugin);
+ p_width = p_height = size;
+ a_width = a_height = -1;
- if (G_UNLIKELY (plugin->show_label && mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR))
- {
- size = xfce_panel_plugin_get_size (panel_plugin);
- }
- else if (G_UNLIKELY (plugin->show_label && mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL))
+ /* add the arrow size */
+ if (gtk_widget_get_visible (plugin->arrow))
{
- gtk_widget_get_preferred_width (GTK_WIDGET (plugin->box), minimum_width, natural_width);
- return;
- }
- else
- {
- size = xfce_panel_plugin_get_size (panel_plugin) / xfce_panel_plugin_get_nrows (panel_plugin);
- }
-
- if (minimum_width != NULL)
- *minimum_width = size;
-
- if (natural_width != NULL)
- *natural_width = size;
-}
-
-
+ /* if the panel is horizontal */
+ horizontal = !!(xfce_panel_plugin_get_orientation (panel_plugin) ==
+ GTK_ORIENTATION_HORIZONTAL);
+ /* translate default direction */
+ arrow_position = launcher_plugin_default_arrow_type (plugin);
-static void
-launcher_plugin_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- XfcePanelPlugin *panel_plugin = XFCE_PANEL_PLUGIN (widget);
- LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (widget);
- XfcePanelPluginMode mode;
- gint size;
+ switch (arrow_position)
+ {
+ case LAUNCHER_ARROW_NORTH:
+ case LAUNCHER_ARROW_SOUTH:
+ a_height = ARROW_BUTTON_SIZE;
+ if (horizontal)
+ p_width -= ARROW_BUTTON_SIZE;
+ else
+ p_height += ARROW_BUTTON_SIZE;
+ break;
+
+ case LAUNCHER_ARROW_EAST:
+ case LAUNCHER_ARROW_WEST:
+ a_width = ARROW_BUTTON_SIZE;
+ if (horizontal)
+ p_width += ARROW_BUTTON_SIZE;
+ else
+ p_height -= ARROW_BUTTON_SIZE;
+ break;
- mode = xfce_panel_plugin_get_mode (XFCE_PANEL_PLUGIN (plugin));
+ default:
+ /* the default position should never be returned */
+ panel_assert_not_reached ();
+ break;
+ }
- if (G_UNLIKELY (plugin->show_label && mode != XFCE_PANEL_PLUGIN_MODE_HORIZONTAL))
- {
- gtk_widget_get_preferred_height (GTK_WIDGET (plugin->box), minimum_height, natural_height);
- return;
+ /* set the arrow size */
+ gtk_widget_set_size_request (plugin->arrow, a_width, a_height);
}
- else
- {
- size = xfce_panel_plugin_get_size (panel_plugin) / xfce_panel_plugin_get_nrows (panel_plugin);
- }
-
- if (minimum_height != NULL)
- *minimum_height = size;
+ /* set the panel plugin size */
+ if (plugin->show_label)
+ gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), -1, -1);
+ else
+ gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), p_width, p_height);
- if (natural_height != NULL)
- *natural_height = size;
+ return TRUE;
}
More information about the Xfce4-commits
mailing list