Skip to content

Commit 7a3f138

Browse files
committed
added named desktops to prefs and lfsdesktop
1 parent 66f9e2b commit 7a3f138

File tree

6 files changed

+125
-4
lines changed

6 files changed

+125
-4
lines changed

LFSApplications/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.2.0
2+
Added setting desktop names to lfsdesktopprefs.
23
Apply in dockprefs kills all docks.
34
Added option to set dock on dockprefs at start up.
45
Added lfsdockprefs desktop file to install.

LFSApplications/LFSApplications/src/lfsdesktopprefs.cpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,44 @@ int parentWindow=-1;
6565
//msg
6666
int queueID=-1;
6767

68+
//workspaces
69+
LFSTK_lineEditClass *desktopNamesEdit=NULL;
70+
6871
bool doQuit(void *p,void* ud)
6972
{
7073
apc->exitValue=0;
7174
apc->mainLoop=false;
7275
return(false);
7376
}
7477

78+
void setDeskNamesProp(void)
79+
{
80+
std::vector<std::string> tokenstrings;
81+
const char *x1;
82+
std::string x="";
83+
int totallen=0;
84+
std::string names=desktopNamesEdit->LFSTK_getBuffer();
85+
86+
tokenstrings=LFSTK_UtilityClass::LFSTK_strTok(names,",");
87+
for(int j=0;j<tokenstrings.size();j++)
88+
{
89+
totallen+=tokenstrings.at(j).length()+1;
90+
x+=tokenstrings.at(j)+'\0';
91+
}
92+
93+
x1=x.c_str();
94+
XChangeProperty(apc->display,apc->rootWindow,XInternAtom(apc->display,"_NET_DESKTOP_NAMES",false),
95+
XInternAtom(apc->display,"UTF8_STRING",false),
96+
8,
97+
PropModeReplace,
98+
(const unsigned char*)*&x1
99+
,totallen
100+
);
101+
102+
XSync(apc->display,false);
103+
//system("xprop -root _NET_DESKTOP_NAMES");
104+
}
105+
75106
bool buttonCB(void *p,void* ud)
76107
{
77108
msgBuffer buffer;
@@ -92,10 +123,12 @@ bool buttonCB(void *p,void* ud)
92123
{prefs.LFSTK_hashFromKey("labelalpha"),{TYPESTRING,"labelalpha",labelAlphaColurEditBox->LFSTK_getCStr(),false,0}},
93124
{prefs.LFSTK_hashFromKey("includelist"),{TYPESTRING,"includelist",includeEditBox->LFSTK_getCStr(),false,0}},
94125
{prefs.LFSTK_hashFromKey("excludelist"),{TYPESTRING,"excludelist",excludeEditBox->LFSTK_getCStr(),false,0}},
95-
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",clickExeCheck->LFSTK_getValue(),0}}
126+
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",clickExeCheck->LFSTK_getValue(),0}},
127+
{prefs.LFSTK_hashFromKey("desknames"),{TYPESTRING,"desknames",desktopNamesEdit->LFSTK_getCStr(),false,0}},
96128
};
97129

98130
prefs.LFSTK_saveVarsToFile(envFile);
131+
setDeskNamesProp();
99132
buffer.mType=DESKTOP_MSG;
100133
sprintf(buffer.mText,"reloadprefs");
101134
if((msgsnd(queueID,&buffer,strlen(buffer.mText)+1,0))==-1)
@@ -218,7 +251,8 @@ int main(int argc, char **argv)
218251
{prefs.LFSTK_hashFromKey("labelalpha"),{TYPESTRING,"labelalpha","1.0",false,0}},
219252
{prefs.LFSTK_hashFromKey("includelist"),{TYPESTRING,"includelist","",false,0}},
220253
{prefs.LFSTK_hashFromKey("excludelist"),{TYPESTRING,"excludelist","",false,0}},
221-
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",false,0}}
254+
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",false,0}},
255+
{prefs.LFSTK_hashFromKey("desknames"),{TYPESTRING,"desknames","Desktop 1,Desktop 2,Desktop 3,Desktop 4,Desktop 5,Desktop 6",false,0}},
222256
};
223257

224258
asprintf(&envFile,"%s/lfsdesktop.rc",apc->configDir.c_str());
@@ -302,6 +336,10 @@ int main(int argc, char **argv)
302336
label=new LFSTK_labelClass(wc,"Exclude Disks",BORDER,sy,GADGETWIDTH,GADGETHITE,LEFT);
303337
excludeEditBox=new LFSTK_lineEditClass(wc,prefs.LFSTK_getCString("excludelist"),BORDER*2+GADGETWIDTH,sy,GADGETWIDTH*4,GADGETHITE,BUTTONGRAV);
304338
sy+=YSPACING;
339+
//desktop names
340+
label=new LFSTK_labelClass(wc,"Desktop Names",BORDER,sy,GADGETWIDTH,GADGETHITE,LEFT);
341+
desktopNamesEdit=new LFSTK_lineEditClass(wc,prefs.LFSTK_getCString("desknames"),BORDER+GADGETWIDTH+BORDER,sy,GADGETWIDTH*4,GADGETHITE,BUTTONGRAV);
342+
sy+=YSPACING;
305343

306344
//line
307345
seperator=new LFSTK_buttonClass(wc,"--",0,sy,DIALOGWIDTH,GADGETHITE,BUTTONGRAV);

