summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2009-04-13 00:26:46 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2009-04-13 00:26:46 +0000
commit19a7d971aaca383901babdc0852eadea12c3c0cd (patch)
treeb8624097ff482b694c858c008e81b22a427a9a66
parentfda46e22fa15bd77a6d1e2610e9fd9b272dc04fa (diff)
extraicons: merge more than one icon with same name and some fixes
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@161 c086bb3d-8645-0410-b8da-73a8550f86e7
-rw-r--r--Plugins/extraicons/ExtraIcon.cpp12
-rw-r--r--Plugins/extraicons/ExtraIcon.h2
-rw-r--r--Plugins/extraicons/extraicons.cpp34
-rw-r--r--Plugins/extraicons/m_extraicons.h6
-rw-r--r--Plugins/extraicons/options.cpp8
5 files changed, 50 insertions, 12 deletions
diff --git a/Plugins/extraicons/ExtraIcon.cpp b/Plugins/extraicons/ExtraIcon.cpp
index 6dd63b8..7fc60dc 100644
--- a/Plugins/extraicons/ExtraIcon.cpp
+++ b/Plugins/extraicons/ExtraIcon.cpp
@@ -21,7 +21,7 @@
ExtraIcon::ExtraIcon(const char *name, const char *description, const char *descIcon, int(*OnClick)(WPARAM wParam,
LPARAM lParam)) :
- name(name), description(Translate(description)), descIcon(descIcon), OnClick(OnClick), slot(-1)
+ name(name), description(description), descIcon(descIcon), OnClick(OnClick), slot(-1)
{
}
@@ -39,11 +39,21 @@ const char *ExtraIcon::getDescription() const
return description.c_str();
}
+void ExtraIcon::setDescription(const char *desc)
+{
+ description = desc;
+}
+
const char *ExtraIcon::getDescIcon() const
{
return descIcon.c_str();
}
+void ExtraIcon::setDescIcon(const char *icon)
+{
+ descIcon = icon;
+}
+
int ExtraIcon::getSlot() const
{
return slot;
diff --git a/Plugins/extraicons/ExtraIcon.h b/Plugins/extraicons/ExtraIcon.h
index 19db99a..1c639f0 100644
--- a/Plugins/extraicons/ExtraIcon.h
+++ b/Plugins/extraicons/ExtraIcon.h
@@ -39,7 +39,9 @@ public:
virtual const char *getName() const;
virtual const char *getDescription() const;
+ virtual void setDescription(const char *desc);
virtual const char *getDescIcon() const;
+ virtual void setDescIcon(const char *icon);
virtual int getType() const =0;
virtual int getSlot() const;
diff --git a/Plugins/extraicons/extraicons.cpp b/Plugins/extraicons/extraicons.cpp
index 61b8c68..a337a20 100644
--- a/Plugins/extraicons/extraicons.cpp
+++ b/Plugins/extraicons/extraicons.cpp
@@ -86,7 +86,7 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
return interfaces;
}
-static void RegisterIcon(char *name, char *section, char *description, int id)
+static void IcoLib_Register(char *name, char *section, char *description, int id)
{
HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) name);
if (hIcon != NULL)
@@ -121,9 +121,9 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
// Icons
- RegisterIcon("AlwaysVis", "Contact List", "Always Visible", IDI_ALWAYSVIS);
- RegisterIcon("NeverVis", "Contact List", "Never Visible", IDI_NEVERVIS);
- RegisterIcon("ChatActivity", "Contact List", "Chat Activity", IDI_CHAT);
+ IcoLib_Register("AlwaysVis", "Contact List", "Always Visible", IDI_ALWAYSVIS);
+ IcoLib_Register("NeverVis", "Contact List", "Never Visible", IDI_NEVERVIS);
+ IcoLib_Register("ChatActivity", "Contact List", "Chat Activity", IDI_CHAT);
// Hooks
@@ -280,6 +280,8 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL))
return 0;
+ const char *desc = Translate(ei->description);
+
for (unsigned int i = 0; i < extraIcons.size(); ++i)
{
ExtraIcon *extra = extraIcons[i];
@@ -288,20 +290,32 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
if (ei->type != extra->getType())
return 0;
- else
- return i + 1;
+
+ // Found one, now merge it
+
+ if (stricmp(extra->getDescription(), desc))
+ {
+ string newDesc = extra->getDescription();
+ newDesc += " / ";
+ newDesc += desc;
+ extra->setDescription(newDesc.c_str());
+ }
+
+ if (IsEmpty(extra->getDescIcon()) && !IsEmpty(ei->descIcon))
+ extra->setDescIcon(ei->descIcon);
+
+ return i + 1;
}
ExtraIcon *extra;
switch (ei->type)
{
case EXTRAICON_TYPE_CALLBACK:
- extra = new CallbackExtraIcon(ei->name, ei->description, ei->descIcon == NULL ? "" : ei->descIcon,
- ei->RebuildIcons, ei->ApplyIcon, ei->OnClick);
+ extra = new CallbackExtraIcon(ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->RebuildIcons,
+ ei->ApplyIcon, ei->OnClick);
break;
case EXTRAICON_TYPE_ICOLIB:
- extra = new IcolibExtraIcon(ei->name, ei->description, ei->descIcon == NULL ? "" : ei->descIcon,
- ei->OnClick);
+ extra = new IcolibExtraIcon(ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick);
break;
default:
return 0;
diff --git a/Plugins/extraicons/m_extraicons.h b/Plugins/extraicons/m_extraicons.h
index 01e793c..66f45dd 100644
--- a/Plugins/extraicons/m_extraicons.h
+++ b/Plugins/extraicons/m_extraicons.h
@@ -91,6 +91,9 @@ static HANDLE ExtraIcon_Register(const char *name, const char *description, cons
int (*ApplyIcon)(WPARAM wParam, LPARAM lParam),
int (*OnClick)(WPARAM wParam, LPARAM lParam) = NULL)
{
+ if (!ServiceExists(MS_EXTRAICON_REGISTER))
+ return NULL;
+
EXTRAICON_INFO ei = {0};
ei.cbSize = sizeof(ei);
ei.type = EXTRAICON_TYPE_CALLBACK;
@@ -107,6 +110,9 @@ static HANDLE ExtraIcon_Register(const char *name, const char *description, cons
static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon = NULL,
int (*OnClick)(WPARAM wParam, LPARAM lParam) = NULL)
{
+ if (!ServiceExists(MS_EXTRAICON_REGISTER))
+ return NULL;
+
EXTRAICON_INFO ei = {0};
ei.cbSize = sizeof(ei);
ei.type = EXTRAICON_TYPE_ICOLIB;
diff --git a/Plugins/extraicons/options.cpp b/Plugins/extraicons/options.cpp
index 8a0e6ba..c1b4852 100644
--- a/Plugins/extraicons/options.cpp
+++ b/Plugins/extraicons/options.cpp
@@ -210,8 +210,14 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
for (int j = 0; j < numSlots; ++j)
{
- if (SendDlgItemMessage(hwndDlg, IDC_SLOT + j * 2, CB_GETCURSEL, 0, 0) != 0)
+ // 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;