summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_extraicons.h17
-rw-r--r--src/mir_app/src/extraicons.cpp23
2 files changed, 27 insertions, 13 deletions
diff --git a/include/m_extraicons.h b/include/m_extraicons.h
index e07384cedb..fb5b3af3d0 100644
--- a/include/m_extraicons.h
+++ b/include/m_extraicons.h
@@ -32,13 +32,13 @@ Boston, MA 02111-1307, USA.
#define EMPTY_EXTRA_ICON 0xFFFF
-//called with wparam=hContact
+// called with wparam=hContact
#define ME_CLIST_EXTRA_IMAGE_APPLY "CListFrames/OnExtraImageApply"
-//called with wparam=hContact lparam=extra
+// called with wparam=hContact lparam=extra
#define ME_CLIST_EXTRA_CLICK "CListFrames/OnExtraClick"
-//called with wparam=lparam=0
+// called with wparam=lparam=0
#define ME_CLIST_EXTRA_LIST_REBUILD "CListFrames/OnExtraListRebuild"
/*
@@ -105,17 +105,24 @@ EXTERN_C MIR_APP_DLL(void) KillModuleExtraIcons(int hLangpack);
#pragma warning(disable:4505)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#define EIF_DISABLED_BY_DEFAULT 0x0001
+
EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, const char *descIcon,
- MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int = hLangpack);
+ MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int flags = 0, int = hLangpack);
EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon = NULL,
- MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int = hLangpack);
+ MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int flags = 0, int = hLangpack);
+
+/////////////////////////////////////////////////////////////////////////////////////////
EXTERN_C MIR_APP_DLL(int) ExtraIcon_SetIcon(HANDLE hExtraIcon, MCONTACT hContact, HANDLE hImage);
EXTERN_C MIR_APP_DLL(int) ExtraIcon_SetIconByName(HANDLE hExtraIcon, MCONTACT hContact, const char *icoName);
EXTERN_C MIR_APP_DLL(int) ExtraIcon_Clear(HANDLE hExtraIcon, MCONTACT hContact);
+/////////////////////////////////////////////////////////////////////////////////////////
// Adding icon to extra image list.
// Used for EXTRAICON_TYPE_CALLBACK extra icons
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp
index 10a6bb853b..28579f98b4 100644
--- a/src/mir_app/src/extraicons.cpp
+++ b/src/mir_app/src/extraicons.cpp
@@ -328,18 +328,25 @@ void fnSetAllExtraIcons(MCONTACT hContact)
}
///////////////////////////////////////////////////////////////////////////////
-// Services
+// external functions
-static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int _hLang)
+static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int flags, int _hLang)
{
char setting[512];
mir_snprintf(setting, "Position_%s", name);
extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000));
mir_snprintf(setting, "Slot_%s", name);
- int slot = db_get_w(NULL, MODULE_NAME, setting, 1);
- if (slot == (WORD)-1)
+ int slot = db_get_w(NULL, MODULE_NAME, setting, -100);
+ if (slot == 0xFFFF)
slot = -1;
+ else if (slot == -100) {
+ if (flags & EIF_DISABLED_BY_DEFAULT) {
+ db_set_w(NULL, MODULE_NAME, setting, 0xFFFF);
+ slot = -1;
+ }
+ else slot = 1;
+ }
extra->setSlot(slot);
extra->m_hLangpack = _hLang;
@@ -381,7 +388,7 @@ static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int _hLang)
EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, const char *descIcon,
MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon,
- MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int _hLang)
+ MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags, int _hLang)
{
// EXTRAICON_TYPE_CALLBACK
if (IsEmpty(name) || IsEmpty(description))
@@ -399,12 +406,12 @@ EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const
int id = registeredExtraIcons.getCount() + 1;
BaseExtraIcon *extra = new CallbackExtraIcon(id, name, desc, descIcon == NULL ? "" : descIcon, RebuildIcons, ApplyIcon, OnClick, onClickParam);
- EI_PostCreate(extra, name, _hLang);
+ EI_PostCreate(extra, name, flags, _hLang);
return (HANDLE)id;
}
EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon,
- MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int _hLang)
+ MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags, int _hLang)
{
if (IsEmpty(name) || IsEmpty(description))
return 0;
@@ -443,7 +450,7 @@ EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const ch
int id = registeredExtraIcons.getCount() + 1;
extra = new IcolibExtraIcon(id, name, desc, descIcon == NULL ? "" : descIcon, OnClick, onClickParam);
- EI_PostCreate(extra, name, _hLang);
+ EI_PostCreate(extra, name, flags, _hLang);
return (HANDLE)id;
}