grim/guifications2

[gf2-migrate @ 14]
org.guifications.gf2
2006-06-18, Sadrul Habib Chowdhury
81a05b0daba6
Parents 767fcb5e43da
Children 397a305111e5
[gf2-migrate @ 14]
Add support for notifications on new emails.
--- a/VERSION Fri Jun 09 03:49:28 2006 -0400
+++ b/VERSION Sun Jun 18 07:51:34 2006 -0400
@@ -1,1 +1,1 @@
-2.13beta3
+2.13svn
--- a/src/gf_event.c Fri Jun 09 03:49:28 2006 -0400
+++ b/src/gf_event.c Sun Jun 18 07:51:34 2006 -0400
@@ -53,6 +53,13 @@
static GList *events = NULL;
+
+void *(*real_notify_email)(GaimConnection *gc, const char *subject, const char *from,
+ const char *to, const char *url);
+void *(*real_notify_emails)(GaimConnection *gc, size_t count, gboolean detailed,
+ const char **subject, const char **from,
+ const char **to, const char **url);
+
/*******************************************************************************
* API
******************************************************************************/
@@ -586,52 +593,47 @@
/*******************************************************************************
* Mail Stuff
******************************************************************************/
-#ifdef EMAIL
static void *
-gf_event_emails(size_t count, gboolean detailed, const gchar **subjects,
- const gchar **froms, const gchar **tos, const gchar **urls,
- GCallback cb, gpointer data)
+gf_event_email(GaimConnection *gc, const char *subject, const char *from,
+ const char *to, const char *url)
{
+ gf_event_common("new-email", gc->account,
+ gaim_find_buddy(gc->account, from),
+ NULL, from, NULL, GAIM_CBFLAGS_NONE, NULL, subject);
+ return real_notify_email(gc, subject, from, to, url);
+}
-
- return NULL;
+static void *
+gf_event_emails(GaimConnection *gc, size_t count, gboolean detailed,
+ const char **subject, const char **from,
+ const char **to, const char **url)
+{
+ if (count == 1 && subject && *subject)
+ return gf_event_email(gc, *subject, *from, *to, *url);
+ return real_notify_emails(gc, count, detailed, subject, from, to, url);
}
-static void *
-gf_event_email(const gchar *subject, const gchar *from, const gchar *to,
- const gchar *url, GCallback cb, gpointer data)
-{
- return gf_event_emails(1, TRUE,
- subject ? &subject : NULL,
- from ? &from : NULL,
- to ? &to : NULL,
- url ? &url : NULL,
- cb, data);
-}
-
-static GaimNotifyUiOps *notify_ops_orig = NULL, *notify_ops_new = NULL;
static void
gf_event_email_init() {
- g_return_if_fail(!notify_ops_new);
+ g_return_if_fail(!real_notify_email);
- notify_ops_orig = gaim_notify_get_ui_ops();
+ GaimNotifyUiOps *notify_ops_orig = gaim_notify_get_ui_ops();
- notify_ops_new = g_memdup(notify_ops_orig, sizeof(GaimNotifyUiOps));
- notify_ops_new->notify_email = gf_event_email;
- notify_ops_new->notify_emails = gf_event_emails;
-
- gaim_notify_set_ui_ops(notify_ops_new);
+ real_notify_email = notify_ops_orig->notify_email;
+ notify_ops_orig->notify_email = gf_event_email;
+ real_notify_emails = notify_ops_orig->notify_emails;
+ notify_ops_orig->notify_emails = gf_event_emails;
}
static void gf_event_email_uninit() {
- g_return_if_fail(notify_ops_new);
+ g_return_if_fail(real_notify_email);
+
+ GaimNotifyUiOps *notify_ops_orig = gaim_notify_get_ui_ops();
- gaim_notify_set_ui_ops(notify_ops_orig);
- g_free(notify_ops_new);
- notify_ops_new = NULL;
+ notify_ops_orig->notify_email = real_notify_email;
+ notify_ops_orig->notify_emails = real_notify_emails;
}
-#endif
/*******************************************************************************
* File transfer stuff
@@ -708,11 +710,9 @@
_("Displayed when a topic is changed in a chat."),
GF_EVENT_PRIORITY_LOW);
-#ifdef EMAIL
- gf_event_new("email", "%DdHhiMmNsTtuYy", _("Email"),
+ gf_event_new("new-email", TOKENS_DEFAULT "c", _("Email"),
_("Displayed when you receive new email."),
GF_EVENT_PRIORITY_NORMAL);
-#endif
gf_event_new(GF_NOTIFICATION_MASTER, TOKENS_DEFAULT "Ccnr",
_("Master"), _("Master notification for the theme editor."),
@@ -798,10 +798,8 @@
gaim_signal_connect(conv_handle, "chat-joined", plugin,
GAIM_CALLBACK(gf_event_conversation_throttle), NULL);
-#ifdef EMAIL
/* mail stuff */
gf_event_email_init();
-#endif
gaim_signal_connect(gaim_xfers_get_handle(), "file-recv-cancel", plugin,
GAIM_CALLBACK(gf_event_file_recv_cancel), "file-remote-cancel");
@@ -815,9 +813,7 @@
gf_events_uninit() {
GList *l, *ll;
-#ifdef EMAIL
gf_event_email_uninit();
-#endif
for(l = events; l; l = ll) {
ll = l->next;
--- a/themes/default/theme.xml Fri Jun 09 03:49:28 2006 -0400
+++ b/themes/default/theme.xml Sun Jun 18 07:51:34 2006 -0400
@@ -356,5 +356,23 @@
<text format='"%X" completed.' clipping='ellipsis-middle' width='0' />
</item>
</notification>
+ <notification type='new-email' background='background.png'>
+ <item type='icon'>
+ <position value='south-west' />
+ <h_offset value='5' />
+ <v_offset value='-5' />
+ <icon type='protocol' size='little' />
+ </item>
+ <item type='text'>
+ <position value='center' />
+ <v_offset value='-25%' />
+ <text format='Mail (%X) from' clipping='ellipsis-middle' width='0' />
+ </item>
+ <item type='text'>
+ <position value='center' />
+ <v_offset value='-13%' />
+ <text format='%c (%a).' clipping='ellipsis-middle' width='0' />
+ </item>
+ </notification>
</theme>
</guifications>