diff options
-rw-r--r-- | Plugins/extraicons/BaseExtraIcon.cpp | 22 | ||||
-rw-r--r-- | Plugins/extraicons/BaseExtraIcon.h | 4 | ||||
-rw-r--r-- | Plugins/extraicons/CallbackExtraIcon.cpp | 2 | ||||
-rw-r--r-- | Plugins/extraicons/DefaultExtraIcons.cpp | 35 | ||||
-rw-r--r-- | Plugins/extraicons/Docs/extraicons.png | bin | 40356 -> 36754 bytes | |||
-rw-r--r-- | Plugins/extraicons/Docs/extraicons_changelog.txt | 4 | ||||
-rw-r--r-- | Plugins/extraicons/Docs/extraicons_version.txt | 2 | ||||
-rw-r--r-- | Plugins/extraicons/Docs/langpack_extraicons.txt | 16 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.cpp | 24 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.h | 8 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIconGroup.cpp | 25 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIconGroup.h | 13 | ||||
-rw-r--r-- | Plugins/extraicons/IcolibExtraIcon.cpp | 4 | ||||
-rw-r--r-- | Plugins/extraicons/commons.h | 5 | ||||
-rw-r--r-- | Plugins/extraicons/extraicons.cpp | 188 | ||||
-rw-r--r-- | Plugins/extraicons/extraicons.dsp | 2 | ||||
-rw-r--r-- | Plugins/extraicons/options.cpp | 401 | ||||
-rw-r--r-- | Plugins/extraicons/res/empty.ico | bin | 0 -> 766 bytes | |||
-rw-r--r-- | Plugins/extraicons/resource.rc | 23 |
19 files changed, 376 insertions, 402 deletions
diff --git a/Plugins/extraicons/BaseExtraIcon.cpp b/Plugins/extraicons/BaseExtraIcon.cpp index 54a8a2b..f1aea54 100644 --- a/Plugins/extraicons/BaseExtraIcon.cpp +++ b/Plugins/extraicons/BaseExtraIcon.cpp @@ -21,7 +21,7 @@ BaseExtraIcon::BaseExtraIcon(int id, const char *name, const char *description, const char *descIcon,
MIRANDAHOOKPARAM OnClick, LPARAM param) :
- ExtraIcon(id, name), description(description), descIcon(descIcon), OnClick(OnClick), onClickParam(param)
+ ExtraIcon(name), id(id), description(description), descIcon(descIcon), OnClick(OnClick), onClickParam(param)
{
}
@@ -29,6 +29,17 @@ BaseExtraIcon::~BaseExtraIcon() {
}
+void BaseExtraIcon::setOnClick(MIRANDAHOOKPARAM OnClick, LPARAM param)
+{
+ this->OnClick = OnClick;
+ this->onClickParam = param;
+}
+
+int BaseExtraIcon::getID() const
+{
+ return id;
+}
+
const char *BaseExtraIcon::getDescription() const
{
return description.c_str();
@@ -57,3 +68,12 @@ void BaseExtraIcon::onClick(HANDLE hContact) OnClick((WPARAM) hContact, (LPARAM) ConvertToClistSlot(slot), onClickParam);
}
+int BaseExtraIcon::ClistSetExtraIcon(HANDLE hContact, HANDLE hImage)
+{
+ ExtraIcon *tmp = extraIconsByHandle[id - 1];
+ if (tmp != this)
+ return tmp->ClistSetExtraIcon(hContact, hImage);
+ else
+ return Clist_SetExtraIcon(hContact, slot, hImage);
+}
+
diff --git a/Plugins/extraicons/BaseExtraIcon.h b/Plugins/extraicons/BaseExtraIcon.h index 7194e68..ef225bc 100644 --- a/Plugins/extraicons/BaseExtraIcon.h +++ b/Plugins/extraicons/BaseExtraIcon.h @@ -10,6 +10,7 @@ public: LPARAM param);
virtual ~BaseExtraIcon();
+ virtual int getID() const;
virtual const char *getDescription() const;
virtual void setDescription(const char *desc);
virtual const char *getDescIcon() const;
@@ -17,9 +18,12 @@ public: virtual int getType() const =0;
virtual void onClick(HANDLE hContact);
+ virtual void setOnClick(MIRANDAHOOKPARAM OnClick, LPARAM param);
+ virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage);
protected:
+ int id;
std::string description;
std::string descIcon;
MIRANDAHOOKPARAM OnClick;
diff --git a/Plugins/extraicons/CallbackExtraIcon.cpp b/Plugins/extraicons/CallbackExtraIcon.cpp index b80675d..3f4d368 100644 --- a/Plugins/extraicons/CallbackExtraIcon.cpp +++ b/Plugins/extraicons/CallbackExtraIcon.cpp @@ -63,7 +63,7 @@ int CallbackExtraIcon::setIcon(int id, HANDLE hContact, void *icon) if (!isEnabled() || hContact == NULL || id != this->id)
return -1;
- return ClistSetExtraIcon(hContact, slot, (HANDLE) icon);
+ return ClistSetExtraIcon(hContact, (HANDLE) icon);
}
void CallbackExtraIcon::storeIcon(HANDLE hContact, void *icon)
diff --git a/Plugins/extraicons/DefaultExtraIcons.cpp b/Plugins/extraicons/DefaultExtraIcons.cpp index 100f8e8..32549be 100644 --- a/Plugins/extraicons/DefaultExtraIcons.cpp +++ b/Plugins/extraicons/DefaultExtraIcons.cpp @@ -37,8 +37,8 @@ static void DBExtraIconsInit(); void DefaultExtraIcons_Load()
{
- ProtocolInit();
DBExtraIconsInit();
+ ProtocolInit();
}
void DefaultExtraIcons_Unload()
@@ -50,6 +50,7 @@ void DefaultExtraIcons_Unload() struct Info;
HANDLE hExtraVisibility = NULL;
+HANDLE hExtraChat = NULL;
HANDLE hExtraGender = NULL;
static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear)
@@ -71,6 +72,11 @@ static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear) // Is chat
if (apparentMode == ID_STATUS_OFFLINE)
ico = "ChatActivity";
+
+ if (ico == NULL && !clear)
+ return;
+
+ ExtraIcon_SetIcon(hExtraChat, hContact, ico);
}
else
{
@@ -80,12 +86,12 @@ static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear) else if (apparentMode == ID_STATUS_ONLINE)
ico = "AlwaysVis";
- }
- if (ico == NULL && !clear)
- return;
+ if (ico == NULL && !clear)
+ return;
- ExtraIcon_SetIcon(hExtraVisibility, hContact, ico);
+ ExtraIcon_SetIcon(hExtraVisibility, hContact, ico);
+ }
}
static void SetGender(HANDLE hContact, int gender, BOOL clear)
@@ -129,16 +135,16 @@ struct Info void (*SetIcon)(HANDLE hContact, Info *info, const char *text);
void (*OnClick)(Info *info, const char *text);
HANDLE hExtraIcon;
-} infos[] = {
- { "email", "E-mail", "core_main_14", { NULL, "e-mail",
- "UserInfo", "e-mail",
- "UserInfo", "Mye-mail0" }, DefaultSetIcon, &EmailOnClick, NULL },
+} infos[] = {
+ { "homepage", "Homepage", "core_main_2", { NULL, "Homepage",
+ "UserInfo", "Homepage" }, DefaultSetIcon, &HomepageOnClick, NULL },
{ "sms", "Phone/SMS", "core_main_17", { NULL, "Cellular",
"UserInfo", "Cellular",
"UserInfo", "Phone",
- "UserInfo", "MyPhone0" }, DefaultSetIcon, NULL, NULL },
- { "homepage", "Homepage", "core_main_2", { NULL, "Homepage",
- "UserInfo", "Homepage" }, DefaultSetIcon, &HomepageOnClick, NULL },
+ "UserInfo", "MyPhone0" }, DefaultSetIcon, NULL, NULL },
+ { "email", "E-mail", "core_main_14", { NULL, "e-mail",
+ "UserInfo", "e-mail",
+ "UserInfo", "Mye-mail0" }, DefaultSetIcon, &EmailOnClick, NULL },
};
static void EmailOnClick(Info *info, const char *text)
@@ -280,6 +286,9 @@ static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) static void DBExtraIconsInit()
{
+ hExtraChat = ExtraIcon_Register("chat_activity", "Chat activity", "ChatActivity");
+ hExtraVisibility = ExtraIcon_Register("visibility", "Visibility", "AlwaysVis");
+ hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male");
for (unsigned int i = 0; i < MAX_REGS(infos); ++i)
{
Info &info = infos[i];
@@ -288,8 +297,6 @@ static void DBExtraIconsInit() else
info.hExtraIcon = ExtraIcon_Register(info.name, info.desc, info.icon);
}
- hExtraVisibility = ExtraIcon_Register("visibility", "Visibility/Chat activity", "AlwaysVis");
- hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male");
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact != NULL)
diff --git a/Plugins/extraicons/Docs/extraicons.png b/Plugins/extraicons/Docs/extraicons.png Binary files differindex 65fbbdd..9710ef5 100644 --- a/Plugins/extraicons/Docs/extraicons.png +++ b/Plugins/extraicons/Docs/extraicons.png diff --git a/Plugins/extraicons/Docs/extraicons_changelog.txt b/Plugins/extraicons/Docs/extraicons_changelog.txt index 38cc836..fdceb04 100644 --- a/Plugins/extraicons/Docs/extraicons_changelog.txt +++ b/Plugins/extraicons/Docs/extraicons_changelog.txt @@ -2,5 +2,9 @@ Extra Icons Service Changelog:
+. 0.2.0.0
+ + Allows group/ungroup of icons
+ + New options dialog
+
. 0.1.0.0
+ Initial version
\ No newline at end of file diff --git a/Plugins/extraicons/Docs/extraicons_version.txt b/Plugins/extraicons/Docs/extraicons_version.txt index 59dd7e0..860ec4e 100644 --- a/Plugins/extraicons/Docs/extraicons_version.txt +++ b/Plugins/extraicons/Docs/extraicons_version.txt @@ -1 +1 @@ -Extra Icons Service 0.1.0.0
\ No newline at end of file +Extra Icons Service 0.2.0.0
\ No newline at end of file diff --git a/Plugins/extraicons/Docs/langpack_extraicons.txt b/Plugins/extraicons/Docs/langpack_extraicons.txt index 7582444..0e97a49 100644 --- a/Plugins/extraicons/Docs/langpack_extraicons.txt +++ b/Plugins/extraicons/Docs/langpack_extraicons.txt @@ -2,22 +2,14 @@ ; Author: Pescuma
[Select the extra icons to be shown in the contact list:]
-[Slot 1]
-[Slot 2]
-[Slot 3]
-[Slot 4]
-[Slot 5]
-[Slot 6]
-[Slot 7]
-[Slot 8]
-[Slot 9]
-[Slot 10]
-[<Empty>]
[Account]
[E-mail]
[Phone/SMS]
[Homepage]
-[Visibility/Chat activity]
+[Visibility]
+[Chat activity]
[Gender]
+[* only the first %d icons will be shown]
+[You can group/ungroup icons by selecting then and using the popup menu]
diff --git a/Plugins/extraicons/ExtraIcon.cpp b/Plugins/extraicons/ExtraIcon.cpp index 696613b..52047a5 100644 --- a/Plugins/extraicons/ExtraIcon.cpp +++ b/Plugins/extraicons/ExtraIcon.cpp @@ -19,8 +19,8 @@ #include "commons.h"
-ExtraIcon::ExtraIcon(int id, const char *name) :
- id(id), name(name), slot(-1), position(1000)
+ExtraIcon::ExtraIcon(const char *name) :
+ name(name), slot(-1), position(1000)
{
}
@@ -53,11 +53,6 @@ void ExtraIcon::setPosition(int position) this->position = position;
}
-int ExtraIcon::getID() const
-{
- return id;
-}
-
bool ExtraIcon::isEnabled() const
{
return slot >= 0;
@@ -85,7 +80,14 @@ int ExtraIcon::compare(const ExtraIcon *other) const int ret = getPosition() - other->getPosition();
if (ret != 0)
return ret;
- return getID() - other->getID();
+
+ int id = 0;
+ if (getType() != EXTRAICON_TYPE_GROUP)
+ id = ((BaseExtraIcon*) this)->getID();
+ int otherId = 0;
+ if (other->getType() != EXTRAICON_TYPE_GROUP)
+ otherId = ((BaseExtraIcon*) other)->getID();
+ return id - otherId;
}
bool ExtraIcon::operator==(const ExtraIcon & other) const
@@ -123,9 +125,3 @@ bool ExtraIcon::operator>=(const ExtraIcon & other) const int c = compare(&other);
return c >= 0;
}
-
-int ExtraIcon::ClistSetExtraIcon(HANDLE hContact, int slot, HANDLE hImage)
-{
- return Clist_SetExtraIcon(hContact, slot, hImage);
-}
-
diff --git a/Plugins/extraicons/ExtraIcon.h b/Plugins/extraicons/ExtraIcon.h index 19cfb9e..03b0177 100644 --- a/Plugins/extraicons/ExtraIcon.h +++ b/Plugins/extraicons/ExtraIcon.h @@ -27,7 +27,7 @@ class ExtraIcon
{
public:
- ExtraIcon(int id, const char *name);
+ ExtraIcon(const char *name);
virtual ~ExtraIcon();
virtual void rebuildIcons() =0;
@@ -38,7 +38,6 @@ public: virtual int setIcon(int id, HANDLE hContact, void *icon) =0;
virtual void storeIcon(HANDLE hContact, void *icon) =0;
- virtual int getID() const;
virtual const char *getName() const;
virtual const char *getDescription() const =0;
virtual const char *getDescIcon() const =0;
@@ -62,14 +61,13 @@ public: bool operator>(const ExtraIcon &other) const;
bool operator>=(const ExtraIcon &other) const;
+ virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage) =0;
+
protected:
- int id;
std::string name;
int slot;
int position;
-
- virtual int ClistSetExtraIcon(HANDLE hContact, int slot, HANDLE hImage);
};
#endif // __EXTRAICON_H__
diff --git a/Plugins/extraicons/ExtraIconGroup.cpp b/Plugins/extraicons/ExtraIconGroup.cpp index 48ff791..6b46fbe 100644 --- a/Plugins/extraicons/ExtraIconGroup.cpp +++ b/Plugins/extraicons/ExtraIconGroup.cpp @@ -23,8 +23,8 @@ #include "commons.h"
-ExtraIconGroup::ExtraIconGroup(int id, const char *name) :
- ExtraIcon(id, name), setValidExtraIcon(false)
+ExtraIconGroup::ExtraIconGroup(const char *name) :
+ ExtraIcon(name), setValidExtraIcon(false)
{
char setting[512];
mir_snprintf(setting, MAX_REGS(setting), "%s/%s", MODULE_NAME, name);
@@ -36,7 +36,7 @@ ExtraIconGroup::~ExtraIconGroup() items.clear();
}
-void ExtraIconGroup::addExtraIcon(ExtraIcon *extra)
+void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra)
{
items.push_back(extra);
@@ -63,12 +63,25 @@ void ExtraIconGroup::applyIcon(HANDLE hContact) setValidExtraIcon = false;
unsigned int i;
- for (i = 0; !setValidExtraIcon && i < items.size(); ++i)
+ for (i = 0; i < items.size(); ++i)
+ {
items[i]->applyIcon(hContact);
+ if (setValidExtraIcon)
+ break;
+ }
+
DBWriteContactSettingDword(hContact, MODULE_NAME, name.c_str(), setValidExtraIcon ? items[i]->getID() : 0);
}
+void ExtraIconGroup::setSlot(int slot)
+{
+ ExtraIcon::setSlot(slot);
+
+ for (unsigned int i = 0; i < items.size(); ++i)
+ items[i]->setSlot(slot);
+}
+
ExtraIcon * ExtraIconGroup::getCurrentItem(HANDLE hContact) const
{
int id = (int) DBGetContactSettingDword(hContact, MODULE_NAME, name.c_str(), 0);
@@ -152,11 +165,11 @@ int ExtraIconGroup::getType() const return EXTRAICON_TYPE_GROUP;
}
-int ExtraIconGroup::ClistSetExtraIcon(HANDLE hContact, int slot, HANDLE hImage)
+int ExtraIconGroup::ClistSetExtraIcon(HANDLE hContact, HANDLE hImage)
{
if (hImage != NULL && hImage != (HANDLE) -1)
setValidExtraIcon = true;
- return ExtraIcon::ClistSetExtraIcon(hContact, slot, hImage);
+ return Clist_SetExtraIcon(hContact, slot, hImage);
}
diff --git a/Plugins/extraicons/ExtraIconGroup.h b/Plugins/extraicons/ExtraIconGroup.h index 1b041fa..9a4d221 100644 --- a/Plugins/extraicons/ExtraIconGroup.h +++ b/Plugins/extraicons/ExtraIconGroup.h @@ -23,13 +23,15 @@ #include <vector>
#include "ExtraIcon.h"
+class BaseExtraIcon;
+
class ExtraIconGroup : public ExtraIcon
{
public:
- ExtraIconGroup(int id, const char *name);
+ ExtraIconGroup(const char *name);
virtual ~ExtraIconGroup();
- virtual void addExtraIcon(ExtraIcon *extra);
+ virtual void addExtraIcon(BaseExtraIcon *extra);
virtual void rebuildIcons();
virtual void applyIcon(HANDLE hContact);
@@ -42,14 +44,17 @@ public: virtual const char *getDescIcon() const;
virtual int getType() const;
- std::vector<ExtraIcon*> items;
+ virtual void setSlot(int slot);
+
+ std::vector<BaseExtraIcon*> items;
+
+ virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage);
protected:
std::string description;
bool setValidExtraIcon;
virtual ExtraIcon * getCurrentItem(HANDLE hContact) const;
- virtual int ClistSetExtraIcon(HANDLE hContact, int slot, HANDLE hImage);
};
#endif // __EXTRAICONGROUP_H__
diff --git a/Plugins/extraicons/IcolibExtraIcon.cpp b/Plugins/extraicons/IcolibExtraIcon.cpp index 1e7cfbf..f7dc03c 100644 --- a/Plugins/extraicons/IcolibExtraIcon.cpp +++ b/Plugins/extraicons/IcolibExtraIcon.cpp @@ -57,7 +57,7 @@ void IcolibExtraIcon::applyIcon(HANDLE hContact) DBFreeVariant(&dbv);
}
- Clist_SetExtraIcon(hContact, slot, hImage);
+ ClistSetExtraIcon(hContact, hImage);
}
int IcolibExtraIcon::setIcon(int id, HANDLE hContact, void *icon)
@@ -89,7 +89,7 @@ int IcolibExtraIcon::setIcon(int id, HANDLE hContact, void *icon) else
hImage = AddIcon(icolibName);
- return ClistSetExtraIcon(hContact, slot, hImage);
+ return ClistSetExtraIcon(hContact, hImage);
}
return 0;
diff --git a/Plugins/extraicons/commons.h b/Plugins/extraicons/commons.h index a2d82ac..ffe0505 100644 --- a/Plugins/extraicons/commons.h +++ b/Plugins/extraicons/commons.h @@ -82,9 +82,10 @@ extern PLUGINLINK *pluginLink; extern vector<HANDLE> hHooks;
extern vector<BaseExtraIcon*> registeredExtraIcons;
-extern vector<ExtraIcon*> extraIcons;
+extern vector<ExtraIcon*> extraIconsByHandle;
+extern vector<ExtraIcon*> extraIconsBySlot;
+void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &groups);
ExtraIcon * GetExtraIconBySlot(int slot);
-ExtraIcon * GetExtraIcon(HANDLE id);
int GetNumberOfSlots();
int ConvertToClistSlot(int slot);
diff --git a/Plugins/extraicons/extraicons.cpp b/Plugins/extraicons/extraicons.cpp index 1e0dde1..370fd65 100644 --- a/Plugins/extraicons/extraicons.cpp +++ b/Plugins/extraicons/extraicons.cpp @@ -24,7 +24,7 @@ PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
"Extra Icons Service",
- PLUGIN_MAKE_VERSION(0,1,0,0),
+ PLUGIN_MAKE_VERSION(0,2,0,0),
"Extra Icons Service",
"Ricardo Pescuma Domenecci",
"",
@@ -43,8 +43,8 @@ UTF8_INTERFACE utfi; vector<HANDLE> hHooks;
vector<HANDLE> hServices;
vector<BaseExtraIcon*> registeredExtraIcons;
-vector<BaseExtraIcon*> extraIconsByHandle;
-vector<ExtraIcon*> extraIcons;
+vector<ExtraIcon*> extraIconsByHandle;
+vector<ExtraIcon*> extraIconsBySlot;
char *metacontacts_proto = NULL;
BOOL clistRebuildAlreadyCalled = FALSE;
@@ -162,6 +162,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // add our modules to the KnownModules list
CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0);
+ CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME "Groups", 0);
// updater plugin support
@@ -250,15 +251,86 @@ ExtraIcon * GetExtraIcon(HANDLE id) ExtraIcon * GetExtraIconBySlot(int slot)
{
- for (unsigned int i = 0; i < extraIcons.size(); ++i)
+ for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i)
{
- ExtraIcon *extra = extraIcons[i];
+ ExtraIcon *extra = extraIconsBySlot[i];
if (extra->getSlot() == slot)
return extra;
}
return NULL;
}
+BaseExtraIcon * GetExtraIconByName(const char *name)
+{
+ for (unsigned int i = 0; i < registeredExtraIcons.size(); ++i)
+ {
+ BaseExtraIcon *extra = registeredExtraIcons[i];
+ if (strcmp(name, extra->getName()) == 0)
+ return extra;
+ }
+ return NULL;
+}
+
+static void LoadGroups(vector<ExtraIconGroup *> &groups)
+{
+ unsigned int count = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", "Count", 0);
+ for (unsigned int i = 0; i < count; ++i)
+ {
+ char setting[512];
+ mir_snprintf(setting, MAX_REGS(setting), "%d_count", i);
+ unsigned int items = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", setting, 0);
+ if (items < 1)
+ continue;
+
+ mir_snprintf(setting, MAX_REGS(setting), "__group_%d", i);
+ ExtraIconGroup *group = new ExtraIconGroup(setting); // TODO Remove name
+
+ for (unsigned int j = 0; j < items; ++j)
+ {
+ mir_snprintf(setting, MAX_REGS(setting), "%d_%d", i, j);
+
+ DBVARIANT dbv = { 0 };
+ if (!DBGetContactSettingString(NULL, MODULE_NAME "Groups", setting, &dbv))
+ {
+ if (!IsEmpty(dbv.pszVal))
+ {
+ BaseExtraIcon *extra = GetExtraIconByName(dbv.pszVal);
+ if (extra != NULL)
+ {
+ group->items.push_back(extra);
+
+ if (extra->getSlot() >= 0)
+ group->setSlot(extra->getSlot());
+ }
+ }
+ DBFreeVariant(&dbv);
+ }
+ }
+
+ if (group->items.size() < 2)
+ {
+ delete group;
+ continue;
+ }
+
+ groups.push_back(group);
+ }
+}
+
+static ExtraIconGroup * IsInGroup(vector<ExtraIconGroup *> &groups, BaseExtraIcon *extra)
+{
+ for (unsigned int i = 0; i < groups.size(); ++i)
+ {
+ ExtraIconGroup *group = groups[i];
+ for (unsigned int j = 0; j < group->items.size(); ++j)
+ {
+ if (extra == group->items[j])
+ return group;
+ }
+ }
+ return NULL;
+}
+
struct compareFunc : std::binary_function<const ExtraIcon *, const ExtraIcon *, bool>
{
bool operator()(const ExtraIcon * one, const ExtraIcon * two) const
@@ -267,6 +339,42 @@ struct compareFunc : std::binary_function<const ExtraIcon *, const ExtraIcon *, }
};
+void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &groups)
+{
+ unsigned int i;
+ for (i = 0; i < extraIconsByHandle.size(); ++i)
+ extraIconsByHandle[i] = registeredExtraIcons[i];
+
+ for (i = 0; i < extraIconsBySlot.size(); ++i)
+ {
+ ExtraIcon *extra = extraIconsBySlot[i];
+ if (extra->getType() != EXTRAICON_TYPE_GROUP)
+ continue;
+
+ delete extra;
+ }
+ extraIconsBySlot.clear();
+
+ for (i = 0; i < groups.size(); ++i)
+ {
+ ExtraIconGroup *group = groups[i];
+
+ for (unsigned int j = 0; j < group->items.size(); ++j)
+ extraIconsByHandle[group->items[j]->getID() - 1] = group;
+
+ extraIconsBySlot.push_back(group);
+ }
+
+ for (i = 0; i < extraIconsByHandle.size(); ++i)
+ {
+ ExtraIcon *extra = extraIconsByHandle[i];
+ if (extra->getType() != EXTRAICON_TYPE_GROUP)
+ extraIconsBySlot.push_back(extra);
+ }
+
+ std::sort(extraIconsBySlot.begin(), extraIconsBySlot.end(), compareFunc());
+}
+
int ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
{
if (wParam == 0)
@@ -284,13 +392,10 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam) const char *desc = Translate(ei->description);
- for (unsigned int i = 0; i < registeredExtraIcons.size(); ++i)
+ BaseExtraIcon *extra = GetExtraIconByName(ei->name);
+ if (extra != NULL)
{
- BaseExtraIcon *extra = registeredExtraIcons[i];
- if (strcmp(ei->name, extra->getName()) != 0)
- continue;
-
- if (ei->type != extra->getType())
+ if (ei->type != extra->getType() || ei->type != EXTRAICON_TYPE_CALLBACK)
return 0;
// Found one, now merge it
@@ -304,15 +409,25 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam) extra->setDescription(newDesc.c_str());
}
- if (IsEmpty(extra->getDescIcon()) && !IsEmpty(ei->descIcon))
+ if (!IsEmpty(ei->descIcon))
extra->setDescIcon(ei->descIcon);
- return i + 1;
+ if (ei->OnClick != NULL)
+ extra->setOnClick(ei->OnClick, ei->onClickParam);
+
+ if (extra->getSlot() > 0)
+ {
+ if (clistRebuildAlreadyCalled)
+ extra->rebuildIcons();
+ if (clistApplyAlreadyCalled)
+ extraIconsByHandle[extra->getID() - 1]->applyIcons();
+ }
+
+ return extra->getID();
}
int id = registeredExtraIcons.size() + 1;
- BaseExtraIcon *extra;
switch (ei->type)
{
case EXTRAICON_TYPE_CALLBACK:
@@ -339,28 +454,40 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam) registeredExtraIcons.push_back(extra);
extraIconsByHandle.push_back(extra);
- extraIcons.push_back(extra);
- if (slot >= 0)
+ vector<ExtraIconGroup *> groups;
+ LoadGroups(groups);
+
+ ExtraIconGroup *group = IsInGroup(groups, extra);
+ if (group != NULL)
{
- vector<BaseExtraIcon *> tmp;
- tmp = registeredExtraIcons;
- std::sort(tmp.begin(), tmp.end(), compareFunc());
+ RebuildListsBasedOnGroups(groups);
+ }
+ else
+ {
+ for (unsigned int i = 0; i < groups.size(); ++i)
+ delete groups[i];
+
+ extraIconsBySlot.push_back(extra);
+ std::sort(extraIconsBySlot.begin(), extraIconsBySlot.end(), compareFunc());
+ }
+ if (slot >= 0 || group != NULL)
+ {
if (clistRebuildAlreadyCalled)
extra->rebuildIcons();
slot = 0;
- for (unsigned int i = 0; i < tmp.size(); ++i)
+ for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i)
{
- ExtraIcon *ex = tmp[i];
+ ExtraIcon *ex = extraIconsBySlot[i];
if (ex->getSlot() < 0)
continue;
int oldSlot = ex->getSlot();
ex->setSlot(slot++);
- if (clistApplyAlreadyCalled && (ex == extra || oldSlot != slot))
+ if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot))
extra->applyIcons();
}
}
@@ -392,8 +519,8 @@ int ClistExtraListRebuild(WPARAM wParam, LPARAM lParam) ResetIcons();
- for (unsigned int i = 0; i < registeredExtraIcons.size(); ++i)
- registeredExtraIcons[i]->rebuildIcons();
+ for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i)
+ extraIconsBySlot[i]->rebuildIcons();
return 0;
}
@@ -406,8 +533,8 @@ int ClistExtraImageApply(WPARAM wParam, LPARAM lParam) clistApplyAlreadyCalled = TRUE;
- for (unsigned int i = 0; i < registeredExtraIcons.size(); ++i)
- registeredExtraIcons[i]->applyIcon(hContact);
+ for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i)
+ extraIconsBySlot[i]->applyIcon(hContact);
return 0;
}
@@ -418,13 +545,14 @@ int ClistExtraClick(WPARAM wParam, LPARAM lParam) if (hContact == NULL)
return 0;
- int extra = (int) lParam;
+ int clistSlot = (int) lParam;
- for (unsigned int i = 0; i < registeredExtraIcons.size(); ++i)
+ for (unsigned int i = 0; i < extraIconsBySlot.size(); ++i)
{
- if (ConvertToClistSlot(registeredExtraIcons[i]->getSlot()) == extra)
+ ExtraIcon *extra = extraIconsBySlot[i];
+ if (ConvertToClistSlot(extra->getSlot()) == clistSlot)
{
- registeredExtraIcons[i]->onClick(hContact);
+ extra->onClick(hContact);
break;
}
}
diff --git a/Plugins/extraicons/extraicons.dsp b/Plugins/extraicons/extraicons.dsp index ba2d1e4..7350649 100644 --- a/Plugins/extraicons/extraicons.dsp +++ b/Plugins/extraicons/extraicons.dsp @@ -57,7 +57,7 @@ BSC32=bscmake.exe LINK32=link.exe
# ADD BASE LINK32 user32.lib shell32.lib wininet.lib gdi32.lib /nologo /base:"0x67100000" /dll /machine:I386 /filealign:0x200
# SUBTRACT BASE LINK32 /pdb:none /map
-# ADD LINK32 shell32.lib kernel32.lib user32.lib gdi32.lib /nologo /base:"0x3EC20000" /dll /map /machine:I386 /out:"..\..\bin\release\Plugins\extraicons.dll" /filealign:0x200 /ALIGN:4096 /ignore:4108
+# ADD LINK32 shell32.lib kernel32.lib user32.lib gdi32.lib comctl32.lib /nologo /base:"0x3EC20000" /dll /map /machine:I386 /out:"..\..\bin\release\Plugins\extraicons.dll" /filealign:0x200 /ALIGN:4096 /ignore:4108
# SUBTRACT LINK32 /profile /pdb:none
!ELSEIF "$(CFG)" == "extraicons - Win32 Debug"
diff --git a/Plugins/extraicons/options.cpp b/Plugins/extraicons/options.cpp index f38652f..75f8a56 100644 --- a/Plugins/extraicons/options.cpp +++ b/Plugins/extraicons/options.cpp @@ -98,248 +98,6 @@ static void RemoveExtraIcons(int slot) }
}
-/*
- static BOOL CALLBACK OptionsDlgProcOld(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- static int numSlots;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- numSlots = GetNumberOfSlots();
-
- RECT rcLabel;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_SLOT_L), &rcLabel);
- ScreenToClient(hwndDlg, &rcLabel);
-
- RECT rcCombo;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_SLOT), &rcCombo);
- ScreenToClient(hwndDlg, &rcCombo);
-
- HFONT hFont = (HFONT) SendMessage(hwndDlg, WM_GETFONT, 0, 0);
-
- int height = MAX(rcLabel.bottom - rcLabel.top, rcCombo.bottom - rcCombo.top) + 3;
-
- for (int i = 0; i < numSlots; ++i)
- {
- int id = IDC_SLOT + i * 2;
-
-
- // Create controls
- if (i > 0)
- {
- char desc[256];
- mir_snprintf(desc, MAX_REGS(desc), "Slot %d:", i + 1);
-
- HWND tmp = CreateWindow("STATIC", Translate(desc),
- WS_CHILD | WS_VISIBLE,
- rcLabel.left, rcLabel.top + i * height,
- rcLabel.right - rcLabel.left, rcLabel.bottom - rcLabel.top,
- hwndDlg, 0, hInst, NULL);
- SendMessage(tmp, WM_SETFONT, (WPARAM) hFont, FALSE);
-
- HWND combo = CreateWindow("COMBOBOX", "",
- WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | WS_VSCROLL
- | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS,
- rcCombo.left, rcCombo.top + i * height,
- rcCombo.right - rcCombo.left, rcCombo.bottom - rcCombo.top,
- hwndDlg, (HMENU) id, hInst, NULL);
- SendMessage(combo, WM_SETFONT, (WPARAM) hFont, FALSE);
- }
-
- // Fill combo
- int sel = 0;
- SendDlgItemMessage(hwndDlg, id, CB_ADDSTRING, 0, (LPARAM) Translate("<Empty>"));
- for (int j = 0; j < (int) extraIcons.size(); ++j)
- {
- ExtraIcon *extra = extraIcons[j];
-
- int pos = SendDlgItemMessage(hwndDlg, id, CB_ADDSTRING, 0, (LPARAM) extra->getDescription());
- SendDlgItemMessage(hwndDlg, id, CB_SETITEMDATA, pos, (DWORD) extra);
-
- if (extra->getSlot() == i)
- sel = j + 1;
- }
- SendDlgItemMessage(hwndDlg, id, CB_SETCURSEL, sel, 0);
- }
-
- break;
- }
- case WM_COMMAND:
- {
- HWND cbl = (HWND) lParam;
- if (HIWORD(wParam) != CBN_SELCHANGE || cbl != GetFocus())
- return 0;
-
- int sel = SendMessage(cbl, CB_GETCURSEL, 0, 0);
- if (sel > 0)
- {
- for (int i = 0; i < numSlots; ++i)
- {
- int id = IDC_SLOT + i * 2;
-
- if (GetDlgItem(hwndDlg, id) == cbl)
- continue;
-
- int sl = SendDlgItemMessage(hwndDlg, id, CB_GETCURSEL, 0, 0);
- if (sl == sel)
- SendDlgItemMessage(hwndDlg, id, CB_SETCURSEL, 0, 0);
- }
- }
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- LPNMHDR lpnmhdr = (LPNMHDR) lParam;
-
- if (lpnmhdr->idFrom == 0 && lpnmhdr->code == (UINT) PSN_APPLY)
- {
- int * slots = new int[extraIcons.size()];
-
- int i;
- for (i = 0; i < (int) extraIcons.size(); ++i)
- slots[i] = -1;
-
- for (i = 0; i < (int) extraIcons.size(); ++i)
- {
- if (slots[i] != -1)
- continue;
-
- for (int j = 0; j < numSlots; ++j)
- {
- if (SendDlgItemMessage(hwndDlg, IDC_SLOT + j * 2, CB_GETCURSEL, 0, 0) == i + 1)
- {
- slots[i] = j;
- break;
- }
- }
- }
-
- for (int j = 0; j < numSlots; ++j)
- {
- // Has icon?
- bool found = false;
- for (i = 0; !found && i < (int) extraIcons.size(); ++i)
- found = (slots[i] == j);
- if (found)
- continue;
-
- // Had icon?
- if (GetExtraIconBySlot(j) == NULL)
- continue;
-
-
- // Had and icon and lost
- RemoveExtraIcons(j);
- }
-
- for (i = 0; i < (int) extraIcons.size(); ++i)
- {
- ExtraIcon *extra = extraIcons[i];
-
- int oldSlot = extra->getSlot();
- if (oldSlot == slots[i])
- continue;
-
- extra->setSlot(slots[i]);
-
- char setting[512];
- mir_snprintf(setting, MAX_REGS(setting), "Slot_%s", extra->getName());
- DBWriteContactSettingWord(NULL, MODULE_NAME, setting, extra->getSlot());
-
- extra->applyIcons();
- }
-
- delete[] slots;
- }
-
- break;
- }
- case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
- if ((lpdis->CtlID % 2) != 0)
- break;
- int slot = (lpdis->CtlID - IDC_SLOT) / 2;
- if (slot < 0 || slot > numSlots * 2)
- break;
- if (lpdis->itemID == (UINT) -1)
- break;
-
- ExtraIcon *extra = (ExtraIcon *) lpdis->itemData;
-
- TEXTMETRIC tm;
- RECT rc;
-
- GetTextMetrics(lpdis->hDC, &tm);
-
- COLORREF clrfore = SetTextColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED
- ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
- COLORREF clrback = SetBkColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT
- : COLOR_WINDOW));
-
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT
- : COLOR_WINDOW));
-
- rc.left = lpdis->rcItem.left + 2;
-
-
- // Draw icon
- HICON hIcon = NULL;
- if (extra != NULL && !IsEmpty(extra->getDescIcon()))
- hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) extra->getDescIcon());
- if (hIcon != NULL)
- {
- rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2;
- DrawIconEx(lpdis->hDC, rc.left, rc.top, hIcon, 16, 16, 0, NULL, DI_NORMAL);
- CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0);
- }
-
- rc.left += ICON_SIZE + 4;
-
-
- // Draw text
- rc.right = lpdis->rcItem.right - 2;
- rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
- rc.bottom = rc.top + tm.tmHeight;
- DrawText(lpdis->hDC, extra == NULL ? Translate("<Empty>") : extra->getDescription(), -1, &rc,
- DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
-
-
- // Restore old colors
- SetTextColor(lpdis->hDC, clrfore);
- SetBkColor(lpdis->hDC, clrback);
-
- return TRUE;
- }
-
- case WM_MEASUREITEM:
- {
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
- if ((lpmis->CtlID % 2) != 0)
- break;
- int slot = (lpmis->CtlID - IDC_SLOT) / 2;
- if (slot < 0 || slot > numSlots * 2)
- break;
-
- TEXTMETRIC tm;
- GetTextMetrics(GetDC(hwndDlg), &tm);
-
- lpmis->itemHeight = MAX(ICON_SIZE, tm.tmHeight);
-
- return TRUE;
- }
- }
-
- return 0;
- }
- */
-
#ifndef TVIS_FOCUSED
#define TVIS_FOCUSED 1
#endif
@@ -494,7 +252,7 @@ static vector<int> * Tree_GetIDs(HWND tree, HTREEITEM hItem) return (vector<int> *) tvi.lParam;
}
-static HTREEITEM Tree_AddExtraIcon(HWND tree, ExtraIcon *extra, bool selected, HTREEITEM hAfter = TVI_LAST)
+static HTREEITEM Tree_AddExtraIcon(HWND tree, BaseExtraIcon *extra, bool selected, HTREEITEM hAfter = TVI_LAST)
{
vector<int> *ids = new vector<int> ;
ids->push_back(extra->getID());
@@ -518,7 +276,7 @@ static HTREEITEM Tree_AddExtraIconGroup(HWND tree, vector<int> &group, bool sele int img = 0;
for (unsigned int i = 0; i < group.size(); ++i)
{
- ExtraIcon *extra = GetExtraIcon((HANDLE) group[i]);
+ BaseExtraIcon *extra = registeredExtraIcons[group[i] - 1];
ids->push_back(extra->getID());
if (img == 0 && !IsEmpty(extra->getDescIcon()))
@@ -580,6 +338,8 @@ static void GroupSelectedItems(HWND tree) return; // None selected
// Add new
+ int ii = ids.at(0);
+ ii = ids.at(1);
HTREEITEM hNew = Tree_AddExtraIconGroup(tree, ids, selected, hPlace);
@@ -608,7 +368,7 @@ static void UngroupSelectedItems(HWND tree) for (unsigned int i = ids->size(); i > 0; --i)
{
- ExtraIcon *extra = GetExtraIcon((HANDLE) (*ids)[i - 1]);
+ BaseExtraIcon *extra = registeredExtraIcons[ids->at(i - 1) - 1];
Tree_AddExtraIcon(tree, extra, selected, hItem);
}
@@ -630,7 +390,7 @@ static int ShowPopup(HWND hwndDlg, int popup) Tree_DropHilite(tree, hItem);
hItem = TreeView_GetNextSibling(tree, hItem);
}
-// InvalidateRect(tree, NULL, FALSE);
+ // InvalidateRect(tree, NULL, FALSE);
HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_OPT_POPUP));
HMENU submenu = GetSubMenu(menu, popup);
@@ -642,6 +402,7 @@ static int ShowPopup(HWND hwndDlg, int popup) DestroyMenu(menu);
+
// Revert selection
hItem = TreeView_GetRoot(tree);
while (hItem)
@@ -658,9 +419,7 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor {
vector<int> *a = (vector<int> *) lParam1;
vector<int> *b = (vector<int> *) lParam2;
- int aid = (*a)[0];
- int bid = (*b)[0];
- return GetExtraIcon((HANDLE) aid)->compare(GetExtraIcon((HANDLE) bid));
+ return registeredExtraIcons[a->at(0) - 1]->compare(registeredExtraIcons[b->at(0) - 1]);
}
static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -720,9 +479,9 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
TreeView_SetImageList(tree, hImageList, TVSIL_NORMAL);
- for (i = 0; i < extraIcons.size(); ++i)
+ for (i = 0; i < extraIconsBySlot.size(); ++i)
{
- ExtraIcon *extra = extraIcons[i];
+ ExtraIcon *extra = extraIconsBySlot[i];
if (extra->getType() == EXTRAICON_TYPE_GROUP)
{
@@ -730,11 +489,11 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA vector<int> ids;
for (unsigned int j = 0; j < group->items.size(); ++j)
ids.push_back(group->items[j]->getID());
- Tree_AddExtraIconGroup(tree, ids, extra->getSlot() >= 0);
+ Tree_AddExtraIconGroup(tree, ids, extra->isEnabled());
}
else
{
- Tree_AddExtraIcon(tree, extra, extra->getSlot() >= 0);
+ Tree_AddExtraIcon(tree, (BaseExtraIcon *) extra, extra->isEnabled());
}
}
@@ -748,11 +507,6 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return TRUE;
}
- case WM_COMMAND:
- {
- // SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
- break;
- }
case WM_NOTIFY:
{
LPNMHDR lpnmhdr = (LPNMHDR) lParam;
@@ -760,19 +514,32 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
if (lpnmhdr->code == (UINT) PSN_APPLY)
{
- int *slots = new int[registeredExtraIcons.size()];
-
unsigned int i;
- for (i = 0; i < registeredExtraIcons.size(); ++i)
- slots[i] = -1;
HWND tree = GetDlgItem(hwndDlg, IDC_EXTRAORDER);
- // Get positions and slots
- HTREEITEM ht = TreeView_GetRoot(tree);
+ // Store old slots
+ int *oldSlots = new int[registeredExtraIcons.size()];
+ int lastUsedSlot = -1;
+ for (i = 0; i < registeredExtraIcons.size(); ++i)
+ {
+ if (extraIconsByHandle[i] == registeredExtraIcons[i])
+ oldSlots[i] = registeredExtraIcons[i]->getSlot();
+ else
+ // Remove old slot for groups to re-set images
+ oldSlots[i] = -1;
+ lastUsedSlot = MAX(lastUsedSlot, registeredExtraIcons[i]->getSlot());
+ }
+ lastUsedSlot = MIN(lastUsedSlot, GetNumberOfSlots());
+
+
+ // Get user data and create new groups
+ vector<ExtraIconGroup *> groups;
+
BYTE pos = 0;
- unsigned int firstEmptySlot = 0;
+ int firstEmptySlot = 0;
+ HTREEITEM ht = TreeView_GetRoot(tree);
TVITEM tvi = { 0 };
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
tvi.stateMask = TVIS_STATEIMAGEMASK;
@@ -781,24 +548,46 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA tvi.hItem = ht;
TreeView_GetItem(tree, &tvi);
- ExtraIcon *extra = (ExtraIcon *) tvi.lParam;
- extra->setPosition(pos);
- if ((tvi.state & INDEXTOSTATEIMAGEMASK(3)) == INDEXTOSTATEIMAGEMASK(2))
- slots[extra->getID() - 1] = firstEmptySlot++;
+ vector<int> *ids = (vector<int> *) tvi.lParam;
+ if (ids == NULL || ids->size() < 1)
+ continue; // ???
- ht = TreeView_GetNextSibling(tree, ht);
- pos++;
- }
+ bool enabled = ((tvi.state & INDEXTOSTATEIMAGEMASK(3)) == INDEXTOSTATEIMAGEMASK(2));
+ int slot = (enabled ? firstEmptySlot++ : -1);
+ if (slot >= GetNumberOfSlots())
+ slot = -1;
- // Clean removed slots
- for (int j = firstEmptySlot; j < GetNumberOfSlots(); ++j)
- {
- if (GetExtraIconBySlot(j) != NULL)
- // Had and icon and lost
- RemoveExtraIcons(j);
+ if (ids->size() == 1)
+ {
+ BaseExtraIcon *extra = registeredExtraIcons[ids->at(0) - 1];
+ extra->setPosition(pos++);
+ extra->setSlot(slot);
+ }
+ else
+ {
+ char name[128];
+ mir_snprintf(name, MAX_REGS(name), "__group_%d", groups.size());
+
+ ExtraIconGroup *group = new ExtraIconGroup(name);
+ group->setPosition(pos);
+
+ for (i = 0; i < ids->size(); ++i)
+ {
+ BaseExtraIcon *extra = registeredExtraIcons[ids->at(i) - 1];
+ extra->setPosition(pos++);
+
+ group->addExtraIcon(extra);
+ }
+
+ group->setSlot(slot);
+
+ groups.push_back(group);
+ }
+
+ ht = TreeView_GetNextSibling(tree, ht);
}
- // Apply icons to new slots
+ // Store data
for (i = 0; i < registeredExtraIcons.size(); ++i)
{
ExtraIcon *extra = registeredExtraIcons[i];
@@ -807,22 +596,50 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA mir_snprintf(setting, MAX_REGS(setting), "Position_%s", extra->getName());
DBWriteContactSettingWord(NULL, MODULE_NAME, setting, extra->getPosition());
- int oldSlot = extra->getSlot();
- if (oldSlot == slots[i])
- continue;
-
- extra->setSlot(slots[i]);
-
mir_snprintf(setting, MAX_REGS(setting), "Slot_%s", extra->getName());
DBWriteContactSettingWord(NULL, MODULE_NAME, setting, extra->getSlot());
+ }
+
+ CallService(MS_DB_MODULE_DELETE, 0, (LPARAM) MODULE_NAME "Groups");
+ DBWriteContactSettingWord(NULL, MODULE_NAME "Groups", "Count", groups.size());
+ for (i = 0; i < groups.size(); ++i)
+ {
+ ExtraIconGroup *group = groups[i];
+
+ char setting[512];
+ mir_snprintf(setting, MAX_REGS(setting), "%d_count", i);
+ DBWriteContactSettingWord(NULL, MODULE_NAME "Groups", setting, group->items.size());
+
+ for (unsigned int j = 0; j < group->items.size(); ++j)
+ {
+ BaseExtraIcon *extra = group->items[j];
- if (slots[i] < 0)
- continue;
+ mir_snprintf(setting, MAX_REGS(setting), "%d_%d", i, j);
+ DBWriteContactSettingString(NULL, MODULE_NAME "Groups", setting, extra->getName());
+ }
+ }
+
+ // Clean removed slots
+ for (int j = firstEmptySlot; j <= lastUsedSlot; ++j)
+ RemoveExtraIcons(j);
+
+
+ // Apply icons to new slots
+ RebuildListsBasedOnGroups(groups);
+ for (i = 0; i < extraIconsBySlot.size(); ++i)
+ {
+ ExtraIcon *extra = extraIconsBySlot[i];
+
+ if (extra->getType() != EXTRAICON_TYPE_GROUP)
+ {
+ if (oldSlots[((BaseExtraIcon *) extra)->getID() - 1] == extra->getSlot())
+ continue;
+ }
extra->applyIcons();
}
- delete[] slots;
+ delete[] oldSlots;
return TRUE;
}
@@ -884,15 +701,23 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (sels > 1)
{
if (ShowPopup(hwndDlg, 0) == ID_GROUP)
+ {
GroupSelectedItems(tree);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
+ }
}
else if (sels == 1)
{
HTREEITEM hItem = TreeView_GetSelection(tree);
vector<int> *ids = Tree_GetIDs(tree, hItem);
if (ids->size() > 1)
+ {
if (ShowPopup(hwndDlg, 1) == ID_UNGROUP)
+ {
UngroupSelectedItems(tree);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM) hwndDlg, 0);
+ }
+ }
}
break;
}
diff --git a/Plugins/extraicons/res/empty.ico b/Plugins/extraicons/res/empty.ico Binary files differnew file mode 100644 index 0000000..8ba9328 --- /dev/null +++ b/Plugins/extraicons/res/empty.ico diff --git a/Plugins/extraicons/resource.rc b/Plugins/extraicons/resource.rc index 9fa2167..0ca7b35 100644 --- a/Plugins/extraicons/resource.rc +++ b/Plugins/extraicons/resource.rc @@ -27,19 +27,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // Dialog
//
-IDD_OPTIONS_OLD DIALOGEX 0, 0, 276, 229
-STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- LTEXT "Select the extra icons to be shown in the contact list:",
- IDC_STATIC,1,9,274,13
- LTEXT "Slot 1:",IDC_SLOT_L,1,31,21,8
- COMBOBOX IDC_SLOT,35,28,173,60,CBS_DROPDOWNLIST |
- CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | WS_VSCROLL |
- WS_TABSTOP
-END
-
IDD_OPTIONS DIALOGEX 0, 0, 276, 229
STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
@@ -52,6 +39,8 @@ BEGIN WS_TABSTOP,1,24,274,160
LTEXT "* only the first %d icons will be shown",
IDC_MAX_ICONS_L,1,190,274,13,NOT WS_VISIBLE
+ LTEXT "You can group/ungroup icons by selecting then and using the popup menu",
+ IDC_STATIC,1,208,274,20
END
@@ -63,14 +52,6 @@ END #ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
- IDD_OPTIONS_OLD, DIALOG
- BEGIN
- LEFTMARGIN, 1
- RIGHTMARGIN, 275
- TOPMARGIN, 1
- BOTTOMMARGIN, 228
- END
-
IDD_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 1
|