~vish/ubuntu/maverick/pidgin/bug25979

« back to all changes in this revision

Viewing changes to pidgin/pidginstock.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-10-09 19:40:26 UTC
  • mfrom: (1.4.1 upstream) (46.1.10 karmic)
  • Revision ID: james.westby@ubuntu.com-20091009194026-wbqqh0bsbz19nx5q
Tags: 1:2.6.2-1ubuntu7
* Don't stick the buddy list window to all desktops as some
  window managers have trouble to properly unstick it (LP: #346840)
  - debian/patches/11_buddy_list_really_show.patch
* Always use default tray icon size on KDE (LP: #209440)
  - debian/patches/62_tray_icon_size_kde.patch
* Use scrollbars in the preferences dialog if the screen height is
  below 700 px instead of 600 px
  - debian/patches/60_1024x600_gtkprefs.c.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 */
27
27
#include "internal.h"
28
28
#include "pidgin.h"
 
29
#include "prefs.h"
 
30
 
 
31
#include "gtkicon-theme-loader.h"
 
32
#include "theme-manager.h"
29
33
 
30
34
#include "pidginstock.h"
31
35
 
 
36
/**************************************************************************
 
37
 * Globals
 
38
 **************************************************************************/
 
39
 
 
40
static gboolean stock_initted = FALSE;
 
41
static GtkIconSize microscopic, extra_small, small, medium, large, huge;
 
42
 
 
43
/**************************************************************************
 
44
 * Structures
 
45
 **************************************************************************/
 
46
 
32
47
static struct StockIcon
33
48
{
34
49
        const char *name;
35
50
        const char *dir;
36
51
        const char *filename;
37
52
 
38
 
} const stock_icons[] =
39
 
{
 
53
} const stock_icons[] = {
 
54
 
40
55
        { PIDGIN_STOCK_ACTION,          NULL,      GTK_STOCK_EXECUTE          },
41
56
#if GTK_CHECK_VERSION(2,6,0)
42
57
        { PIDGIN_STOCK_ALIAS,           NULL,      GTK_STOCK_EDIT             },
98
113
        { PIDGIN_STOCK_EDIT,                N_("_Edit"),       0, 0, NULL }
99
114
};
100
115
 
101
 
static struct SizedStockIcon {
102
 
  const char *name;
103
 
  const char *dir;
104
 
  const char *filename;
105
 
  gboolean microscopic;
106
 
  gboolean extra_small;
107
 
  gboolean small;
108
 
  gboolean medium;
109
 
  gboolean large;
110
 
  gboolean huge;
111
 
  gboolean rtl;
112
 
  const char *translucent_name;
113
 
} const sized_stock_icons [] = {
114
 
        { PIDGIN_STOCK_STATUS_AVAILABLE,   "status", "available.png",   TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, PIDGIN_STOCK_STATUS_AVAILABLE_I },
115
 
        { PIDGIN_STOCK_STATUS_AWAY,        "status", "away.png",        TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, PIDGIN_STOCK_STATUS_AWAY_I },
116
 
        { PIDGIN_STOCK_STATUS_BUSY,     "status", "busy.png",           TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, PIDGIN_STOCK_STATUS_BUSY_I },
117
 
        { PIDGIN_STOCK_STATUS_CHAT,     "status", "chat.png",           TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
118
 
        { PIDGIN_STOCK_STATUS_INVISIBLE,"status", "invisible.png",      TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
119
 
        { PIDGIN_STOCK_STATUS_XA,       "status", "extended-away.png",  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, PIDGIN_STOCK_STATUS_XA_I },
120
 
        { PIDGIN_STOCK_STATUS_LOGIN,    "status", "log-in.png",         TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
121
 
        { PIDGIN_STOCK_STATUS_LOGOUT,   "status", "log-out.png",        TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
122
 
        { PIDGIN_STOCK_STATUS_OFFLINE,  "status", "offline.png",        TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, PIDGIN_STOCK_STATUS_OFFLINE_I  },
123
 
        { PIDGIN_STOCK_STATUS_PERSON,   "status", "person.png",         TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
124
 
        { PIDGIN_STOCK_STATUS_MESSAGE,  "toolbar", "message-new.png",   TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
125
 
        
126
 
        { PIDGIN_STOCK_STATUS_IGNORED,  "emblems", "blocked.png",       FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
127
 
        { PIDGIN_STOCK_STATUS_FOUNDER,  "emblems", "founder.png",       FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
128
 
        { PIDGIN_STOCK_STATUS_OPERATOR, "emblems", "operator.png",      FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
129
 
        { PIDGIN_STOCK_STATUS_HALFOP,   "emblems", "half-operator.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
130
 
        { PIDGIN_STOCK_STATUS_VOICE,    "emblems", "voice.png",         FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
131
 
 
132
 
        { PIDGIN_STOCK_DIALOG_AUTH,     "dialogs", "auth.png",          FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
133
 
        { PIDGIN_STOCK_DIALOG_COOL,     "dialogs", "cool.png",          FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
134
 
        { PIDGIN_STOCK_DIALOG_ERROR,    "dialogs", "error.png",         FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
135
 
        { PIDGIN_STOCK_DIALOG_INFO,     "dialogs", "info.png",          FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
136
 
        { PIDGIN_STOCK_DIALOG_MAIL,     "dialogs", "mail.png",          FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
137
 
        { PIDGIN_STOCK_DIALOG_QUESTION, "dialogs", "question.png",      FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
138
 
        { PIDGIN_STOCK_DIALOG_WARNING,  "dialogs", "warning.png",       FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, NULL  },
139
 
 
140
 
        { PIDGIN_STOCK_ANIMATION_CONNECT0, "animations", "process-working0.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
141
 
        { PIDGIN_STOCK_ANIMATION_CONNECT1, "animations", "process-working1.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
142
 
        { PIDGIN_STOCK_ANIMATION_CONNECT2, "animations", "process-working2.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
143
 
        { PIDGIN_STOCK_ANIMATION_CONNECT3, "animations", "process-working3.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
144
 
        { PIDGIN_STOCK_ANIMATION_CONNECT4, "animations", "process-working4.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
145
 
        { PIDGIN_STOCK_ANIMATION_CONNECT5, "animations", "process-working5.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
146
 
        { PIDGIN_STOCK_ANIMATION_CONNECT6, "animations", "process-working6.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
147
 
        { PIDGIN_STOCK_ANIMATION_CONNECT7, "animations", "process-working7.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
148
 
        { PIDGIN_STOCK_ANIMATION_CONNECT8, "animations", "process-working8.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
149
 
        { PIDGIN_STOCK_ANIMATION_CONNECT9, "animations", "process-working9.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
150
 
        { PIDGIN_STOCK_ANIMATION_CONNECT10, "animations", "process-working10.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
151
 
        { PIDGIN_STOCK_ANIMATION_CONNECT11, "animations", "process-working11.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
152
 
        { PIDGIN_STOCK_ANIMATION_CONNECT12, "animations", "process-working12.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
153
 
        { PIDGIN_STOCK_ANIMATION_CONNECT13, "animations", "process-working13.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
154
 
        { PIDGIN_STOCK_ANIMATION_CONNECT14, "animations", "process-working14.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
155
 
        { PIDGIN_STOCK_ANIMATION_CONNECT15, "animations", "process-working15.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
156
 
        { PIDGIN_STOCK_ANIMATION_CONNECT16, "animations", "process-working16.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
157
 
        { PIDGIN_STOCK_ANIMATION_CONNECT17, "animations", "process-working17.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
158
 
        { PIDGIN_STOCK_ANIMATION_CONNECT18, "animations", "process-working18.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
159
 
        { PIDGIN_STOCK_ANIMATION_CONNECT19, "animations", "process-working19.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
160
 
        { PIDGIN_STOCK_ANIMATION_CONNECT20, "animations", "process-working20.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
161
 
        { PIDGIN_STOCK_ANIMATION_CONNECT21, "animations", "process-working21.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
162
 
        { PIDGIN_STOCK_ANIMATION_CONNECT22, "animations", "process-working22.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
163
 
        { PIDGIN_STOCK_ANIMATION_CONNECT23, "animations", "process-working23.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
164
 
        { PIDGIN_STOCK_ANIMATION_CONNECT24, "animations", "process-working24.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
165
 
        { PIDGIN_STOCK_ANIMATION_CONNECT25, "animations", "process-working25.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
166
 
        { PIDGIN_STOCK_ANIMATION_CONNECT26, "animations", "process-working26.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
167
 
        { PIDGIN_STOCK_ANIMATION_CONNECT27, "animations", "process-working27.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
168
 
        { PIDGIN_STOCK_ANIMATION_CONNECT28, "animations", "process-working28.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
169
 
        { PIDGIN_STOCK_ANIMATION_CONNECT29, "animations", "process-working29.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
170
 
        { PIDGIN_STOCK_ANIMATION_CONNECT30, "animations", "process-working30.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
171
 
        { PIDGIN_STOCK_ANIMATION_TYPING0,  "animations", "typing0.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
172
 
        { PIDGIN_STOCK_ANIMATION_TYPING1,  "animations", "typing1.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
173
 
        { PIDGIN_STOCK_ANIMATION_TYPING2,  "animations", "typing2.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
174
 
        { PIDGIN_STOCK_ANIMATION_TYPING3,  "animations", "typing3.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
175
 
        { PIDGIN_STOCK_ANIMATION_TYPING4,  "animations", "typing4.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
176
 
        { PIDGIN_STOCK_ANIMATION_TYPING5,  "animations", "typing5.png",FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
177
 
 
178
 
        { PIDGIN_STOCK_TOOLBAR_BGCOLOR, "toolbar", "change-bgcolor.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
179
 
        { PIDGIN_STOCK_TOOLBAR_BLOCK, "emblems", "blocked.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
180
 
        { PIDGIN_STOCK_TOOLBAR_FGCOLOR, "toolbar", "change-fgcolor.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
181
 
        { PIDGIN_STOCK_TOOLBAR_SMILEY, "toolbar", "emote-select.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
182
 
        { PIDGIN_STOCK_TOOLBAR_FONT_FACE, "toolbar", "font-face.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
183
 
        { PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, "toolbar", "font-size-down.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
184
 
        { PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, "toolbar", "font-size-up.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
185
 
        { PIDGIN_STOCK_TOOLBAR_INSERT, "toolbar", "insert.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
186
 
        { PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, "toolbar", "insert-image.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
187
 
        { PIDGIN_STOCK_TOOLBAR_INSERT_LINK, "toolbar", "insert-link.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
188
 
        { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, "toolbar", "message-new.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
189
 
        { PIDGIN_STOCK_TOOLBAR_PENDING, "tray", "tray-new-im.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
190
 
        { PIDGIN_STOCK_TOOLBAR_PLUGINS, "toolbar", "plugins.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
191
 
        { PIDGIN_STOCK_TOOLBAR_UNBLOCK, "toolbar", "unblock.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
192
 
        { PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR, "toolbar", "select-avatar.png", FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, NULL  },
193
 
        { PIDGIN_STOCK_TOOLBAR_SEND_FILE, "toolbar", "send-file.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
194
 
        { PIDGIN_STOCK_TOOLBAR_TRANSFER, "toolbar", "transfer.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
195
 
 
196
 
        { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
197
 
        { PIDGIN_STOCK_TRAY_INVISIBLE, "tray", "tray-invisible.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
198
 
        { PIDGIN_STOCK_TRAY_AWAY, "tray", "tray-away.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
199
 
        { PIDGIN_STOCK_TRAY_BUSY, "tray", "tray-busy.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
200
 
        { PIDGIN_STOCK_TRAY_XA, "tray", "tray-extended-away.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
201
 
        { PIDGIN_STOCK_TRAY_OFFLINE, "tray", "tray-offline.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
202
 
        { PIDGIN_STOCK_TRAY_CONNECT, "tray", "tray-connecting.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
203
 
        { PIDGIN_STOCK_TRAY_PENDING, "tray", "tray-new-im.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
204
 
        { PIDGIN_STOCK_TRAY_EMAIL, "tray", "tray-message.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  }
205
 
};
206
 
 
207
 
static void
208
 
add_sized_icon_common(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir,
209
 
               gboolean rtl, const char *size, const char *file,
210
 
                   gboolean translucent);
 
116
typedef struct {
 
117
        const char *name;
 
118
        const char *dir;
 
119
        const char *filename;
 
120
        gboolean microscopic;
 
121
        gboolean extra_small;
 
122
        gboolean small;
 
123
        gboolean medium;
 
124
        gboolean large;
 
125
        gboolean huge;
 
126
        gboolean rtl;
 
127
        const char *translucent_name;
 
128
} SizedStockIcon;
 
129
 
 
130
const SizedStockIcon sized_stock_icons [] = {
 
131
 
 
132
        { PIDGIN_STOCK_STATUS_IGNORED,  "emblems", "blocked.png",       FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
133
        { PIDGIN_STOCK_STATUS_FOUNDER,  "emblems", "founder.png",       FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
134
        { PIDGIN_STOCK_STATUS_OPERATOR, "emblems", "operator.png",      FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
135
        { PIDGIN_STOCK_STATUS_HALFOP,   "emblems", "half-operator.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
136
        { PIDGIN_STOCK_STATUS_VOICE,    "emblems", "voice.png",         FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
137
 
 
138
        { PIDGIN_STOCK_DIALOG_AUTH,     "dialogs", "auth.png",      FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
139
        { PIDGIN_STOCK_DIALOG_COOL,     "dialogs", "cool.png",      FALSE, FALSE, FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
140
        { PIDGIN_STOCK_DIALOG_ERROR,    "dialogs", "error.png",     FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
141
        { PIDGIN_STOCK_DIALOG_INFO,     "dialogs", "info.png",      FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
142
        { PIDGIN_STOCK_DIALOG_MAIL,     "dialogs", "mail.png",      FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
143
        { PIDGIN_STOCK_DIALOG_QUESTION, "dialogs", "question.png",  FALSE, TRUE,  FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
144
        { PIDGIN_STOCK_DIALOG_WARNING,  "dialogs", "warning.png",   FALSE, FALSE, FALSE, FALSE, FALSE, TRUE,  FALSE, NULL },
 
145
 
 
146
        { PIDGIN_STOCK_ANIMATION_CONNECT0,  "animations", "process-working0.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
147
        { PIDGIN_STOCK_ANIMATION_CONNECT1,  "animations", "process-working1.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
148
        { PIDGIN_STOCK_ANIMATION_CONNECT2,  "animations", "process-working2.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
149
        { PIDGIN_STOCK_ANIMATION_CONNECT3,  "animations", "process-working3.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
150
        { PIDGIN_STOCK_ANIMATION_CONNECT4,  "animations", "process-working4.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
151
        { PIDGIN_STOCK_ANIMATION_CONNECT5,  "animations", "process-working5.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
152
        { PIDGIN_STOCK_ANIMATION_CONNECT6,  "animations", "process-working6.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
153
        { PIDGIN_STOCK_ANIMATION_CONNECT7,  "animations", "process-working7.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
154
        { PIDGIN_STOCK_ANIMATION_CONNECT8,  "animations", "process-working8.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
155
        { PIDGIN_STOCK_ANIMATION_CONNECT9,  "animations", "process-working9.png",  FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
156
        { PIDGIN_STOCK_ANIMATION_CONNECT10, "animations", "process-working10.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
157
        { PIDGIN_STOCK_ANIMATION_CONNECT11, "animations", "process-working11.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
158
        { PIDGIN_STOCK_ANIMATION_CONNECT12, "animations", "process-working12.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
159
        { PIDGIN_STOCK_ANIMATION_CONNECT13, "animations", "process-working13.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
160
        { PIDGIN_STOCK_ANIMATION_CONNECT14, "animations", "process-working14.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
161
        { PIDGIN_STOCK_ANIMATION_CONNECT15, "animations", "process-working15.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
162
        { PIDGIN_STOCK_ANIMATION_CONNECT16, "animations", "process-working16.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
163
        { PIDGIN_STOCK_ANIMATION_CONNECT17, "animations", "process-working17.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
164
        { PIDGIN_STOCK_ANIMATION_CONNECT18, "animations", "process-working18.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
165
        { PIDGIN_STOCK_ANIMATION_CONNECT19, "animations", "process-working19.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
166
        { PIDGIN_STOCK_ANIMATION_CONNECT20, "animations", "process-working20.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
167
        { PIDGIN_STOCK_ANIMATION_CONNECT21, "animations", "process-working21.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
168
        { PIDGIN_STOCK_ANIMATION_CONNECT22, "animations", "process-working22.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
169
        { PIDGIN_STOCK_ANIMATION_CONNECT23, "animations", "process-working23.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
170
        { PIDGIN_STOCK_ANIMATION_CONNECT24, "animations", "process-working24.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
171
        { PIDGIN_STOCK_ANIMATION_CONNECT25, "animations", "process-working25.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
172
        { PIDGIN_STOCK_ANIMATION_CONNECT26, "animations", "process-working26.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
173
        { PIDGIN_STOCK_ANIMATION_CONNECT27, "animations", "process-working27.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
174
        { PIDGIN_STOCK_ANIMATION_CONNECT28, "animations", "process-working28.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
175
        { PIDGIN_STOCK_ANIMATION_CONNECT29, "animations", "process-working29.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
176
        { PIDGIN_STOCK_ANIMATION_CONNECT30, "animations", "process-working30.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
177
 
 
178
        { PIDGIN_STOCK_ANIMATION_TYPING0,  "animations", "typing0.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
179
        { PIDGIN_STOCK_ANIMATION_TYPING1,  "animations", "typing1.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
180
        { PIDGIN_STOCK_ANIMATION_TYPING2,  "animations", "typing2.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
181
        { PIDGIN_STOCK_ANIMATION_TYPING3,  "animations", "typing3.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
182
        { PIDGIN_STOCK_ANIMATION_TYPING4,  "animations", "typing4.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
183
        { PIDGIN_STOCK_ANIMATION_TYPING5,  "animations", "typing5.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
184
 
 
185
        { PIDGIN_STOCK_TOOLBAR_BGCOLOR,         "toolbar", "change-bgcolor.png", FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
186
        { PIDGIN_STOCK_TOOLBAR_BLOCK,           "emblems", "blocked.png",        FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
187
        { PIDGIN_STOCK_TOOLBAR_FGCOLOR,         "toolbar", "change-fgcolor.png", FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
188
        { PIDGIN_STOCK_TOOLBAR_SMILEY,          "toolbar", "emote-select.png",   FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
189
        { PIDGIN_STOCK_TOOLBAR_FONT_FACE,       "toolbar", "font-face.png",      FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
190
        { PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER,    "toolbar", "font-size-down.png", FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
191
        { PIDGIN_STOCK_TOOLBAR_TEXT_LARGER,     "toolbar", "font-size-up.png",   FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
192
        { PIDGIN_STOCK_TOOLBAR_INSERT,          "toolbar", "insert.png",         FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
193
        { PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE,    "toolbar", "insert-image.png",   FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
194
        { PIDGIN_STOCK_TOOLBAR_INSERT_LINK,     "toolbar", "insert-link.png",    FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
195
        { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW,     "toolbar", "message-new.png",    FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
196
        { PIDGIN_STOCK_TOOLBAR_PENDING,         "toolbar", "message-new.png",    FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
197
        { PIDGIN_STOCK_TOOLBAR_PLUGINS,         "toolbar", "plugins.png",        FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
198
        { PIDGIN_STOCK_TOOLBAR_UNBLOCK,         "toolbar", "unblock.png",        FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
199
        { PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR,   "toolbar", "select-avatar.png",  FALSE, FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, NULL },
 
200
        { PIDGIN_STOCK_TOOLBAR_SEND_FILE,       "toolbar", "send-file.png",      FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
201
        { PIDGIN_STOCK_TOOLBAR_TRANSFER,        "toolbar", "transfer.png",       FALSE, TRUE,  FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
202
#ifdef USE_VV
 
203
        { PIDGIN_STOCK_TOOLBAR_AUDIO_CALL,       "toolbar", "audio-call.png",       FALSE, TRUE,  TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
 
204
        { PIDGIN_STOCK_TOOLBAR_VIDEO_CALL,       "toolbar", "video-call.png",       FALSE, TRUE,  TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
 
205
        { PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL, "toolbar", "audio-video-call.png", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
206
#endif
 
207
};
 
208
 
 
209
const SizedStockIcon sized_status_icons [] = {
 
210
 
 
211
        { PIDGIN_STOCK_STATUS_AVAILABLE, "status",  "available.png",     TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, PIDGIN_STOCK_STATUS_AVAILABLE_I },
 
212
        { PIDGIN_STOCK_STATUS_AWAY,      "status",  "away.png",          TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, PIDGIN_STOCK_STATUS_AWAY_I },
 
213
        { PIDGIN_STOCK_STATUS_BUSY,      "status",  "busy.png",          TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, PIDGIN_STOCK_STATUS_BUSY_I },
 
214
        { PIDGIN_STOCK_STATUS_CHAT,      "status",  "chat.png",          TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
 
215
        { PIDGIN_STOCK_STATUS_INVISIBLE, "status",  "invisible.png",     TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
 
216
        { PIDGIN_STOCK_STATUS_XA,        "status",  "extended-away.png", TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, TRUE,  PIDGIN_STOCK_STATUS_XA_I },
 
217
        { PIDGIN_STOCK_STATUS_LOGIN,     "status",  "log-in.png",        TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, TRUE,  NULL },
 
218
        { PIDGIN_STOCK_STATUS_LOGOUT,    "status",  "log-out.png",       TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, TRUE,  NULL },
 
219
        { PIDGIN_STOCK_STATUS_OFFLINE,   "status",  "offline.png",       TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, PIDGIN_STOCK_STATUS_OFFLINE_I  },
 
220
        { PIDGIN_STOCK_STATUS_PERSON,    "status",  "person.png",        TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
 
221
        { PIDGIN_STOCK_STATUS_MESSAGE,   "toolbar", "message-new.png",   TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
 
222
 
 
223
        { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png",        FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
224
        { PIDGIN_STOCK_TRAY_INVISIBLE, "tray", "tray-invisible.png",     FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
225
        { PIDGIN_STOCK_TRAY_AWAY,      "tray", "tray-away.png",          FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
226
        { PIDGIN_STOCK_TRAY_BUSY,      "tray", "tray-busy.png",          FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
227
        { PIDGIN_STOCK_TRAY_XA,        "tray", "tray-extended-away.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
228
        { PIDGIN_STOCK_TRAY_OFFLINE,   "tray", "tray-offline.png",       FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
229
        { PIDGIN_STOCK_TRAY_CONNECT,   "tray", "tray-connecting.png",    FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
230
        { PIDGIN_STOCK_TRAY_PENDING,   "tray", "tray-new-im.png",        FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 
231
        { PIDGIN_STOCK_TRAY_EMAIL,     "tray", "tray-message.png",       FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL }
 
232
};
 
233
 
 
234
/*****************************************************************************
 
235
 * Private functions
 
236
 *****************************************************************************/
211
237
 
212
238
static gchar *
213
239
find_file_common(const char *name)
257
283
        return ret;
258
284
}
259
285
 
260
 
static void
261
 
add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir,
262
 
               gboolean rtl, const char *size, const char *file)
263
 
{
264
 
        add_sized_icon_common(iconset, sizeid, dir, rtl, size, file, FALSE);
265
 
}
266
286
 
267
287
/* Altered from do_colorshift in gnome-panel */
268
288
static void
269
 
do_alphashift (GdkPixbuf *dest, GdkPixbuf *src)
270
 
{
271
 
        gint i, j;
272
 
        gint width, height, has_alpha, srcrowstride, destrowstride;
273
 
        guchar *target_pixels;
274
 
        guchar *original_pixels;
275
 
        guchar *pixsrc;
276
 
        guchar *pixdest;
277
 
        guchar a;
278
 
 
279
 
        has_alpha = gdk_pixbuf_get_has_alpha (src);
280
 
        if (!has_alpha)
281
 
          return;
282
 
 
283
 
        width = gdk_pixbuf_get_width (src);
284
 
        height = gdk_pixbuf_get_height (src);
285
 
        srcrowstride = gdk_pixbuf_get_rowstride (src);
286
 
        destrowstride = gdk_pixbuf_get_rowstride (dest);
287
 
        target_pixels = gdk_pixbuf_get_pixels (dest);
288
 
        original_pixels = gdk_pixbuf_get_pixels (src);
289
 
 
290
 
        for (i = 0; i < height; i++) {
291
 
                pixdest = target_pixels + i*destrowstride;
292
 
                pixsrc = original_pixels + i*srcrowstride;
293
 
                for (j = 0; j < width; j++) {
294
 
                        *(pixdest++) = *(pixsrc++);
295
 
                        *(pixdest++) = *(pixsrc++);
296
 
                        *(pixdest++) = *(pixsrc++);
297
 
                        a = *(pixsrc++);
298
 
                        *(pixdest++) = a / 2;
299
 
                }
300
 
        }
301
 
}
302
 
 
303
 
static void
304
 
add_translucent_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir,
305
 
               gboolean rtl, const char *size, const char *file)
306
 
{
307
 
        add_sized_icon_common(iconset, sizeid, dir, rtl, size, file, TRUE);
308
 
}
309
 
 
310
 
static void
311
 
add_sized_icon_common(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir,
312
 
               gboolean rtl, const char *size, const char *file,
313
 
                   gboolean translucent)
314
 
{
315
 
        char *filename, *subpath;
 
289
do_alphashift(GdkPixbuf *dest, GdkPixbuf *src)
 
290
{
 
291
        gint i, j;
 
292
        gint width, height, has_alpha, srcrowstride, destrowstride;
 
293
        guchar *target_pixels;
 
294
        guchar *original_pixels;
 
295
        guchar *pixsrc;
 
296
        guchar *pixdest;
 
297
        guchar a;
 
298
 
 
299
        has_alpha = gdk_pixbuf_get_has_alpha (src);
 
300
        if (!has_alpha)
 
301
                return;
 
302
 
 
303
        width = gdk_pixbuf_get_width (src);
 
304
        height = gdk_pixbuf_get_height (src);
 
305
        srcrowstride = gdk_pixbuf_get_rowstride (src);
 
306
        destrowstride = gdk_pixbuf_get_rowstride (dest);
 
307
        target_pixels = gdk_pixbuf_get_pixels (dest);
 
308
        original_pixels = gdk_pixbuf_get_pixels (src);
 
309
 
 
310
        for (i = 0; i < height; i++) {
 
311
                pixdest = target_pixels + i*destrowstride;
 
312
                pixsrc = original_pixels + i*srcrowstride;
 
313
                for (j = 0; j < width; j++) {
 
314
                        *(pixdest++) = *(pixsrc++);
 
315
                        *(pixdest++) = *(pixsrc++);
 
316
                        *(pixdest++) = *(pixsrc++);
 
317
                        a = *(pixsrc++);
 
318
                        *(pixdest++) = a / 2;
 
319
                }
 
320
        }
 
321
}
 
322
 
 
323
static gchar *
 
324
find_icon_file(PidginIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl)
 
325
{
 
326
        const gchar *file, *dir;
 
327
        gchar *file_full = NULL;
 
328
        gchar *tmp;
 
329
 
 
330
        if (theme != NULL) {
 
331
                file = pidgin_icon_theme_get_icon(PIDGIN_ICON_THEME(theme), sized_icon.name);
 
332
                dir = purple_theme_get_dir(PURPLE_THEME(theme));
 
333
 
 
334
                if (rtl)
 
335
                        file_full = g_build_filename(dir, size, "rtl", file, NULL);
 
336
                else
 
337
                        file_full = g_build_filename(dir, size, file, NULL);
 
338
 
 
339
                if (g_file_test(file_full, G_FILE_TEST_IS_REGULAR))
 
340
                        return file_full;
 
341
 
 
342
                g_free(file_full);
 
343
        }
 
344
 
 
345
        if (rtl)
 
346
                tmp = g_build_filename("pixmaps", "pidgin", sized_icon.dir, size, "rtl", sized_icon.filename, NULL);
 
347
        else
 
348
                tmp = g_build_filename("pixmaps", "pidgin", sized_icon.dir, size, sized_icon.filename, NULL);
 
349
 
 
350
        file_full = find_file_common(tmp);
 
351
        g_free(tmp);
 
352
        return file_full;
 
353
}
 
354
 
 
355
static void
 
356
add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme,
 
357
                const char *size, SizedStockIcon sized_icon, gboolean translucent)
 
358
{
 
359
        char *filename;
316
360
        GtkIconSource *source;
317
361
        GdkPixbuf *pixbuf;
318
362
 
319
 
        subpath = g_build_filename("pixmaps", "pidgin", dir, size, file, NULL);
320
 
        filename = find_file_common(subpath);
321
 
        g_free(subpath);
322
 
        if (!filename)
323
 
                return;
324
 
 
 
363
        filename = find_icon_file(theme, size, sized_icon, FALSE);
 
364
        g_return_if_fail(filename != NULL);
325
365
        pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
326
366
        if (translucent)
327
367
                do_alphashift(pixbuf, pixbuf);
329
369
        source = gtk_icon_source_new();
330
370
        gtk_icon_source_set_pixbuf(source, pixbuf);
331
371
        gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR);
332
 
        gtk_icon_source_set_direction_wildcarded(source, !rtl);
 
372
        gtk_icon_source_set_direction_wildcarded(source, !sized_icon.rtl);
333
373
        gtk_icon_source_set_size(source, sizeid);
334
374
        gtk_icon_source_set_size_wildcarded(source, FALSE);
335
375
        gtk_icon_source_set_state_wildcarded(source, TRUE);
349
389
        g_free(filename);
350
390
        g_object_unref(pixbuf);
351
391
 
352
 
        if (rtl) {
353
 
                subpath = g_build_filename("pixmaps", "pidgin", dir, size, "rtl", file, NULL);
354
 
                filename = find_file_common(subpath);
355
 
                g_free(subpath);
356
 
                if (!filename)
357
 
                        return;
 
392
        if (sized_icon.rtl) {
 
393
                filename = find_icon_file(theme, size, sized_icon, TRUE);
 
394
                g_return_if_fail(filename != NULL);
358
395
                pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
359
396
                if (translucent)
360
397
                        do_alphashift(pixbuf, pixbuf);
 
398
 
361
399
                source = gtk_icon_source_new();
362
400
                gtk_icon_source_set_pixbuf(source, pixbuf);
 
401
                gtk_icon_source_set_filename(source, filename);
363
402
                gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL);
364
403
                gtk_icon_source_set_size(source, sizeid);
365
404
                gtk_icon_source_set_size_wildcarded(source, FALSE);
371
410
        }
372
411
}
373
412
 
 
413
static void
 
414
reload_settings(void)
 
415
{
 
416
#if GTK_CHECK_VERSION(2,4,0)
 
417
        GtkSettings *setting = NULL;
 
418
        setting = gtk_settings_get_default();
 
419
        gtk_rc_reset_styles(setting);
 
420
#endif
 
421
}
 
422
 
 
423
/*****************************************************************************
 
424
 * Public API functions
 
425
 *****************************************************************************/
 
426
 
374
427
void
375
 
pidgin_stock_init(void)
 
428
pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme)
376
429
{
377
 
        static gboolean stock_initted = FALSE;
378
430
        GtkIconFactory *icon_factory;
379
 
        size_t i;
 
431
        gint i;
 
432
        GtkIconSet *normal;
 
433
        GtkIconSet *translucent = NULL;
380
434
        GtkWidget *win;
381
 
        GtkIconSize microscopic, extra_small, small, medium, large, huge;
382
 
 
383
 
        if (stock_initted)
384
 
                return;
385
 
 
386
 
        stock_initted = TRUE;
387
 
 
388
 
        /* Setup the icon factory. */
 
435
 
 
436
        if (theme != NULL) {
 
437
                purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme",
 
438
                                        purple_theme_get_name(PURPLE_THEME(theme)));
 
439
                purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir",
 
440
                                      purple_theme_get_dir(PURPLE_THEME(theme)));
 
441
        }
 
442
        else {
 
443
                purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme", "");
 
444
                purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", "");
 
445
        }
 
446
 
389
447
        icon_factory = gtk_icon_factory_new();
390
448
 
391
449
        gtk_icon_factory_add_default(icon_factory);
392
450
 
393
 
        /* Er, yeah, a hack, but it works. :) */
394
451
        win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
395
452
        gtk_widget_realize(win);
396
453
 
397
 
        for (i = 0; i < G_N_ELEMENTS(stock_icons); i++)
 
454
        for (i = 0; i < G_N_ELEMENTS(sized_status_icons); i++)
398
455
        {
 
456
                normal = gtk_icon_set_new();
 
457
                if (sized_status_icons[i].translucent_name)
 
458
                        translucent = gtk_icon_set_new();
 
459
 
 
460
#define ADD_SIZED_ICON(name, size) \
 
461
                if (sized_status_icons[i].name) { \
 
462
                        add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \
 
463
                        if (sized_status_icons[i].translucent_name) \
 
464
                                add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \
 
465
                }
 
466
                ADD_SIZED_ICON(microscopic, "11");
 
467
                ADD_SIZED_ICON(extra_small, "16");
 
468
                ADD_SIZED_ICON(small, "22");
 
469
                ADD_SIZED_ICON(medium, "32");
 
470
                ADD_SIZED_ICON(large, "48");
 
471
                ADD_SIZED_ICON(huge, "64");
 
472
#undef ADD_SIZED_ICON
 
473
 
 
474
                gtk_icon_factory_add(icon_factory, sized_status_icons[i].name, normal);
 
475
                gtk_icon_set_unref(normal);
 
476
 
 
477
                if (sized_status_icons[i].translucent_name) {
 
478
                        gtk_icon_factory_add(icon_factory, sized_status_icons[i].translucent_name, translucent);
 
479
                        gtk_icon_set_unref(translucent);
 
480
                }
 
481
        }
 
482
 
 
483
        gtk_widget_destroy(win);
 
484
        g_object_unref(G_OBJECT(icon_factory));
 
485
        reload_settings();
 
486
}
 
487
 
 
488
void
 
489
pidgin_stock_load_stock_icon_theme(PidginStockIconTheme *theme)
 
490
{
 
491
        GtkIconFactory *icon_factory;
 
492
        gint i;
 
493
        GtkWidget *win;
 
494
 
 
495
        if (theme != NULL) {
 
496
                purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme",
 
497
                                        purple_theme_get_name(PURPLE_THEME(theme)));
 
498
                purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir",
 
499
                                      purple_theme_get_dir(PURPLE_THEME(theme)));
 
500
        }
 
501
        else {
 
502
                purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", "");
 
503
                purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", "");
 
504
        }
 
505
 
 
506
        icon_factory = gtk_icon_factory_new();
 
507
 
 
508
        gtk_icon_factory_add_default(icon_factory);
 
509
 
 
510
        win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
511
        gtk_widget_realize(win);
 
512
 
 
513
        /* All non-sized icons */
 
514
        for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) {
399
515
                GtkIconSource *source;
400
516
                GtkIconSet *iconset;
401
517
                gchar *filename;
402
518
 
403
 
                if (stock_icons[i].dir == NULL)
404
 
                {
 
519
                if (stock_icons[i].dir == NULL) {
405
520
                        /* GTK+ Stock icon */
406
521
                        iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win),
407
522
                                        stock_icons[i].filename);
408
 
                }
409
 
                else
410
 
                {
 
523
                } else {
411
524
                        filename = find_file(stock_icons[i].dir, stock_icons[i].filename);
412
525
 
413
526
                        if (filename == NULL)
431
544
                gtk_icon_set_unref(iconset);
432
545
        }
433
546
 
 
547
        /* All non-status sized icons */
 
548
        for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++)
 
549
        {
 
550
                GtkIconSet *iconset = gtk_icon_set_new();
 
551
 
 
552
#define ADD_SIZED_ICON(name, size) \
 
553
                if (sized_stock_icons[i].name) \
 
554
                        add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE);
 
555
                ADD_SIZED_ICON(microscopic, "11");
 
556
                ADD_SIZED_ICON(extra_small, "16");
 
557
                ADD_SIZED_ICON(small, "22");
 
558
                ADD_SIZED_ICON(medium, "32");
 
559
                ADD_SIZED_ICON(large, "48");
 
560
                ADD_SIZED_ICON(huge, "64");
 
561
#undef ADD_SIZED_ICON
 
562
 
 
563
                gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset);
 
564
                gtk_icon_set_unref(iconset);
 
565
        }
 
566
 
 
567
        gtk_widget_destroy(win);
 
568
        g_object_unref(G_OBJECT(icon_factory));
 
569
        reload_settings();
 
570
}
 
571
 
 
572
void
 
573
pidgin_stock_init(void)
 
574
{
 
575
        PidginIconThemeLoader *loader, *stockloader;
 
576
        const gchar *path = NULL;
 
577
 
 
578
        if (stock_initted)
 
579
                return;
 
580
 
 
581
        stock_initted = TRUE;
 
582
 
 
583
        /* Setup the status icon theme */
 
584
        loader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "status-icon", NULL);
 
585
        purple_theme_manager_register_type(PURPLE_THEME_LOADER(loader));
 
586
        purple_prefs_add_none(PIDGIN_PREFS_ROOT "/status");
 
587
        purple_prefs_add_string(PIDGIN_PREFS_ROOT "/status/icon-theme", "");
 
588
        purple_prefs_add_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", "");
 
589
 
 
590
        stockloader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "stock-icon", NULL);
 
591
        purple_theme_manager_register_type(PURPLE_THEME_LOADER(stockloader));
 
592
        purple_prefs_add_none(PIDGIN_PREFS_ROOT "/stock");
 
593
        purple_prefs_add_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", "");
 
594
        purple_prefs_add_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", "");
 
595
 
434
596
        /* register custom icon sizes */
435
 
 
436
597
        microscopic =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC, 11, 11);
437
598
        extra_small =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16);
438
 
        small =        gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22);
439
 
        medium =       gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32);
440
 
        large =        gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48);
441
 
        huge =         gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64);
442
 
 
443
 
        for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++)
444
 
        {
445
 
                GtkIconSet *iconset;
446
 
 
447
 
                iconset = gtk_icon_set_new();
448
 
 
449
 
#define ADD_SIZED_ICON(name, size) do { \
450
 
                if (sized_stock_icons[i].name)  \
451
 
                        add_sized_icon(iconset, name,  \
452
 
                                        sized_stock_icons[i].dir, sized_stock_icons[i].rtl, \
453
 
                                        size, sized_stock_icons[i].filename); \
454
 
                } while (0)
455
 
                ADD_SIZED_ICON(microscopic, "11");
456
 
                ADD_SIZED_ICON(extra_small, "16");
457
 
                ADD_SIZED_ICON(small, "22");
458
 
                ADD_SIZED_ICON(medium, "32");
459
 
                ADD_SIZED_ICON(large, "48");
460
 
                ADD_SIZED_ICON(huge, "64");
461
 
#undef ADD_SIZED_ICON
462
 
 
463
 
                gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset);
464
 
                gtk_icon_set_unref(iconset);
465
 
 
466
 
                if (sized_stock_icons[i].translucent_name) {
467
 
                        iconset = gtk_icon_set_new();
468
 
 
469
 
#define ADD_TRANS_ICON(name, size) do { \
470
 
                        if (sized_stock_icons[i].name) \
471
 
                                add_translucent_sized_icon(iconset, name, \
472
 
                                                sized_stock_icons[i].dir, sized_stock_icons[i].rtl, \
473
 
                                                size, sized_stock_icons[i].filename); \
474
 
                        } while (0)
475
 
                        ADD_TRANS_ICON(microscopic, "11");
476
 
                        ADD_TRANS_ICON(extra_small, "16");
477
 
                        ADD_TRANS_ICON(small, "22");
478
 
                        ADD_TRANS_ICON(medium, "32");
479
 
                        ADD_TRANS_ICON(large, "48");
480
 
                        ADD_TRANS_ICON(huge, "64");
481
 
#undef ADD_TRANS_ICON
482
 
 
483
 
                        gtk_icon_factory_add(icon_factory, sized_stock_icons[i].translucent_name, iconset);
484
 
                        gtk_icon_set_unref(iconset);
485
 
                }
 
599
        small       =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22);
 
600
        medium      =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32);
 
601
        large       =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48);
 
602
        huge        =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64);
 
603
 
 
604
        pidgin_stock_load_stock_icon_theme(NULL);
 
605
 
 
606
        /* Pre-load Status icon theme - this avoids a bug with displaying the correct icon in the tray, theme is destroyed after*/
 
607
        if (purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme") &&
 
608
           (path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir"))) {
 
609
 
 
610
                PidginStatusIconTheme *theme = PIDGIN_STATUS_ICON_THEME(purple_theme_loader_build(PURPLE_THEME_LOADER(loader), path));
 
611
                pidgin_stock_load_status_icon_theme(theme);
 
612
                g_object_unref(G_OBJECT(theme));
 
613
 
486
614
        }
487
 
 
488
 
        gtk_widget_destroy(win);
489
 
        g_object_unref(G_OBJECT(icon_factory));
 
615
        else
 
616
                pidgin_stock_load_status_icon_theme(NULL);
490
617
 
491
618
        /* Register the stock items. */
492
619
        gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items));
493
620
}
 
621
 
 
622
static void
 
623
pidgin_stock_icon_theme_class_init(PidginStockIconThemeClass *klass)
 
624
{
 
625
}
 
626
 
 
627
GType
 
628
pidgin_stock_icon_theme_get_type(void)
 
629
{
 
630
        static GType type = 0;
 
631
        if (type == 0) {
 
632
                static const GTypeInfo info = {
 
633
                        sizeof (PidginStockIconThemeClass),
 
634
                        NULL, /* base_init */
 
635
                        NULL, /* base_finalize */
 
636
                        (GClassInitFunc)pidgin_stock_icon_theme_class_init, /* class_init */
 
637
                        NULL, /* class_finalize */
 
638
                        NULL, /* class_data */
 
639
                        sizeof (PidginStockIconTheme),
 
640
                        0, /* n_preallocs */
 
641
                        NULL,
 
642
                        NULL, /* value table */
 
643
                };
 
644
                type = g_type_register_static(PIDGIN_TYPE_ICON_THEME,
 
645
                                "PidginStockIconTheme", &info, 0);
 
646
        }
 
647
        return type;
 
648
}