[Xfce4-commits] <xfce4-wmdock-plugin:0.6.x> Implemented restoring dockapp postion from rc file.
Andre Ellguth
noreply at xfce.org
Tue Oct 8 18:24:01 CEST 2013
Updating branch refs/heads/0.6.x
to 79f73db43ddd64ac4224286ef9abc53f526dd898 (commit)
from db7f29c982e45760ae35feb31ac2993f5c7524a4 (commit)
commit 79f73db43ddd64ac4224286ef9abc53f526dd898
Author: Andre Ellguth <andre at ellguth.com>
Date: Tue Oct 8 18:22:17 2013 +0200
Implemented restoring dockapp postion from rc file.
panel-plugin/dockapp.c | 4 +--
panel-plugin/dockapp.h | 4 +--
panel-plugin/extern.h | 1 -
panel-plugin/rcfile.c | 66 ++++++++++++++++++++++++++++++++++--------------
panel-plugin/wmdock.c | 1 -
5 files changed, 51 insertions(+), 25 deletions(-)
diff --git a/panel-plugin/dockapp.c b/panel-plugin/dockapp.c
index d96260e..fc2535a 100644
--- a/panel-plugin/dockapp.c
+++ b/panel-plugin/dockapp.c
@@ -253,7 +253,7 @@ static gboolean wmdock_replace_tile_dummy(DockappNode *dapp)
* @param gluePos Position to be translated.
* @return String representation of the postion.
*/
-const gchar *get_glue_name(const gint glusPos)
+const gchar *wmdock_get_glue_name(const gint glusPos)
{
static gchar ret[10];
@@ -282,7 +282,7 @@ const gchar *get_glue_name(const gint glusPos)
* @param name The name to be translated to a number.
* @return The position as integer. On error -1 is returned.
*/
-gint get_glue_position(gchar const *name)
+gint wmdock_get_glue_position(gchar const *name)
{
if(!g_ascii_strcasecmp(name, "GLUE_B"))
return GLUE_B;
diff --git a/panel-plugin/dockapp.h b/panel-plugin/dockapp.h
index 06fd2c1..3873eec 100644
--- a/panel-plugin/dockapp.h
+++ b/panel-plugin/dockapp.h
@@ -75,7 +75,7 @@ void wmdock_remove_anchor_dockapp(DockappNode *, DockappNode *);
void wmdock_order_dockapps(DockappNode *);
GtkWidget *wmdock_create_tile_dummy();
gint wmdock_get_default_gluepos();
-gint get_glue_position(gchar const *);
-const gchar *get_glue_name(const gint);
+gint wmdock_get_glue_position(gchar const *);
+const gchar *wmdock_get_glue_name(const gint);
#endif /* __DOCKAPP_H__ */
diff --git a/panel-plugin/extern.h b/panel-plugin/extern.h
index cb83c13..bda4b0c 100644
--- a/panel-plugin/extern.h
+++ b/panel-plugin/extern.h
@@ -31,7 +31,6 @@ extern GdkPixbuf *gdkPbTileDefault;
extern GtkWidget *wmdockIcon;
extern Atom XfceDockAppAtom;
extern gchar **rcCmds;
-extern gint rcCmdcnt;
extern gboolean rcPanelOff;
#endif /* __EXTERN_H__ */
diff --git a/panel-plugin/rcfile.c b/panel-plugin/rcfile.c
index e567ce3..771cb51 100644
--- a/panel-plugin/rcfile.c
+++ b/panel-plugin/rcfile.c
@@ -48,37 +48,45 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
{
gchar *file = NULL;
XfceRc *rc = NULL;
- gint i;
+ gint i = 0, j = 0, gluePos = 0;
+ gint64 n = 0;
+ gchar *glueName = NULL;
GtkWidget *gtkDlg;
DockappNode *dapp = NULL;
+ DockappNode **launched = NULL;
+ gchar **glueList = NULL;
+ gchar **tokens = NULL;
if (!(file = xfce_panel_plugin_lookup_rc_file (plugin))) return;
rc = xfce_rc_simple_open (file, TRUE);
g_free(file);
-
- if(!rc) return;
+ if(!rc)
+ return;
rcCmds = xfce_rc_read_list_entry(rc, RCKEY_CMDLIST, ";");
- rcCmdcnt = xfce_rc_read_int_entry(rc, RCKEY_CMDCNT, 0);
wmdock->propDispTile = xfce_rc_read_bool_entry (rc, RCKEY_DISPTILE, TRUE);
wmdock->propDispPropButton = xfce_rc_read_bool_entry (rc, RCKEY_DISPPROPBTN, FALSE);
wmdock->propDispAddOnlyWM = xfce_rc_read_bool_entry (rc, RCKEY_DISPADDONLYWM, TRUE);
if(wmdock->filterList) g_free(wmdock->filterList);
wmdock->filterList = g_strdup(xfce_rc_read_entry (rc, RCKEY_DAFILTER, DOCKAPP_FILTER_PATTERN));
/* TODO: Set panel off to FALSE. */
- rcPanelOff = wmdock->propPanelOff = xfce_rc_read_bool_entry (rc, RCKEY_PANELOFF, TRUE);
+ rcPanelOff = wmdock->propPanelOff = xfce_rc_read_bool_entry (rc, RCKEY_PANELOFF, TRUE);
+ glueList = IS_PANELOFF(wmdock) ? xfce_rc_read_list_entry(rc, RCKEY_GLUELIST, ";") : NULL;
wmdock->anchorPos = xfce_rc_read_int_entry(rc, RCKEY_ANCHORPOS, -1);
+ xfce_rc_close (rc);
if(G_LIKELY(rcCmds != NULL)) {
- /* Wait 5 seconds as workaround for double XMap problems. */
- g_usleep(5 * G_USEC_PER_SEC);
+ if(!(launched = g_malloc0(sizeof (DockappNode *) * (g_strv_length(rcCmds)))))
+ return;
- for (i = 0; i <= rcCmdcnt; i++) {
- if(!rcCmds[i]) continue;
+ /* Wait 1 seconds as workaround for double XMap problems. */
+ g_usleep(1 * G_USEC_PER_SEC);
+ for (i = 0; rcCmds[i]; i++) {
debug("rcfile.c: Setup `%s'\n", rcCmds[i]);
if(wmdock_startup_dockapp(rcCmds[i]) != TRUE) {
+ launched[i] = NULL;
gtkDlg = gtk_message_dialog_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@@ -99,6 +107,7 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
dapp->tile = wmdock_create_tile_from_socket(dapp);
wmdock->dapps = g_list_append(wmdock->dapps, dapp);
+ launched[i] = dapp;
if( ! IS_PANELOFF(wmdock) ) {
gtk_box_pack_start(GTK_BOX(wmdock->box), GTK_WIDGET(dapp->tile), FALSE, FALSE, 0);
@@ -112,9 +121,28 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
}
}
}
- } /* rcCmds != NULL */
- xfce_rc_close (rc);
+ if( IS_PANELOFF(wmdock ) && g_strv_length(rcCmds) == g_strv_length(glueList) ) {
+ for (i = 0; glueList[i]; i++) {
+ if(!launched[i] || glueList[i][0] == '\0' || !(tokens = g_strsplit(glueList[i], ",", 0)))
+ continue;
+
+ for (j = 0; tokens[j]; j++) {
+ n = g_ascii_strtoll(tokens[j], &glueName, 10);
+ if(n > G_MAXINT || n < 0 || n > g_strv_length(rcCmds)-1 || glueName == tokens[j])
+ continue;
+ if((gluePos = wmdock_get_glue_position(glueName) == -1))
+ continue;
+
+ launched[i]->glue[gluePos] = launched[(gint) n];
+ }
+ g_strfreev(tokens);
+ }
+
+ g_strfreev(glueList);
+ }
+ g_free(launched);
+ } /* rcCmds != NULL */
}
@@ -127,14 +155,15 @@ void wmdock_write_rc_file (XfcePanelPlugin *plugin)
gchar buf[BUF_MAX];
GList *dapps;
DockappNode *dapp = NULL;
- gint i = 0, gluePos = 0, j = 0;
+ gint i = 0, gluePos = 0, n = 0;
if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) return;
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
- if (!rc) return;
+ if (!rc)
+ return;
if(g_list_length (wmdock->dapps) > 0) {
cmdList = g_malloc0(sizeof (gchar *) * (g_list_length (wmdock->dapps) + 1));
@@ -149,12 +178,12 @@ void wmdock_write_rc_file (XfcePanelPlugin *plugin)
if( IS_PANELOFF(wmdock) ) {
buf[0] = '\0';
for(gluePos = 0; gluePos < GLUE_MAX; gluePos++) {
- if(dapp->glue[gluePos] && (j = g_list_index(wmdock->dapps, (gconstpointer) dapp->glue[gluePos])) != -1) {
- /* ChildIndex1(j):position,ChildIndex2:postion,... */
- if(strlen((const char *) buf) > 0)
- p = g_strdup_printf(",%d:%s", j, get_glue_name(gluePos));
+ if(dapp->glue[gluePos] && (n = g_list_index(wmdock->dapps, (gconstpointer) dapp->glue[gluePos])) != -1) {
+ /* ChildIndex1(n):position,ChildIndex2:postion,... */
+ if(strnlen((const char *) buf, sizeof(buf)-1) > 0)
+ p = g_strdup_printf(",%d:%s", n, wmdock_get_glue_name(gluePos));
else
- p = g_strdup_printf("%d:%s", j, get_glue_name(gluePos));
+ p = g_strdup_printf("%d:%s", n, wmdock_get_glue_name(gluePos));
g_strlcat(buf, p, sizeof(buf));
g_free(p);
}
@@ -171,7 +200,6 @@ void wmdock_write_rc_file (XfcePanelPlugin *plugin)
g_strfreev(glueList);
}
- xfce_rc_write_int_entry (rc, RCKEY_CMDCNT, g_list_length (wmdock->dapps));
xfce_rc_write_bool_entry (rc, RCKEY_DISPTILE, wmdock->propDispTile);
xfce_rc_write_bool_entry (rc, RCKEY_DISPPROPBTN, wmdock->propDispPropButton);
xfce_rc_write_bool_entry (rc, RCKEY_DISPADDONLYWM, wmdock->propDispAddOnlyWM);
diff --git a/panel-plugin/wmdock.c b/panel-plugin/wmdock.c
index cd95366..50420f9 100644
--- a/panel-plugin/wmdock.c
+++ b/panel-plugin/wmdock.c
@@ -56,7 +56,6 @@ GdkPixbuf *gdkPbTileDefault = NULL;
GdkPixbuf *gdkPbIcon = NULL;
WmdockPlugin *wmdock = NULL;
gchar **rcCmds = NULL;
-gint rcCmdcnt = 0;
/* TODO: Set panel off to FALSE. */
gboolean rcPanelOff = TRUE;
More information about the Xfce4-commits
mailing list