LFSApplications/LFSApplications/src/lfsdockprefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int dockSizePref=3;
7575
//dock select
7676
LFSTK_buttonClass *selectDock=NULL;
7777
LFSTK_lineEditClass *dockNameEdit=NULL;
78-
infoDataStruct **dockNames=NULL;
78+
infoDataStruct **dockNames=NULL;
7979
LFSTK_menuClass *dockMenu=NULL;
8080
int dockCnt=0;
8181
std::string dockName="";

LFSDesktop/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.2.0
2+
Set desktop names on start.
23
Fixed minor compiler complaint.
34
Fixed segfault for unreachable icon in desktop file.
45
Fixed not displaying items as links properly.

LFSDesktop/LFSDesktop/src/prefs.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,34 @@ void saveCacheFile(const char *cachefilepath,desktopItemStruct *cfd)
8888
cacheprefs.LFSTK_saveVarsToFile(cachefilepath);
8989
}
9090

91+
void setDeskNamesProp(void)
92+
{
93+
std::vector<std::string> tokenstrings;
94+
const char *x1;
95+
std::string x="";
96+
int totallen=0;
97+
std::string names=prefs.LFSTK_getString("desknames");
98+
99+
tokenstrings=LFSTK_UtilityClass::LFSTK_strTok(names,",");
100+
for(int j=0;j<tokenstrings.size();j++)
101+
{
102+
totallen+=tokenstrings.at(j).length()+1;
103+
x+=tokenstrings.at(j)+'\0';
104+
}
105+
106+
x1=x.c_str();
107+
XChangeProperty(apc->display,apc->rootWindow,XInternAtom(apc->display,"_NET_DESKTOP_NAMES",false),
108+
XInternAtom(apc->display,"UTF8_STRING",false),
109+
8,
110+
PropModeReplace,
111+
(const unsigned char*)*&x1
112+
,totallen
113+
);
114+
115+
XSync(apc->display,false);
116+
system("xprop -root _NET_DESKTOP_NAMES");
117+
}
118+
91119
void loadPrefs(void)
92120
{
93121
//{(".*"),(.*),&.*}
@@ -108,7 +136,8 @@ void loadPrefs(void)
108136
{prefs.LFSTK_hashFromKey("labelalpha"),{TYPESTRING,"labelalpha","1.0",false,0}},
109137
{prefs.LFSTK_hashFromKey("includelist"),{TYPESTRING,"includelist","",false,0}},
110138
{prefs.LFSTK_hashFromKey("excludelist"),{TYPESTRING,"excludelist","",false,0}},
111-
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",false,0}}
139+
{prefs.LFSTK_hashFromKey("doubleclickexe"),{TYPEBOOL,"doubleclickexe","",false,0}},
140+
{prefs.LFSTK_hashFromKey("desknames"),{TYPESTRING,"desknames","Desktop 1,Desktop 2,Desktop 3,Desktop 4,Desktop 5,Desktop 6",false,0}},
112141
};
113142

114143
prefs.LFSTK_loadVarsFromFile(prefsPath);
@@ -128,6 +157,7 @@ void loadPrefs(void)
128157
includeList=prefs.LFSTK_getCString("includelist");
129158
excludeList=prefs.LFSTK_getCString("excludelist");
130159
doubleClickExecute=prefs.LFSTK_getBool("doubleclickexe");
160+
setDeskNamesProp();
131161
}
132162

133163
void reloadPrefs(void)

LFSToolKit/devtests/setdesknames.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#if 0
2+
3+
# (c)keithhedger Tue 9 Jan 13:48:05 GMT 2024 [email protected]
4+
5+
#USEVALGRIND="valgrind --leak-check=full"
6+
7+
APPNAME=$(basename $0 .cpp)
8+
9+
g++ "$0" -O0 -ggdb $(pkg-config --cflags --libs x11 xft cairo lfstk ) -llfstoolkit -lImlib2 -o $APPNAME ||exit 1
10+
$USEVALGRIND ./$APPNAME "$@"
11+
12+
retval=$?
13+
echo "Exit code $retval"
14+
rm $APPNAME
15+
exit $retval
16+
#endif
17+
18+
#include "lfstk/LFSTKGlobals.h"
19+
#include <memory>
20+
21+
int main(int argc, char **argv)
22+
{
23+
std::vector<std::string> tokenstrings;
24+
const char *x1;
25+
std::string x="";
26+
int totallen=0;
27+
LFSTK_applicationClass *apc=new LFSTK_applicationClass();
28+
std::string names="w1,w2,w3,w4,w5,w6";
29+
30+
tokenstrings=LFSTK_UtilityClass::LFSTK_strTok(names,",");
31+
for(int j=0;j<tokenstrings.size();j++)
32+
{
33+
totallen+=tokenstrings.at(j).length()+1;
34+
x+=tokenstrings.at(j)+'\0';
35+
}
36+
37+
x1=x.c_str();
38+
XChangeProperty(apc->display,apc->rootWindow,XInternAtom(apc->display,"_NET_DESKTOP_NAMES",false),
39+
XInternAtom(apc->display,"UTF8_STRING",false),
40+
8,
41+
PropModeReplace,
42+
(const unsigned char*)*&x1
43+
,totallen
44+
);
45+
46+
XSync(apc->display,false);
47+
//system("xprop -root _NET_DESKTOP_NAMES");
48+
delete apc;
49+
cairo_debug_reset_static_data();
50+
return(0);
51+
}

0 commit comments

Comments
 (0)