From: Rodolfo García Peñas (kix) Date: Wed, 28 Nov 2012 22:56:19 +0000 (+0100) Subject: winspector: Save iconpath if icon will be used X-Git-Tag: wmaker-0.95.4~9 X-Git-Url: https://repo.or.cz/w/wmaker-crm.git/commitdiff_plain/c164db31bf39ec63cb7ab1778e80bba9c945e074 winspector: Save iconpath if icon will be used This patch avoids to save the icon name in the configuration file if the flag "Ignore client supplied icon" is not selected. First, when winspector tries to show the icon to the user, it must not search the default icon. It should use the specific icon or the icon provided by the client. When we click in "save Settings", the function saveSettings reads the icon specified by the user in the text box. If the checkbox "Ignore client supplied icon" is not selected, then saves the icon too. Using this behaviour we never recover the initial position (no icon selected, no ignore client supplied icon flag set). This patch recovers the initial state of the icon options. When the user unsets the ignore client the filename provided is not saved in the configuration file. Now, the configuration is like the initial status. If the user checks the flag and set the file to use as icon, the file is used. --- diff --git a/src/winspector.c b/src/winspector.c index cd9250da..73350308 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -314,8 +314,8 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instanc file = NULL; } } else { - /* Get the application icon, default included */ - db_icon = wDefaultGetIconFile(wm_instance, wm_class, True); + /* Get the application icon, default NOT included */ + db_icon = wDefaultGetIconFile(wm_instance, wm_class, False); if (db_icon != NULL) file = wstrdup(db_icon); } @@ -433,7 +433,7 @@ static void saveSettings(WMButton *button, InspectorPanel *panel) WWindow *wwin = panel->inspected; WDDomain *db = WDWindowAttributes; WMPropList *dict = NULL; - WMPropList *winDic, *appDic, *value, *key = NULL, *key2; + WMPropList *winDic, *appDic, *value, *value1, *key = NULL, *key2; char *icon_file, *buf1, *buf2; int flags = 0, i = 0, different = 0, different2 = 0; @@ -475,16 +475,29 @@ static void saveSettings(WMButton *button, InspectorPanel *panel) winDic = WMCreatePLDictionary(NULL, NULL); appDic = WMCreatePLDictionary(NULL, NULL); - /* Update icon for window */ - icon_file = WMGetTextFieldText(panel->fileText); - if (icon_file) { - if (icon_file[0] != 0) { - value = WMCreatePLString(icon_file); - different |= insertAttribute(dict, winDic, AIcon, value, flags); - different2 |= insertAttribute(dict, appDic, AIcon, value, flags); - WMReleasePropList(value); + /* If the "Ignore client suplied icon is not selected" flag was not set, + * then, don't save the icon filename. If saved, the application will use + * that icon, even the flag is not set. */ + if (WMGetButtonSelected(panel->alwChk) != 0) { + /* Update icon for window */ + icon_file = WMGetTextFieldText(panel->fileText); + if (icon_file) { + if (icon_file[0] != 0) { + value = WMCreatePLString(icon_file); + different |= insertAttribute(dict, winDic, AIcon, value, flags); + different2 |= insertAttribute(dict, appDic, AIcon, value, flags); + WMReleasePropList(value); + + /* Set the ckeck for AAlwaysUserIcon only if icon_file exists */ + buf1 = wmalloc(4); + snprintf(buf1, 4, "%s", (WMGetButtonSelected(panel->alwChk) != 0) ? "Yes" : "No"); + value1 = WMCreatePLString(buf1); + different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value1, flags); + WMReleasePropList(value1); + wfree(buf1); + } + wfree(icon_file); } - wfree(icon_file); } i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1; @@ -496,9 +509,6 @@ static void saveSettings(WMButton *button, InspectorPanel *panel) flags |= IS_BOOLEAN; - value = (WMGetButtonSelected(panel->alwChk) != 0) ? Yes : No; - different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value, flags); - value = (WMGetButtonSelected(panel->attrChk[0]) != 0) ? Yes : No; different |= insertAttribute(dict, winDic, ANoTitlebar, value, flags);