1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

Added ability to set omnipresent icons in Clip.

This commit is contained in:
dan
1999-05-14 23:49:07 +00:00
parent 39513b9f35
commit 70a363de7b
25 changed files with 640 additions and 463 deletions

View File

@@ -1,9 +1,9 @@
/* dockedapp.c- docked application settings panel
*
*
* Window Maker window manager
*
*
* Copyright (c) 1998 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -48,12 +48,12 @@ extern WPreferences wPreferences;
typedef struct _AppSettingsPanel {
WMWindow *win;
WAppIcon *editedIcon;
WWindow *wwin;
WMLabel *iconLabel;
WMLabel *nameLabel;
WMFrame *commandFrame;
WMTextField *commandField;
@@ -66,6 +66,7 @@ typedef struct _AppSettingsPanel {
WMButton *browseBtn;
WMButton *autoLaunchBtn;
WMButton *omnipresentBtn;
WMButton *okBtn;
WMButton *cancelBtn;
@@ -92,7 +93,7 @@ updateCommand(WAppIcon *icon, char *command)
}
icon->command = command;
if (!icon->wm_class && !icon->wm_instance && icon->command
if (!icon->wm_class && !icon->wm_instance && icon->command
&& strlen(icon->command)>0) {
icon->forced_dock = 1;
}
@@ -118,13 +119,13 @@ static void
updateSettingsPanelIcon(AppSettingsPanel *panel)
{
char *file;
file = WMGetTextFieldText(panel->iconField);
if (!file)
WMSetLabelImage(panel->iconLabel, NULL);
else {
char *path;
path = FindImage(wPreferences.icon_path, file);
if (!path) {
wwarning(_("could not find icon %s, used in a docked application"),
@@ -165,8 +166,8 @@ chooseIconCallback(WMWidget *self, void *clientData)
panel->choosingIcon = 1;
WMSetButtonEnabled(panel->browseBtn, False);
result = wIconChooserDialog(panel->wwin->screen_ptr, &file,
result = wIconChooserDialog(panel->wwin->screen_ptr, &file,
panel->editedIcon->wm_instance,
panel->editedIcon->wm_class);
@@ -177,7 +178,7 @@ chooseIconCallback(WMWidget *self, void *clientData)
free(file);
updateSettingsPanelIcon(panel);
}
WMSetButtonEnabled(panel->browseBtn, True);
} else {
/* kluge for the case, the user asked to close the panel before
@@ -193,8 +194,8 @@ panelBtnCallback(WMWidget *self, void *data)
WMButton *btn = self;
AppSettingsPanel *panel = (AppSettingsPanel*)data;
char *text;
int done;
int done, omnipresent;
done = 1;
if (panel->okBtn == btn) {
text = WMGetTextFieldText(panel->iconField);
@@ -204,10 +205,10 @@ panelBtnCallback(WMWidget *self, void *data)
}
if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
char *buf;
buf = wmalloc(strlen(text) + 64);
sprintf(buf, _("Could not open specified icon file: %s"), text);
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
if (text)
free(text);
@@ -244,7 +245,19 @@ panelBtnCallback(WMWidget *self, void *data)
updateDNDCommand(panel->editedIcon, text);
#endif
panel->editedIcon->auto_launch =
omnipresent = WMGetButtonSelected(panel->omnipresentBtn);
if (wClipMakeIconOmnipresent(panel->editedIcon, omnipresent) ==
WO_FAILED) {
wMessageDialog(panel->wwin->screen_ptr, _("Error"),
_("Sorry, icon cannot be made omnipresent. "
"Please make sure that no other icon is "
"docked in the same position on the other "
"workspaces, and try again."),
_("OK"), NULL, NULL);
return;
}
panel->editedIcon->auto_launch =
WMGetButtonSelected(panel->autoLaunchBtn);
}
@@ -254,10 +267,10 @@ panelBtnCallback(WMWidget *self, void *data)
#define PWIDTH 295
#define PHEIGHT 345
#define PHEIGHT 375
void
void
ShowDockAppSettingsPanel(WAppIcon *aicon)
{
AppSettingsPanel *panel;
@@ -265,15 +278,15 @@ ShowDockAppSettingsPanel(WAppIcon *aicon)
Window parent;
WMFont *font;
int x, y;
panel = wmalloc(sizeof(AppSettingsPanel));
memset(panel, 0, sizeof(AppSettingsPanel));
panel->editedIcon = aicon;
aicon->panel = panel;
aicon->editing = 1;
panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings");
WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
@@ -281,7 +294,7 @@ ShowDockAppSettingsPanel(WAppIcon *aicon)
WMResizeWidget(panel->iconLabel, 64, 64);
WMMoveWidget(panel->iconLabel, 10, 10);
WMSetLabelImagePosition(panel->iconLabel, WIPImageOnly);
panel->nameLabel = WMCreateLabel(panel->win);
WMResizeWidget(panel->nameLabel, 190, 18);
WMMoveWidget(panel->nameLabel, 80, 35);
@@ -294,75 +307,84 @@ ShowDockAppSettingsPanel(WAppIcon *aicon)
panel->autoLaunchBtn = WMCreateSwitchButton(panel->win);
WMResizeWidget(panel->autoLaunchBtn, PWIDTH-30, 20);
WMMoveWidget(panel->autoLaunchBtn, 15, 80);
WMSetButtonText(panel->autoLaunchBtn,
WMSetButtonText(panel->autoLaunchBtn,
_("Start when WindowMaker is started"));
WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch);
panel->omnipresentBtn = WMCreateSwitchButton(panel->win);
WMResizeWidget(panel->omnipresentBtn, PWIDTH-30, 20);
WMMoveWidget(panel->omnipresentBtn, 15, 102);
WMSetButtonText(panel->omnipresentBtn,
_("Omnipresent application icon"));
WMSetButtonEnabled(panel->omnipresentBtn,
aicon->dock!=scr->dock && aicon!=scr->clip_icon);
WMSetButtonSelected(panel->omnipresentBtn, (aicon->omnipresent ||
aicon->dock==scr->dock || aicon==scr->clip_icon));
panel->commandFrame = WMCreateFrame(panel->win);
WMResizeWidget(panel->commandFrame, 275, 50);
WMMoveWidget(panel->commandFrame, 10, 105);
WMMoveWidget(panel->commandFrame, 10, 130);
WMSetFrameTitle(panel->commandFrame, _("Application path and arguments"));
panel->commandField = WMCreateTextField(panel->commandFrame);
WMResizeWidget(panel->commandField, 256, 20);
WMMoveWidget(panel->commandField, 10, 20);
WMSetTextFieldText(panel->commandField, aicon->command);
panel->dndCommandFrame = WMCreateFrame(panel->win);
WMResizeWidget(panel->dndCommandFrame, 275, 70);
WMMoveWidget(panel->dndCommandFrame, 10, 165);
WMSetFrameTitle(panel->dndCommandFrame,
WMMoveWidget(panel->dndCommandFrame, 10, 190);
WMSetFrameTitle(panel->dndCommandFrame,
_("Command for files dropped with DND"));
panel->dndCommandField = WMCreateTextField(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandField, 256, 20);
WMMoveWidget(panel->dndCommandField, 10, 20);
panel->dndCommandLabel = WMCreateLabel(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandLabel, 256, 18);
WMMoveWidget(panel->dndCommandLabel, 10, 45);
#ifdef OFFIX_DND
WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command);
WMSetLabelText(panel->dndCommandLabel,
WMSetLabelText(panel->dndCommandLabel,
_("%d will be replaced with the file name"));
#else
WMSetTextFieldEditable(panel->dndCommandField, False);
WMSetLabelText(panel->dndCommandLabel,
_("DND support was not compiled in"));
_("DND support was not compiled in"));
#endif
panel->iconFrame = WMCreateFrame(panel->win);
WMResizeWidget(panel->iconFrame, 275, 50);
WMMoveWidget(panel->iconFrame, 10, 245);
WMMoveWidget(panel->iconFrame, 10, 270);
WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
panel->iconField = WMCreateTextField(panel->iconFrame);
WMResizeWidget(panel->iconField, 176, 20);
WMMoveWidget(panel->iconField, 10, 20);
WMSetTextFieldText(panel->iconField,
wDefaultGetIconFile(scr, aicon->wm_instance,
WMSetTextFieldText(panel->iconField,
wDefaultGetIconFile(scr, aicon->wm_instance,
aicon->wm_class, True));
panel->browseBtn = WMCreateCommandButton(panel->iconFrame);
WMResizeWidget(panel->browseBtn, 70, 24);
WMMoveWidget(panel->browseBtn, 195, 18);
WMSetButtonText(panel->browseBtn, _("Browse..."));
WMSetButtonAction(panel->browseBtn, chooseIconCallback, panel);
panel->okBtn = WMCreateCommandButton(panel->win);
WMResizeWidget(panel->okBtn, 80, 26);
WMMoveWidget(panel->okBtn, 200, 308);
WMMoveWidget(panel->okBtn, 200, 333);
WMSetButtonText(panel->okBtn, _("OK"));
WMSetButtonAction(panel->okBtn, panelBtnCallback, panel);
panel->cancelBtn = WMCreateCommandButton(panel->win);
WMResizeWidget(panel->cancelBtn, 80, 26);
WMMoveWidget(panel->cancelBtn, 110, 308);
WMMoveWidget(panel->cancelBtn, 110, 333);
WMSetButtonText(panel->cancelBtn, _("Cancel"));
WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel);
WMRealizeWidget(panel->win);
WMMapSubwidgets(panel->win);
WMMapSubwidgets(panel->commandFrame);
@@ -376,7 +398,7 @@ ShowDockAppSettingsPanel(WAppIcon *aicon)
XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
y = aicon->y_pos;
if (y < 0)
y = 0;
@@ -391,16 +413,16 @@ ShowDockAppSettingsPanel(WAppIcon *aicon)
} else {
x = (scr->scr_width - PWIDTH)/2;
}
panel->wwin = wManageInternalWindow(scr, parent, None,
panel->wwin = wManageInternalWindow(scr, parent, None,
_("Docked Application Settings"),
x, y, PWIDTH, PHEIGHT);
panel->wwin->client_leader = WMWidgetXID(panel->win);
panel->parent = parent;
WMMapWidget(panel->win);
wWindowMap(panel->wwin);
}
@@ -410,23 +432,23 @@ DestroyDockAppSettingsPanel(AppSettingsPanel *panel)
{
if (!panel->destroyed) {
XUnmapWindow(dpy, panel->wwin->client_win);
XReparentWindow(dpy, panel->wwin->client_win,
XReparentWindow(dpy, panel->wwin->client_win,
panel->wwin->screen_ptr->root_win, 0, 0);
wUnmanageWindow(panel->wwin, False, False);
}
panel->destroyed = 1;
/*
* kluge. If we destroy the panel before the icon chooser is closed,
* we will crash when it does close, trying to access something in the
* destroyed panel. Could use wretain()/wrelease() in the panel,
* destroyed panel. Could use wretain()/wrelease() in the panel,
* but it is not working for some reason.
*/
if (panel->choosingIcon)
if (panel->choosingIcon)
return;
WMDestroyWidget(panel->win);
WMDestroyWidget(panel->win);
XDestroyWindow(dpy, panel->parent);