added settings window for open remembered windows (configpanel remember)
added list_remember ipc call SVN revision: 2411
This commit is contained in:
parent
4d18b0a3bb
commit
e310843452
11
src/E.h
11
src/E.h
|
@ -1736,6 +1736,16 @@ typedef enum
|
|||
}
|
||||
KMessage;
|
||||
|
||||
/* only used for remember list dialog callback funcs (SettingsDialog()
|
||||
in in settings.c)... snaps are attached to windows, not a global list */
|
||||
typedef struct _remwinlist
|
||||
{
|
||||
EWin *ewin;
|
||||
char remember;
|
||||
}
|
||||
RememberWinList;
|
||||
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
void Efont_extents(Efont * f, char *text,
|
||||
|
@ -3000,6 +3010,7 @@ void SettingsBackground(Background * bg);
|
|||
void SettingsIconbox(char *name);
|
||||
void SettingsGroups(EWin * ewin);
|
||||
void SettingsDefaultGroupControl(void);
|
||||
void SettingsRemember(void);
|
||||
|
||||
void BGSettingsGoTo(Background * bg);
|
||||
|
||||
|
|
|
@ -3476,6 +3476,11 @@ doConfigure(void *params)
|
|||
ACTION_ADD_TO_GROUP);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(s, "remember"))
|
||||
{
|
||||
|
||||
SettingsRemember();
|
||||
}
|
||||
}
|
||||
EDBUG_RETURN(0);
|
||||
}
|
||||
|
|
127
src/ipc.c
127
src/ipc.c
|
@ -83,6 +83,7 @@ void IPC_CurrentTheme(char *params, Client * c);
|
|||
void IPC_Nop(char *params, Client * c);
|
||||
void IPC_Xinerama(char *params, Client * c);
|
||||
void IPC_ConfigPanel(char *params, Client * c);
|
||||
void IPC_RememberList(char *params, Client * c);
|
||||
|
||||
/* Changes By Asmodean_ <naru@caltech.edu> / #E@Efnet
|
||||
*
|
||||
|
@ -557,7 +558,16 @@ IPCStruct IPCArray[] = {
|
|||
" configpanel <panelname>\n"
|
||||
" where panelname is one of the following: focus, moveresize,\n"
|
||||
" desktops, area, placement, icons, autoraise, tooltips, kde,\n"
|
||||
" audio, fx, bg, group_defaults"}
|
||||
" audio, fx, bg, group_defaults, remember"},
|
||||
{
|
||||
IPC_RememberList,
|
||||
"list_remember",
|
||||
"Retrieve a list of remembered windows and their attributes.",
|
||||
"usage:\n"
|
||||
" list_remember [full]\n"
|
||||
" Retrieve a list of remembered windows. with full, the list\n"
|
||||
" includes the window's remembered attributes."
|
||||
}
|
||||
};
|
||||
|
||||
/* the functions */
|
||||
|
@ -5369,3 +5379,118 @@ IPC_MemDebug(char *params, Client * c)
|
|||
params = NULL;
|
||||
c = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
IPC_RememberList(char *params, Client * c)
|
||||
{
|
||||
Snapshot **lst;
|
||||
int i, j, num, f;
|
||||
char buf[FILEPATH_LEN_MAX*2], /* hope 2x doesn't break anything */
|
||||
buf2[FILEPATH_LEN_MAX],
|
||||
fullstr[FILEPATH_LEN_MAX],
|
||||
nstr[]="null";
|
||||
|
||||
buf[0]=0; buf2[0]=0; fullstr[0]=0; f=0; j=0;
|
||||
|
||||
if (params) {
|
||||
word(params,1,fullstr);
|
||||
if (fullstr&&!strncmp(fullstr,"full", 5)) {
|
||||
f++;
|
||||
}
|
||||
}
|
||||
|
||||
lst = (Snapshot**) ListItemType(&num, LIST_TYPE_SNAPSHOT);
|
||||
if (!num) {
|
||||
Esnprintf(buf, sizeof(buf), "Error: no remembered windows\n");
|
||||
} else {
|
||||
if (f) {
|
||||
for (i=0; i<num; i++) {
|
||||
if (!lst[i]||(lst[i]&&!lst[i]->used)) j++;
|
||||
}
|
||||
Esnprintf(buf, sizeof(buf), "Number of remembered windows: %d\n",
|
||||
num-j);
|
||||
}
|
||||
/* strncat(buf, buf2, sizeof(buf)); */
|
||||
for (i=0; i<num; i++) {
|
||||
if (lst[i]&&lst[i]->used) {
|
||||
if (!f) {
|
||||
Esnprintf(buf2, sizeof(buf2), "%s\n",
|
||||
lst[i]->name?lst[i]->name:nstr);
|
||||
} else {
|
||||
Esnprintf(buf2, sizeof(buf2),
|
||||
" Name: %s\n"
|
||||
" Window Title: %s\n"
|
||||
" Window Name: %s\n"
|
||||
" Window Class: %s\n"
|
||||
" Border Name: %s\n"
|
||||
/*" Used: %s\n"*/
|
||||
" use_desktop: %d\n"
|
||||
" desktop: %d\n"
|
||||
" area (x, y): %d, %d\n"
|
||||
" use_wh: %d\n"
|
||||
" (w, h): %d, %d\n"
|
||||
" use_xy: %d\n"
|
||||
" (x, y): %d, %d\n"
|
||||
" use_layer: %d\n"
|
||||
" layer: %d\n"
|
||||
" use_sticky: %d\n"
|
||||
" sticky: %d\n"
|
||||
" use_shade: %d\n"
|
||||
" shade: %d\n"
|
||||
" use_command: %d\n"
|
||||
" command: %s\n"
|
||||
" use_skipwinlist: %d\n"
|
||||
" skipwinlist: %d\n"
|
||||
" use_skiplists: %d\n"
|
||||
" skiptask: %d\n"
|
||||
" skipfocus: %d\n"
|
||||
" use_neverfocus: %d\n"
|
||||
" neverfocus: %d\n",
|
||||
lst[i]->name?lst[i]->name:nstr,
|
||||
lst[i]->win_title?lst[i]->win_title:nstr,
|
||||
lst[i]->win_name?lst[i]->win_name:nstr,
|
||||
lst[i]->win_class?lst[i]->win_class:nstr,
|
||||
lst[i]->border_name?lst[i]->border_name:nstr,
|
||||
/*lst[i]->used?"yes":"no",*/
|
||||
|
||||
lst[i]->use_desktop,
|
||||
lst[i]->desktop,
|
||||
lst[i]->area_x, lst[i]->area_y,
|
||||
lst[i]->use_wh,
|
||||
lst[i]->w, lst[i]->h,
|
||||
lst[i]->use_xy,
|
||||
lst[i]->x, lst[i]->y,
|
||||
lst[i]->use_layer,
|
||||
lst[i]->layer,
|
||||
lst[i]->use_sticky,
|
||||
lst[i]->sticky,
|
||||
lst[i]->use_shade,
|
||||
lst[i]->shade,
|
||||
lst[i]->use_cmd,
|
||||
lst[i]->cmd?lst[i]->cmd:nstr,
|
||||
lst[i]->use_skipwinlist,
|
||||
lst[i]->skipwinlist,
|
||||
lst[i]->use_skiplists,
|
||||
lst[i]->skiptask,
|
||||
lst[i]->skipfocus,
|
||||
lst[i]->use_neverfocus,
|
||||
lst[i]->neverfocus
|
||||
);
|
||||
}
|
||||
} else {
|
||||
/* null snapshot or unused: argh hot grits, hot grits!!! :) */
|
||||
buf2[0]=0;
|
||||
}
|
||||
|
||||
if (strlen(buf)+strlen(buf2)>sizeof(buf)) {
|
||||
CommsSend(c, buf);
|
||||
buf[0]=0;
|
||||
}
|
||||
strncat(buf, buf2, sizeof(buf));
|
||||
}
|
||||
}
|
||||
|
||||
if (buf)
|
||||
CommsSend(c, buf);
|
||||
return;
|
||||
}
|
||||
|
|
212
src/settings.c
212
src/settings.c
|
@ -4191,3 +4191,215 @@ SettingsDefaultGroupControl(void)
|
|||
DialogBindKey(d, "Return", CB_ConfigureDefaultGroupSettings, 0, d);
|
||||
ShowDialog(d);
|
||||
}
|
||||
|
||||
|
||||
/* lsit of remembered items for the remember dialog -- it's either
|
||||
_anotyer_ glboal var, or i wrapper struct to pass data to the
|
||||
callback funcs besides the dialog itself -- this is much easier */
|
||||
static RememberWinList **rd_ewin_list;
|
||||
|
||||
void
|
||||
CB_ApplyRemember(int val, void *data)
|
||||
{
|
||||
Snapshot *sn;
|
||||
int i;
|
||||
|
||||
if (val<2 && rd_ewin_list) {
|
||||
for (i=0; rd_ewin_list[i]; i++) {
|
||||
if (rd_ewin_list[i]) {
|
||||
if (rd_ewin_list[i]->ewin && !rd_ewin_list[i]->remember) {
|
||||
UnsnapshotEwin(rd_ewin_list[i]->ewin);
|
||||
rd_ewin_list[i]->ewin = 0;
|
||||
/* would this be a better way to do things? */
|
||||
/* sn = FindSnapshot(rd_ewin_list[i]->ewin); */
|
||||
/* ClearSnapshot(sn); */
|
||||
/* rd_ewin_list[i]->ewin->snap = 0; */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* save snapshot info to disk */
|
||||
SaveSnapInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CB_ApplyRememberEscape(int val, void *data)
|
||||
{
|
||||
int i;
|
||||
DialogClose((Dialog *) data);
|
||||
val = 0;
|
||||
Efree(rd_ewin_list);
|
||||
}
|
||||
|
||||
void
|
||||
CB_RememberWindowSettings(int va, void *data)
|
||||
{
|
||||
EWin *ewin;
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
ewin = (EWin*) data;
|
||||
SnapshotEwinDialog(ewin);
|
||||
}
|
||||
|
||||
void
|
||||
SettingsRemember()
|
||||
{
|
||||
Dialog *d;
|
||||
DItem *table, *di;
|
||||
EWin **lst, *ewin;
|
||||
int i, ri, num, g_desc, verbose;
|
||||
|
||||
/* show as little infor as possible -- good for small screens
|
||||
where the hell should i put this option? */
|
||||
verbose = 1;
|
||||
|
||||
/* init remember window */
|
||||
if ((d=FindItem("REMEMBER_WINDOW",0,LIST_FINDBY_NAME,LIST_TYPE_DIALOG))) {
|
||||
ShowDialog(d);
|
||||
return;
|
||||
}
|
||||
d = CreateDialog("REMEMBER_WINDOW");
|
||||
DialogSetTitle(d, "Remembered Window Settings");
|
||||
table = DialogInitItem(d);
|
||||
DialogItemTableSetOptions(table, 4, 0, 0, 0);
|
||||
|
||||
/* theres a much more efficient way of doing this, but this'll work
|
||||
for now */
|
||||
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
||||
if (rd_ewin_list) {
|
||||
for (i=0; rd_ewin_list[i]; i++)
|
||||
Efree(rd_ewin_list[i]);
|
||||
Efree(rd_ewin_list);
|
||||
rd_ewin_list = 0;
|
||||
}
|
||||
rd_ewin_list = Emalloc(sizeof(RememberWinList*)*num+1);
|
||||
ri = 0;
|
||||
if ((lst) && (num > 0)) {
|
||||
for (i = 0; i < num; i++) {
|
||||
ewin = lst[i];
|
||||
if (!ewin || !FindSnapshot(ewin) ||
|
||||
!(ewin->client.title||ewin->client.name||ewin->client.class)) {
|
||||
/* fprintf(stderr,"Skipping window #%d \"%s\".\n",
|
||||
i, ewin->client.title?ewin->client.title:"null"); */
|
||||
} else {
|
||||
rd_ewin_list[ri] = Emalloc(sizeof(RememberWinList));
|
||||
rd_ewin_list[ri]->ewin = ewin;
|
||||
rd_ewin_list[ri]->remember = 1;
|
||||
/* fprintf(stderr," Window #%d \"%s\" is remembered (ri==%d)\n",
|
||||
i, ewin->client.title?ewin->client.title:"null", ri);
|
||||
fprintf(stderr," title:\t%s\n name:\t%s\n class:\t%s\n command:\t%s\n",
|
||||
ewin->client.title?ewin->client.title:"null",
|
||||
ewin->client.name?ewin->client.name:"null",
|
||||
ewin->client.class?ewin->client.class:"null",
|
||||
ewin->client.command?ewin->client.command:"null"
|
||||
); */
|
||||
|
||||
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
||||
DialogItemSetColSpan(di, 2);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 0, 512);
|
||||
DialogItemCheckButtonSetText(di, _("Remember this window"));
|
||||
DialogItemCheckButtonSetState(di, rd_ewin_list[ri]->remember);
|
||||
DialogItemCheckButtonSetPtr(di, &(rd_ewin_list[ri]->remember));
|
||||
|
||||
di = DialogAddItem(table, DITEM_BUTTON);
|
||||
DialogItemSetColSpan(di, 2);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 1024, 512);
|
||||
DialogItemButtonSetText(di, _("Remembered Settings..."));
|
||||
DialogItemSetCallback(di, CB_RememberWindowSettings,
|
||||
0, (char*)ewin);
|
||||
|
||||
g_desc = 0;
|
||||
if (ewin->client.title && strlen(ewin->client.title) &&
|
||||
strncmp(ewin->client.title, "0", 1)) {
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 0, 512);
|
||||
DialogItemTextSetText(di, "Title:");
|
||||
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetColSpan(di, 3);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 1024, 512);
|
||||
DialogItemTextSetText(di, ewin->client.title);
|
||||
g_desc = 1;
|
||||
}
|
||||
|
||||
if (ewin->client.name && strlen(ewin->client.name) &&
|
||||
strncmp(ewin->client.name, "0", 1) && (verbose||!g_desc)) {
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 0, 512);
|
||||
DialogItemTextSetText(di, "Name:");
|
||||
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetColSpan(di, 3);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 1024, 512);
|
||||
DialogItemTextSetText(di, ewin->client.name);
|
||||
g_desc = 1;
|
||||
}
|
||||
|
||||
if (ewin->client.class && strlen(ewin->client.class) &&
|
||||
strncmp(ewin->client.class, "0", 1) && (verbose||!g_desc)) {
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 0, 512);
|
||||
DialogItemTextSetText(di, "Class:");
|
||||
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetColSpan(di, 3);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 1024, 512);
|
||||
DialogItemTextSetText(di, ewin->client.class);
|
||||
}
|
||||
|
||||
if (ewin->client.command && strlen(ewin->client.command) &&
|
||||
strncmp(ewin->client.command, "0", 1)) {
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 0, 512);
|
||||
DialogItemTextSetText(di, "Command:");
|
||||
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
DialogItemSetColSpan(di, 3);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSetAlign(di, 1024, 512);
|
||||
DialogItemTextSetText(di, ewin->client.command);
|
||||
}
|
||||
|
||||
di = DialogAddItem(table, DITEM_SEPARATOR);
|
||||
DialogItemSetColSpan(di, 4);
|
||||
DialogItemSetPadding(di, 2, 2, 2, 2);
|
||||
DialogItemSetFill(di, 1, 0);
|
||||
DialogItemSeparatorSetOrientation(di, 0);
|
||||
|
||||
ri++;
|
||||
}
|
||||
}
|
||||
Efree(lst);
|
||||
rd_ewin_list[ri]=0;
|
||||
}
|
||||
|
||||
/* finish remember window */
|
||||
DialogAddButton(d, _("OK"), CB_ApplyRemember, 1);
|
||||
DialogAddButton(d, _("Apply"), CB_ApplyRemember, 0);
|
||||
DialogAddButton(d, _("Cancel"), CB_ApplyRemember, 1);
|
||||
DialogSetExitFunction(d, CB_ApplyRemember, 2, d);
|
||||
DialogBindKey(d, "Escape", CB_ApplyRememberEscape, 0, d);
|
||||
DialogBindKey(d, "Return", CB_ApplyRemember, 0, d);
|
||||
|
||||
ShowDialog(d);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ ADD_MENU_TEXT_ITEM("Autoraise Settings ...", __A_CONFIG, "autoraise")
|
|||
ADD_MENU_TEXT_ITEM("Tooltip Settings ...", __A_CONFIG, "tooltips")
|
||||
ADD_MENU_TEXT_ITEM("Audio Settings ...", __A_CONFIG, "audio")
|
||||
ADD_MENU_TEXT_ITEM("Group Settings ...", __A_CONFIG, "group_defaults")
|
||||
ADD_MENU_TEXT_ITEM("Remember Settings ...", __A_CONFIG, "remember");
|
||||
ADD_MENU_TEXT_ITEM("Special FX Settings ...", __A_CONFIG, "fx")
|
||||
ADD_MENU_TEXT_ITEM("Desktop Background Settings ...", __A_CONFIG, "bg")
|
||||
ADD_MENU_TEXT_ITEM("KDE Support Settings ...", __A_CONFIG, "kde")
|
||||
|
|
Loading…
Reference in New Issue