Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
icon: fixup asserting dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
FauxFaux committed Sep 27, 2018
1 parent dc4ed09 commit 6ee2c9f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
13 changes: 11 additions & 2 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ union control {
STANDARD_PREFIX;
char shortcut;
} fontselect;

// region tray-icon

struct {
STANDARD_PREFIX;
intorptr handle;
} icon;

// endregion
};

#undef STANDARD_PREFIX
Expand Down Expand Up @@ -605,8 +614,8 @@ union control *ctrl_tabdelay(struct controlset *, union control *);
// region tray-icon

union control *ctrl_icon(struct controlset *s,
intorptr helpctx,
intorptr context);
intorptr helpctx,
intorptr context);

// endregion

Expand Down
6 changes: 5 additions & 1 deletion windows/wincfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
// region tray-icon

int dlg_pick_icon(void *dlg, char **iname, int inamesize, DWORD *iindex);
void dlg_icon_set(union control *ctrl, void *dlg, char const *icon);
union control *ctrl_icon(struct controlset *s,
intorptr helpctx,
intorptr context);

// endregion

Expand Down Expand Up @@ -489,7 +493,7 @@ void win_setup_config_box(struct controlbox *b,
'n',
I(TRAY_NORMAL),
"Always",
'y',
NULL,
I(TRAY_ALWAYS),
"Never",
'r',
Expand Down
30 changes: 30 additions & 0 deletions windows/winctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "pickicondialog.h"
#include "win_res.h"
#define ICONHEIGHT 20
void staticicon(struct ctlpos *cp, char *stext, char *iname, int id);

// endregion

Expand Down Expand Up @@ -1663,6 +1665,20 @@ void winctrl_layout(struct dlgparam *dp,
}
sfree(escaped);
break;

// region tray-icon

case CTRL_ICON: {
Conf *conf = (Conf *)dp->data;
num_ids = 1;
staticicon(&pos,
ctrl->icon.label,
conf_get_filename(conf, ctrl->icon.context.i)->path,
base_id);
} break;

// endregion

case CTRL_RADIO:
num_ids = ctrl->radio.nbuttons + 1; /* label as well */
{
Expand Down Expand Up @@ -2774,6 +2790,20 @@ HICON extract_icon(const char *iconpath, int smallicon)
}
}

void staticicon(struct ctlpos *cp, char *stext, char *iname, int id)
{
RECT r;
r.left = GAPBETWEEN;
r.top = cp->ypos;
r.right = cp->width;
r.bottom = ICONHEIGHT;
cp->ypos += r.bottom + GAPBETWEEN;
HWND hcontrol =
doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE | SS_ICON, 0, NULL, id);
HICON hicon = extract_icon(iname, FALSE);
SendMessage(hcontrol, STM_SETICON, (WPARAM)hicon, 0);
}

void dlg_icon_set(union control *ctrl, void *dlg, char const *icon)
{
HICON hicon;
Expand Down

0 comments on commit 6ee2c9f

Please sign in to comment.