Browse Source

Add option on Xinerama systems to make panel span across monitors

(Old svn revision: 19530)
upstream/xfce4-panel-4.10.1
Jasper Huijsmans 17 years ago
parent
commit
7b7e5ac633
  1. 14
      panel/panel-config.c
  2. 81
      panel/panel-dialogs.c
  3. 10
      panel/panel-private.h
  4. 127
      panel/panel-properties.c
  5. 2
      panel/panel-properties.h

14
panel/panel-config.c

@ -209,7 +209,7 @@ struct _ConfigParser
int size;
int monitor;
int screen_position;
gboolean full_width;
int full_width;
int xoffset;
int yoffset;
int handle_style;
@ -226,7 +226,7 @@ init_properties (ConfigParser *parser)
parser->size = DEFAULT_SIZE;
parser->monitor = 0;
parser->screen_position = DEFAULT_SCREEN_POSITION;
parser->full_width = FALSE;
parser->full_width = XFCE_PANEL_NORMAL_WIDTH;
parser->xoffset = 0;
parser->yoffset = 0;
parser->handle_style = XFCE_HANDLE_STYLE_NONE;
@ -257,7 +257,7 @@ config_set_property (ConfigParser *parser,
}
else if (strcmp (name, "fullwidth") == 0)
{
parser->full_width = ((int) strtol (value, NULL, 0) == 1);
parser->full_width = ((int) strtol (value, NULL, 0));
}
else if (strcmp (name, "xoffset") == 0)
{
@ -634,8 +634,8 @@ config_save_to_file (GPtrArray *array, const char *filename)
{
Panel *panel;
int size, monitor, screen_position, xoffset, yoffset, handle_style,
transparency, j;
gboolean autohide, fullwidth;
transparency, fullwidth, j;
gboolean autohide;
XfcePanelItemConfig *configlist;
DBG ("Saving panel %d", i + 1);
@ -643,8 +643,8 @@ config_save_to_file (GPtrArray *array, const char *filename)
panel = g_ptr_array_index (array, i);
size = monitor = screen_position = xoffset = yoffset =
transparency = 0;
autohide = fullwidth = FALSE;
transparency = fullwidth = 0;
autohide = FALSE;
g_object_get (G_OBJECT (panel),
"size", &size,

81
panel/panel-dialogs.c

@ -95,6 +95,7 @@ struct _PanelManagerDialog
GtkWidget *fixed_box;
GtkWidget *screen_position[12];
GtkWidget *fullwidth;
int n_width_items;
GtkWidget *autohide;
GtkWidget *floating_box;
@ -175,7 +176,6 @@ present_dialog (GtkWidget *dialog, GPtrArray *panels)
gtk_window_present (GTK_WINDOW (dialog));
}
/*
* Add Items Dialog
* ================
@ -661,10 +661,19 @@ add_items_dialog (GPtrArray *panels, GtkWidget *active_item)
* ====================
*/
/* Update properties */
static gboolean
can_span_monitors (Panel *panel)
{
return ( (panel_app_monitors_equal_height () &&
panel_is_horizontal (panel))
|| (panel_app_monitors_equal_width () &&
!panel_is_horizontal (panel)) );
}
/* Update widgets */
static void
update_properties (PanelManagerDialog *pmd)
update_widgets (PanelManagerDialog *pmd)
{
PanelPrivate *priv = PANEL_GET_PRIVATE (pmd->panel);
int i;
@ -694,8 +703,6 @@ update_properties (PanelManagerDialog *pmd)
priv->autohide);
/* position */
DBG ("position: %d", priv->screen_position);
if (!xfce_screen_position_is_floating (priv->screen_position))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pmd->fixed), TRUE);
@ -710,8 +717,8 @@ update_properties (PanelManagerDialog *pmd)
(int)priv->screen_position == i+1);
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pmd->fullwidth),
priv->full_width);
gtk_combo_box_set_active (GTK_COMBO_BOX (pmd->fullwidth),
priv->full_width);
}
else
{
@ -798,7 +805,7 @@ type_changed (GtkToggleButton *tb, PanelManagerDialog *pmd)
gtk_widget_queue_draw (GTK_WIDGET (pmd->panel));
update_properties (pmd);
update_widgets (pmd);
}
static gboolean
@ -818,7 +825,7 @@ screen_position_pressed (GtkToggleButton *tb, GdkEvent *ev,
(((GdkEventKey *)ev)->keyval == GDK_space ||
((GdkEventKey *)ev)->keyval == GDK_Return)))
{
int i;
int i, full_width;
for (i = 0; i < 12; ++i)
{
@ -829,7 +836,36 @@ screen_position_pressed (GtkToggleButton *tb, GdkEvent *ev,
{
gtk_toggle_button_set_active (button, TRUE);
panel_set_screen_position (pmd->panel, i + 1);
}
/* fix up full width setting */
full_width = gtk_combo_box_get_active (
GTK_COMBO_BOX (pmd->fullwidth));
for ( ; pmd->n_width_items > 0; pmd->n_width_items--)
{
gtk_combo_box_remove_text (
GTK_COMBO_BOX (pmd->fullwidth),
pmd->n_width_items - 1);
}
gtk_combo_box_append_text (GTK_COMBO_BOX (pmd->fullwidth),
_("Normal Width"));
gtk_combo_box_append_text (GTK_COMBO_BOX (pmd->fullwidth),
_("Full Width"));
pmd->n_width_items = 2;
if (can_span_monitors(pmd->panel))
{
gtk_combo_box_append_text (
GTK_COMBO_BOX (pmd->fullwidth),
_("Span Monitors"));
pmd->n_width_items = 3;
}
full_width = MIN(pmd->n_width_items - 1, full_width);
panel_set_full_width (pmd->panel, full_width);
gtk_combo_box_set_active (GTK_COMBO_BOX (pmd->fullwidth),
full_width);
}
else
{
gtk_toggle_button_set_active (button, FALSE);
@ -842,12 +878,12 @@ screen_position_pressed (GtkToggleButton *tb, GdkEvent *ev,
}
static void
fullwidth_changed (GtkToggleButton *tb, PanelManagerDialog *pmd)
fullwidth_changed (GtkComboBox *box, PanelManagerDialog *pmd)
{
if (pmd->updating)
return;
panel_set_full_width (pmd->panel, gtk_toggle_button_get_active (tb));
panel_set_full_width (pmd->panel, gtk_combo_box_get_active (box));
}
static void
@ -1031,12 +1067,23 @@ add_position_options (GtkBox *box, PanelManagerDialog *pmd)
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (pmd->fixed_box), vbox, TRUE, TRUE, 0);
pmd->fullwidth =
gtk_check_button_new_with_mnemonic (_("_Full Width"));
pmd->fullwidth = gtk_combo_box_new_text ();
gtk_widget_show (pmd->fullwidth);
gtk_box_pack_start (GTK_BOX (vbox), pmd->fullwidth, FALSE, FALSE, 0);
g_signal_connect (pmd->fullwidth, "toggled",
gtk_combo_box_append_text (GTK_COMBO_BOX (pmd->fullwidth),
_("Normal Width"));
gtk_combo_box_append_text (GTK_COMBO_BOX (pmd->fullwidth),
_("Full Width"));
pmd->n_width_items = 2;
if (can_span_monitors (pmd->panel))
{
pmd->n_width_items = 3;
gtk_combo_box_append_text (GTK_COMBO_BOX (pmd->fullwidth),
_("Span Monitors"));
}
g_signal_connect (pmd->fullwidth, "changed",
G_CALLBACK (fullwidth_changed), pmd);
/* fixed:autohide */
@ -1362,7 +1409,7 @@ panel_selected (GtkComboBox * combo, PanelManagerDialog * pmd)
pmd->current = n;
pmd->panel = g_ptr_array_index (pmd->panels, n);
update_properties (pmd);
update_widgets (pmd);
highlight_widget (GTK_WIDGET (pmd->panel), pmd);
}
@ -1604,7 +1651,7 @@ panel_manager_dialog (GPtrArray *panels)
pmd->updating = FALSE;
/* fill in values */
update_properties (pmd);
update_widgets (pmd);
/* setup panels */
g_ptr_array_foreach (pmd->panels, (GFunc)panel_block_autohide, NULL);

10
panel/panel-private.h

@ -43,6 +43,14 @@
typedef struct _PanelPrivate PanelPrivate;
typedef enum
{
XFCE_PANEL_NORMAL_WIDTH,
XFCE_PANEL_FULL_WIDTH,
XFCE_PANEL_SPAN_MONITORS,
}
XfcePanelWidthType;
struct _PanelPrivate
{
GtkWidget *itembar;
@ -54,7 +62,7 @@ struct _PanelPrivate
int xoffset;
int yoffset;
guint autohide:1;
guint full_width:1;
XfcePanelWidthType full_width;
int transparency;
guint opacity;

127
panel/panel-properties.c

@ -385,24 +385,23 @@ panel_set_position (Panel *panel, XfceScreenPosition position,
yoffset -= xmon->geometry.y;
}
if (priv->full_width)
switch (priv->full_width)
{
xoffset = yoffset = 0;
if (xfce_screen_position_is_horizontal (position))
{
if (panel_app_monitors_equal_height ())
case XFCE_PANEL_NORMAL_WIDTH:
x += xoffset;
y += yoffset;
break;
case XFCE_PANEL_SPAN_MONITORS:
if (xfce_screen_position_is_horizontal (position))
x = 0;
}
else
{
if (panel_app_monitors_equal_width ())
else
y = 0;
}
}
else
{
x += xoffset;
y += yoffset;
/* fall through */
case XFCE_PANEL_FULL_WIDTH:
xoffset = yoffset = 0;
break;
}
priv->xoffset = xoffset;
@ -499,27 +498,33 @@ _set_hidden (Panel *panel, gboolean hide)
xmon = panel_app_get_monitor (priv->monitor);
if (!priv->full_width)
{
w = h = -1;
}
else if (xfce_screen_position_is_horizontal (priv->screen_position))
{
if (!panel_app_monitors_equal_height ())
w = xmon->geometry.width;
else
w = gdk_screen_get_width (xmon->screen);
h = -1;
}
else
switch (priv->full_width)
{
w = -1;
if (!panel_app_monitors_equal_width ())
h = xmon->geometry.height;
else
h = gdk_screen_get_height (xmon->screen);
case XFCE_PANEL_NORMAL_WIDTH:
w = h = -1;
break;
case XFCE_PANEL_FULL_WIDTH:
case XFCE_PANEL_SPAN_MONITORS:
if (xfce_screen_position_is_horizontal (priv->screen_position))
{
h = -1;
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
w = xmon->geometry.width;
else
w = gdk_screen_get_width (xmon->screen);
}
else
{
w = -1;
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
h = xmon->geometry.height;
else
h = gdk_screen_get_height (xmon->screen);
}
break;
}
gtk_widget_show (priv->itembar);
gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
}
@ -670,13 +675,13 @@ panel_init_position (Panel *panel)
g_signal_connect (xmon->screen, "size-changed",
G_CALLBACK (panel_screen_size_changed), panel);
if (priv->full_width)
if (priv->full_width > XFCE_PANEL_NORMAL_WIDTH)
{
if (xfce_screen_position_is_horizontal (priv->screen_position))
{
int w;
if (!panel_app_monitors_equal_height ())
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
w = xmon->geometry.width;
else
w = gdk_screen_get_width (xmon->screen);
@ -687,7 +692,7 @@ panel_init_position (Panel *panel)
{
int h;
if (!panel_app_monitors_equal_width ())
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
h = xmon->geometry.height;
else
h = gdk_screen_get_height (xmon->screen);
@ -832,7 +837,7 @@ void panel_unblock_autohide (Panel *panel)
}
void
panel_set_full_width (Panel *panel, gboolean fullwidth)
panel_set_full_width (Panel *panel, int fullwidth)
{
PanelPrivate *priv;
@ -849,28 +854,34 @@ panel_set_full_width (Panel *panel, gboolean fullwidth)
xmon = panel_app_get_monitor (priv->monitor);
if (!priv->full_width)
switch (priv->full_width)
{
w = h = -1;
case XFCE_PANEL_NORMAL_WIDTH:
w = h = -1;
break;
case XFCE_PANEL_FULL_WIDTH:
case XFCE_PANEL_SPAN_MONITORS:
if (xfce_screen_position_is_horizontal (
priv->screen_position))
{
h = -1;
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
w = xmon->geometry.width;
else
w = gdk_screen_get_width (xmon->screen);
}
else
{
w = -1;
if (priv->full_width == XFCE_PANEL_FULL_WIDTH)
h = xmon->geometry.height;
else
h = gdk_screen_get_height (xmon->screen);
}
break;
}
else if (xfce_screen_position_is_horizontal (
priv->screen_position))
{
if (!panel_app_monitors_equal_height())
w = xmon->geometry.width;
else
w = gdk_screen_get_width (xmon->screen);
h = -1;
}
else
{
w = -1;
if (!panel_app_monitors_equal_width())
h = xmon->geometry.height;
else
h = gdk_screen_get_height (xmon->screen);
}
gtk_widget_set_size_request (GTK_WIDGET (panel), w, h);
panel_set_position (panel, priv->screen_position,

2
panel/panel-properties.h

@ -68,7 +68,7 @@ void panel_block_autohide (Panel *panel);
void panel_unblock_autohide (Panel *panel);
void panel_set_full_width (Panel *panel,
gboolean fullwidth);
int fullwidth);
void panel_set_transparency (Panel *panel,
int transparency);

Loading…
Cancel
Save