[Xfce4-commits] <xfce4-wmdock-plugin:0.6.x> Added alignment options for the panel off mode. Integrated the new anchor postions.
Andre Ellguth
noreply at xfce.org
Fri Sep 20 18:44:01 CEST 2013
Updating branch refs/heads/0.6.x
to a5a23d4397b58043b04917f9139adbf66735f624 (commit)
from 62926768568bf222739c07aebc2480f4895a36b2 (commit)
commit a5a23d4397b58043b04917f9139adbf66735f624
Author: Andre Ellguth <andre at ellguth.com>
Date: Fri Sep 20 18:41:05 2013 +0200
Added alignment options for the panel off mode.
Integrated the new anchor postions.
panel-plugin/catchwindow.c | 2 +-
panel-plugin/dockapp.c | 182 ++++++++++++++++++++++++--------------------
panel-plugin/misc.c | 44 +++++++++++
panel-plugin/misc.h | 1 +
panel-plugin/props.c | 37 +++++++--
panel-plugin/wmdock.c | 2 +-
panel-plugin/wmdock.h | 9 ++-
7 files changed, 186 insertions(+), 91 deletions(-)
diff --git a/panel-plugin/catchwindow.c b/panel-plugin/catchwindow.c
index 0daf78d..e12ef92 100644
--- a/panel-plugin/catchwindow.c
+++ b/panel-plugin/catchwindow.c
@@ -236,7 +236,7 @@ void wmdock_window_open(WnckScreen *s, WnckWindow *w)
_dapps = g_list_find(wmdock->dapps, (gconstpointer) dapp);
wmdock_set_autoposition_dockapp( dapp,
(DOCKAPP(g_list_first(wmdock->dapps)->data) != dapp && _dapps) ?
- DOCKAPP(g_list_previous(_dapps)->data) : NULL);
+ DOCKAPP(((GList *) g_list_previous(_dapps))->data) : NULL);
wmdock_order_dockapps(DOCKAPP(g_list_first(wmdock->dapps)->data));
}
diff --git a/panel-plugin/dockapp.c b/panel-plugin/dockapp.c
index 4ba8f43..06eac91 100644
--- a/panel-plugin/dockapp.c
+++ b/panel-plugin/dockapp.c
@@ -149,7 +149,7 @@ static DockappNode *wmdock_get_primary_anchor_dockapp()
*/
static DockappNode *wmdock_get_snapable_dockapp(DockappNode *dapp, gint *gluepos)
{
- #define SNAPDELTA (DEFAULT_DOCKAPP_HEIGHT/2)-1
+#define SNAPDELTA (DEFAULT_DOCKAPP_HEIGHT/2)-1
gint posx, posy, gluex, gluey;
gint possible = GLUE_T | GLUE_B | GLUE_L | GLUE_R;
gboolean prim;
@@ -159,26 +159,18 @@ static DockappNode *wmdock_get_snapable_dockapp(DockappNode *dapp, gint *gluepos
prim = (dapp == wmdock_get_primary_anchor_dockapp()) ? TRUE : FALSE;
switch(wmdock->anchorPos) {
- /* Remove not possible snap positions. */
- case XFCE_SCREEN_POSITION_NW_H:
- case XFCE_SCREEN_POSITION_N:
- case XFCE_SCREEN_POSITION_NE_H:
+ /* Remove not possible snap positions for the first dockapp. */
+ case ANCHOR_TR:
possible^= prim == TRUE ? (GLUE_T | GLUE_L | GLUE_R) : 0;
break;
- case XFCE_SCREEN_POSITION_SW_H:
- case XFCE_SCREEN_POSITION_S:
- case XFCE_SCREEN_POSITION_SE_H:
+ case ANCHOR_BR:
possible^= prim == TRUE ? (GLUE_B | GLUE_L | GLUE_R): 0;
break;
- case XFCE_SCREEN_POSITION_NW_V:
- case XFCE_SCREEN_POSITION_W:
- case XFCE_SCREEN_POSITION_SW_V:
- possible^= prim == TRUE ? (GLUE_B | GLUE_T | GLUE_L) : 0;
+ case ANCHOR_TL:
+ possible^= prim == TRUE ? (GLUE_T | GLUE_L | GLUE_R) : 0;
break;
- case XFCE_SCREEN_POSITION_NE_V:
- case XFCE_SCREEN_POSITION_E:
- case XFCE_SCREEN_POSITION_SE_V:
- possible^= prim == TRUE ? (GLUE_B | GLUE_T | GLUE_R) : 0;
+ case ANCHOR_BL:
+ possible^= prim == TRUE ? (GLUE_B | GLUE_L | GLUE_R) : 0;
break;
}
@@ -403,7 +395,7 @@ GtkWidget *wmdock_create_tile_dummy()
gtk_window_set_skip_pager_hint(GTK_WINDOW(dummy), TRUE);
gtk_window_set_opacity(GTK_WINDOW(dummy), 0.6);
gtk_widget_set_size_request(dummy, DEFAULT_DOCKAPP_WIDTH, DEFAULT_DOCKAPP_HEIGHT);
-// gtk_window_set_type_hint(GTK_WINDOW(dummy), GDK_WINDOW_TYPE_HINT_DND);
+ // gtk_window_set_type_hint(GTK_WINDOW(dummy), GDK_WINDOW_TYPE_HINT_DND);
return (dummy);
}
@@ -787,7 +779,8 @@ GtkWidget *wmdock_create_tile_from_socket(DockappNode *dapp)
void wmdock_set_autoposition_dockapp(DockappNode *dapp, DockappNode *prevDapp)
{
gint panelx, panely, plugx, plugy;
- gint x, y, i, gluepos = GLUE_MAX;
+ gint x, y, i, offsetx, offsety, gluepos = GLUE_MAX;
+ XfceScreenPosition xfceScrPos;
if(!IS_PANELOFF(wmdock))
return;
@@ -800,78 +793,103 @@ void wmdock_set_autoposition_dockapp(DockappNode *dapp, DockappNode *prevDapp)
&panelx, &panely);
gdk_window_get_position (GDK_WINDOW (GTK_WIDGET (wmdock->plugin)->window), &plugx, &plugy);
- /* Initial define the position of the first anchor dockapp. */
- if(wmdock->anchorPos == -1)
- wmdock->anchorPos = xfce_panel_plugin_get_screen_position(wmdock->plugin);
-
- if(prevDapp) {
- for(i = 0; i < GLUE_MAX; i++) {
- if(prevDapp->glue[i] == dapp) {
- gluepos = i;
- break;
- }
+ for(i = 0; prevDapp && i < GLUE_MAX; i++) {
+ if(prevDapp->glue[i] == dapp) {
+ gluepos = i;
+ break;
}
}
if(gluepos != GLUE_MAX) {
+ /* Realign the existing dockapp. */
wmdock_dockapp_child_pos(prevDapp, gluepos, &x, &y);
} else {
- /* Determine the initial dockapp position. */
- switch(wmdock->anchorPos) {
- case XFCE_SCREEN_POSITION_NW_H:
- case XFCE_SCREEN_POSITION_N:
- case XFCE_SCREEN_POSITION_NE_H:
- if(!prevDapp) {
- /* From the top to the bottom. */
- x = wmdock->anchorPos == XFCE_SCREEN_POSITION_NW_H ? gdk_screen_get_width(get_current_gdkscreen()) - DEFAULT_DOCKAPP_WIDTH : 0;
- y = panelx == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
- } else {
- wmdock_dockapp_child_pos(prevDapp, GLUE_B, &x, &y);
- prevDapp->glue[GLUE_B] = dapp;
- }
- break;
+ /* Align a new dockapp. */
+ if(prevDapp) {
+ /* If a parent dockapp already exists. */
+ if(wmdock->anchorPos == ANCHOR_TL || wmdock->anchorPos == ANCHOR_TR)
+ gluepos = GLUE_B;
+ else
+ gluepos = GLUE_T;
+
+ wmdock_dockapp_child_pos(prevDapp, gluepos, &x, &y);
+ prevDapp->glue[gluepos] = dapp;
+ } else {
+ /* Determine the initial dockapp position. */
+ xfceScrPos = xfce_panel_plugin_get_screen_position(wmdock->plugin);
+
+ offsetx = offsety = 0;
+ switch(wmdock->anchorPos) {
+ case ANCHOR_TL:
+ if(xfceScrPos == XFCE_SCREEN_POSITION_NW_V ||
+ xfceScrPos == XFCE_SCREEN_POSITION_W ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SW_V) {
+ offsetx = panelx == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
+ offsety = 0;
+ } else if (xfceScrPos == XFCE_SCREEN_POSITION_NW_H ||
+ xfceScrPos == XFCE_SCREEN_POSITION_N ||
+ xfceScrPos == XFCE_SCREEN_POSITION_NE_H) {
+ offsetx = 0;
+ offsety = panely == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
+ }
- case XFCE_SCREEN_POSITION_SW_H:
- case XFCE_SCREEN_POSITION_S:
- case XFCE_SCREEN_POSITION_SE_H:
- if(!prevDapp) {
- /* From the bottom to the top. */
- x = wmdock->anchorPos == XFCE_SCREEN_POSITION_SW_H ? gdk_screen_get_width(get_current_gdkscreen()) - DEFAULT_DOCKAPP_WIDTH : 0;
- y = panelx == 0 ? panely - DEFAULT_DOCKAPP_HEIGHT : gdk_screen_get_height(get_current_gdkscreen()) - DEFAULT_DOCKAPP_HEIGHT;
- } else {
- wmdock_dockapp_child_pos(prevDapp, GLUE_T, &x, &y);
- prevDapp->glue[GLUE_T] = dapp;
- }
- break;
- case XFCE_SCREEN_POSITION_NW_V:
- case XFCE_SCREEN_POSITION_W:
- case XFCE_SCREEN_POSITION_SW_V:
- if(!prevDapp) {
- /* From the left to the right. */
- x = panely == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
- y = panely == 0 ? 0 : gdk_screen_get_height(get_current_gdkscreen()) - DEFAULT_DOCKAPP_HEIGHT;
- } else {
- wmdock_dockapp_child_pos(prevDapp, GLUE_R, &x, &y);
- prevDapp->glue[GLUE_R] = dapp;
- }
- break;
- case XFCE_SCREEN_POSITION_NE_V:
- case XFCE_SCREEN_POSITION_E:
- case XFCE_SCREEN_POSITION_SE_V:
- if(!prevDapp) {
- /* From the top to the bottom. */
- x = panely == 0 ? gdk_screen_get_width(get_current_gdkscreen()) - xfce_panel_plugin_get_size(wmdock->plugin) - DEFAULT_DOCKAPP_WIDTH : gdk_screen_get_width(get_current_gdkscreen()) - DEFAULT_DOCKAPP_WIDTH;
- y = panely == 0 ? 0 : gdk_screen_get_height(get_current_gdkscreen()) - DEFAULT_DOCKAPP_HEIGHT;
- } else {
- wmdock_dockapp_child_pos(prevDapp, GLUE_L, &x, &y);
- prevDapp->glue[GLUE_L] = dapp;
+ x = 0 + offsetx;
+ y = 0 + offsety;
+ break;
+ case ANCHOR_TR:
+ if(xfceScrPos == XFCE_SCREEN_POSITION_NE_V ||
+ xfceScrPos == XFCE_SCREEN_POSITION_E ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SE_V) {
+ offsetx = xfce_panel_plugin_get_size(wmdock->plugin);
+ offsety = 0;
+ } else if (xfceScrPos == XFCE_SCREEN_POSITION_NW_H ||
+ xfceScrPos == XFCE_SCREEN_POSITION_N ||
+ xfceScrPos == XFCE_SCREEN_POSITION_NE_H) {
+ offsetx = 0;
+ offsety = panely == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
+ }
+
+ x = gdk_screen_get_width(get_current_gdkscreen()) - DEFAULT_DOCKAPP_WIDTH - offsetx;
+ y = 0 + offsety;
+ break;
+ case ANCHOR_BL:
+ if(xfceScrPos == XFCE_SCREEN_POSITION_NW_V ||
+ xfceScrPos == XFCE_SCREEN_POSITION_W ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SW_V) {
+ offsetx = panelx == 0 ? xfce_panel_plugin_get_size(wmdock->plugin) : 0;
+ offsety = 0;
+ } else if (xfceScrPos == XFCE_SCREEN_POSITION_SW_H ||
+ xfceScrPos == XFCE_SCREEN_POSITION_S ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SE_H) {
+ offsetx = 0;
+ offsety = xfce_panel_plugin_get_size(wmdock->plugin);
+ }
+
+ x = 0 + offsetx;
+ y = gdk_screen_get_height(get_current_gdkscreen()) - DEFAULT_DOCKAPP_HEIGHT - offsety;
+ break;
+ case ANCHOR_BR:
+ if(xfceScrPos == XFCE_SCREEN_POSITION_NE_V ||
+ xfceScrPos == XFCE_SCREEN_POSITION_E ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SE_V) {
+ offsetx = xfce_panel_plugin_get_size(wmdock->plugin);
+ offsety = 0;
+ } else if (xfceScrPos == XFCE_SCREEN_POSITION_SW_H ||
+ xfceScrPos == XFCE_SCREEN_POSITION_S ||
+ xfceScrPos == XFCE_SCREEN_POSITION_SE_H) {
+ offsetx = 0;
+ offsety = xfce_panel_plugin_get_size(wmdock->plugin);
+ }
+
+ x = gdk_screen_get_width(get_current_gdkscreen()) - DEFAULT_DOCKAPP_WIDTH - offsetx;
+ y = gdk_screen_get_height(get_current_gdkscreen()) - DEFAULT_DOCKAPP_HEIGHT - offsety;
+ break;
+ default:
+ debug("dockapp.c: Can not determine panel position x = y = 0.");
+ x = y = 0;
+ break;
}
- break;
- default:
- debug("dockapp.c: Can not determine panel position x = y = 0.");
- x = y = 0;
- break;
- }
+ } /* else */
}
gtk_window_move(GTK_WINDOW(dapp->tile), x, y);
diff --git a/panel-plugin/misc.c b/panel-plugin/misc.c
index 248a31b..3dd6a9e 100644
--- a/panel-plugin/misc.c
+++ b/panel-plugin/misc.c
@@ -189,6 +189,50 @@ GdkScreen *get_current_gdkscreen()
}
/**
+ * Returns the default anchor postion for the XFCE panel.
+ *
+ * @return default anchor postion
+ */
+AnchorPostion get_default_anchor_postion()
+{
+ AnchorPostion anchorPos = ANCHOR_BR;
+
+ if(!wmdock || !wmdock->plugin)
+ return anchorPos;
+
+ switch(xfce_panel_plugin_get_screen_position(wmdock->plugin)) {
+ case XFCE_SCREEN_POSITION_NW_H:
+ case XFCE_SCREEN_POSITION_N:
+ case XFCE_SCREEN_POSITION_NE_H:
+ anchorPos = ANCHOR_TR;
+ break;
+
+ case XFCE_SCREEN_POSITION_SW_H:
+ case XFCE_SCREEN_POSITION_S:
+ case XFCE_SCREEN_POSITION_SE_H:
+ anchorPos = ANCHOR_BR;
+ break;
+
+ case XFCE_SCREEN_POSITION_NW_V:
+ case XFCE_SCREEN_POSITION_W:
+ case XFCE_SCREEN_POSITION_SW_V:
+ anchorPos = ANCHOR_TL;
+ break;
+
+ case XFCE_SCREEN_POSITION_NE_V:
+ case XFCE_SCREEN_POSITION_E:
+ case XFCE_SCREEN_POSITION_SE_V:
+ anchorPos = ANCHOR_TR;
+ break;
+
+ default:
+ break;
+ }
+
+ return anchorPos;
+}
+
+/**
* Function which interacts with the wmdock icon.
*
* @param icon The wmdock icon widget.
diff --git a/panel-plugin/misc.h b/panel-plugin/misc.h
index bb043dc..9d52ea4 100644
--- a/panel-plugin/misc.h
+++ b/panel-plugin/misc.h
@@ -32,5 +32,6 @@ gboolean comp_dockapp_with_filterlist(const gchar *);
gboolean comp_str_with_pattern(const gchar *, gchar *, gsize);
void wmdock_panel_draw_wmdock_icon (gboolean redraw);
int wmdock_get_instance_count();
+AnchorPostion get_default_anchor_postion();
#endif /* __MISC_H__ */
diff --git a/panel-plugin/props.c b/panel-plugin/props.c
index 762b271..f20892d 100644
--- a/panel-plugin/props.c
+++ b/panel-plugin/props.c
@@ -43,10 +43,11 @@
static struct {
GtkWidget *dlg;
GtkWidget *vbox, *vbox2, *vboxGeneral, *vboxDetect;
- GtkWidget *hbox;
- GtkWidget *frmGeneral, *frmDetect;
+ GtkWidget *hbox, *hboxPanelOffOpts;
+ GtkWidget *frmGeneral, *frmDetect, *frmPanelOffOpts;
GtkWidget *lblSel, *lblCmd;
GtkWidget *chkDispTile, *chkPropButton, *chkAddOnlyWM, *chkPanelOff;
+ GtkWidget *radioPanelOffTL, *radioPanelOffTR, *radioPanelOffBL, *radioPanelOffBR;
GtkWidget *imageContainer, *container;
GtkWidget *imageTile, *image;
GtkWidget *txtCmd;
@@ -107,11 +108,14 @@ static void wmdock_properties_chkpaneloff(GtkToggleButton *gtkChkPanelOff, gpoin
{
GtkWidget *gtkDlg;
- rcPanelOff = gtk_toggle_button_get_active(gtkChkPanelOff);
+ if((rcPanelOff = gtk_toggle_button_get_active(gtkChkPanelOff)) == TRUE) {
+ wmdock->anchorPos = xfce_panel_plugin_get_screen_position(wmdock->plugin);
+ gtk_widget_set_sensitive(GTK_WIDGET(prop.frmPanelOffOpts), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(prop.frmPanelOffOpts), FALSE);
+ }
if(g_list_length(wmdock->dapps)) {
- if(rcPanelOff == TRUE)
- wmdock->anchorPos = xfce_panel_plugin_get_screen_position(wmdock->plugin);
gtkDlg = gtk_message_dialog_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (wmdock->plugin))),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -380,6 +384,7 @@ void wmdock_properties_dialog(XfcePanelPlugin *plugin)
prop.frmGeneral = gtk_frame_new(_("General settings"));
prop.frmDetect = gtk_frame_new(_("Dockapp detection"));
+ prop.frmPanelOffOpts = gtk_frame_new(_("Alignment options"));
prop.vboxGeneral = gtk_vbox_new(FALSE, 6);
prop.vboxDetect = gtk_vbox_new(FALSE, 6);
@@ -397,13 +402,15 @@ void wmdock_properties_dialog(XfcePanelPlugin *plugin)
gtk_box_pack_start (GTK_BOX (prop.hbox), prop.vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (prop.hbox), prop.vbox2, FALSE, FALSE, 0);
-
prop.imageContainer = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_widget_set_size_request(GTK_WIDGET(prop.imageContainer),
DEFAULT_DOCKAPP_WIDTH,
DEFAULT_DOCKAPP_HEIGHT);
prop.container = gtk_fixed_new();
+ prop.hboxPanelOffOpts = gtk_hbox_new(FALSE, 4);
+
+ /* Create the GTK widget objects. */
gdkPbIcon = gdk_pixbuf_new_from_xpm_data((const char**)
xfce4_wmdock_plugin_xpm);
@@ -470,8 +477,11 @@ void wmdock_properties_dialog(XfcePanelPlugin *plugin)
gtk_container_add(GTK_CONTAINER(prop.frmGeneral), prop.vboxGeneral);
gtk_container_add(GTK_CONTAINER(prop.frmDetect), prop.vboxDetect);
+
gtk_box_pack_start (GTK_BOX(prop.vboxGeneral), prop.chkPanelOff,
FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(prop.vboxGeneral), prop.frmPanelOffOpts,
+ FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(prop.vboxGeneral), prop.chkDispTile,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(prop.vboxGeneral), prop.chkPropButton,
@@ -481,6 +491,21 @@ void wmdock_properties_dialog(XfcePanelPlugin *plugin)
gtk_box_pack_start (GTK_BOX(prop.vboxDetect), prop.txtPatterns,
FALSE, FALSE, 0);
+ /* Setup advanced panel off mode options frame. */
+ prop.radioPanelOffTL = gtk_radio_button_new_with_label(NULL, _("Top left"));
+ prop.radioPanelOffTR = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(prop.radioPanelOffTL), _("Top right"));
+ prop.radioPanelOffBL = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(prop.radioPanelOffTL), _("Bottom left"));
+ prop.radioPanelOffBR = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(prop.radioPanelOffTL), _("Bottom right"));
+
+ gtk_container_add(GTK_CONTAINER(prop.frmPanelOffOpts), prop.hboxPanelOffOpts);
+ gtk_box_pack_start (GTK_BOX (prop.hboxPanelOffOpts), prop.radioPanelOffTL,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (prop.hboxPanelOffOpts), prop.radioPanelOffTR,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (prop.hboxPanelOffOpts), prop.radioPanelOffBL,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (prop.hboxPanelOffOpts), prop.radioPanelOffBR,
+ FALSE, FALSE, 0);
/* Fill the dockapp chooser with entries. */
wmdock_refresh_properties_dialog();
diff --git a/panel-plugin/wmdock.c b/panel-plugin/wmdock.c
index 033e1b2..cd95366 100644
--- a/panel-plugin/wmdock.c
+++ b/panel-plugin/wmdock.c
@@ -119,7 +119,7 @@ static WmdockPlugin *wmdock_plugin_new (XfcePanelPlugin* plugin)
/* TODO: Set panel off to FALSE. */
wmdock->propPanelOff = TRUE;
wmdock->filterList = g_strdup(DOCKAPP_FILTER_PATTERN);
- wmdock->anchorPos = -1;
+ wmdock->anchorPos = ANCHOR_BR;
wmdock->eventBox = gtk_event_box_new ();
gtk_widget_show(GTK_WIDGET(wmdock->eventBox));
diff --git a/panel-plugin/wmdock.h b/panel-plugin/wmdock.h
index d7178b0..2a2f480 100644
--- a/panel-plugin/wmdock.h
+++ b/panel-plugin/wmdock.h
@@ -28,6 +28,13 @@
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
+typedef enum {
+ ANCHOR_TL,
+ ANCHOR_TR,
+ ANCHOR_BL,
+ ANCHOR_BR
+} AnchorPostion;
+
typedef struct {
XfcePanelPlugin *plugin;
@@ -42,7 +49,7 @@ typedef struct {
gboolean propDispPropButton;
gboolean propDispAddOnlyWM;
gboolean propPanelOff;
- gint anchorPos;
+ AnchorPostion anchorPos;
gchar *filterList;
GList *dapps;
More information about the Xfce4-commits
mailing list