cpw.masca.notify: fccfce77: Reagroup code so it get related function...
masca at cpw.pidgin.im
masca at cpw.pidgin.im
Wed May 12 03:15:55 EDT 2010
-----------------------------------------------------------------
Revision: fccfce77991429c1dde51027879812352e673715
Ancestor: d0352326dd80bf0907b912692459a42467b61284
Author: masca at cpw.pidgin.im
Date: 2010-05-12T07:10:58
Branch: im.pidgin.cpw.masca.notify
URL: http://d.pidgin.im/viewmtn/revision/info/fccfce77991429c1dde51027879812352e673715
Modified files:
pidgin/gtknotify.c
ChangeLog:
Reagroup code so it get related functions closer.
-------------- next part --------------
============================================================
--- pidgin/gtknotify.c 54dd15afcb829a207a5c01da07352c4f3ee6db6e
+++ pidgin/gtknotify.c 6d971bc5d58a96db3055662e609fa678157b5593
@@ -156,6 +156,45 @@ static void pidgin_close_notify(PurpleNo
static void pidgin_close_notify(PurpleNotifyType type, void *ui_handle);
+/********************************************************************
+ * Notify Message
+ *******************************************************************/
+static GdkPixbuf *
+message_get_icon(PurpleNotifyMsgType type, const char *size)
+{
+ GtkWidget *img = NULL;
+ GdkPixbuf *pixbuf = NULL;
+ const char *icon_name = NULL;
+
+ switch (type)
+ {
+ case PURPLE_NOTIFY_MSG_ERROR:
+ icon_name = PIDGIN_STOCK_DIALOG_ERROR;
+ break;
+
+ case PURPLE_NOTIFY_MSG_WARNING:
+ icon_name = PIDGIN_STOCK_DIALOG_WARNING;
+ break;
+
+ case PURPLE_NOTIFY_MSG_INFO:
+ icon_name = PIDGIN_STOCK_DIALOG_INFO;
+ break;
+
+ default:
+ icon_name = NULL;
+ break;
+ }
+
+
+ if (icon_name != NULL)
+ {
+ img = gtk_image_new();
+ pixbuf = gtk_widget_render_icon(img, icon_name, gtk_icon_size_from_name(size), NULL);
+ }
+
+ return pixbuf;
+}
+
static void
message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
{
@@ -200,7 +239,134 @@ message_dialog_response_cb(GtkDialog *di
}
}
+static void *
+pidgin_notify_message(PurpleNotifyMsgType type, const char *title,
+ const char *primary, const char *secondary)
+{
+ PidginNotifyMsgData *msg_data;
+ GtkTreeIter iter;
+ gboolean first;
+
+ first = (message_dialog == NULL);
+
+ if (first)
+ message_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_MESSAGE);
+
+ msg_data = g_new(PidginNotifyMsgData, 1);
+
+ msg_data->pixbuf = message_get_icon(type, PIDGIN_ICON_SIZE_TANGO_SMALL);
+ msg_data->type = type;
+ msg_data->title = g_strdup(title);
+ msg_data->primary = g_strdup(primary);
+ msg_data->secondary = g_strdup(secondary);
+
+ gtk_tree_store_append(message_dialog->treemodel, &iter, NULL);
+
+ gtk_tree_store_set(message_dialog->treemodel, &iter,
+ PIDGIN_MSG_TYPE, msg_data->pixbuf,
+ PIDGIN_MSG_TITLE, msg_data->title,
+ PIDGIN_MSG_PRIMARY, msg_data->primary,
+ PIDGIN_MSG_SECONDARY, msg_data->secondary,
+ PIDGIN_MSG_DATA, msg_data,
+ -1);
+
+ if (first) {
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(message_dialog->treeview));
+ gtk_tree_selection_select_iter(selection, &iter);
+ }
+
+ gtk_widget_show_all(message_dialog->dialog);
+
+ return message_dialog->dialog;
+}
+
+static void *
+pidgin_notify_message_full(PurpleNotifyMsgType type, const char *title,
+ const char *primary, const char *secondary)
+{
+ GtkWidget *dialog;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *img = NULL;
+ GdkPixbuf *pixbuf;
+ char label_text[2048];
+ char *primary_esc, *secondary_esc;
+
+ pixbuf = message_get_icon(type, PIDGIN_ICON_SIZE_TANGO_HUGE);
+ img = gtk_image_new_from_pixbuf(pixbuf);
+
+ dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE,
+ NULL, 0, GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog");
+
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(message_response_cb), dialog);
+
+ gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+ gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER);
+ gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE);
+
+ hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
+
+ if (img != NULL)
+ gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
+
+ primary_esc = g_markup_escape_text(primary, -1);
+ secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
+ g_snprintf(label_text, sizeof(label_text),
+ "<span weight=\"bold\" size=\"larger\">%s</span>%s%s",
+ primary_esc, (secondary ? "\n\n" : ""),
+ (secondary ? secondary_esc : ""));
+ g_free(primary_esc);
+ g_free(secondary_esc);
+
+ label = gtk_label_new(NULL);
+
+ gtk_label_set_markup(GTK_LABEL(label), label_text);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ pidgin_auto_parent_window(dialog);
+
+ gtk_widget_show_all(dialog);
+
+ return dialog;
+}
+
static void
+message_row_activated_cb(GtkTreeView *tv, GtkTreePath *path,
+ GtkTreeViewColumn *col, gpointer data)
+{
+ GtkTreeSelection *selection;
+ PidginNotifyMsgData *msg_data;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = GTK_TREE_MODEL(message_dialog->treemodel);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(message_dialog->treeview));
+
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter) )
+ return;
+
+ gtk_tree_model_get(model, &iter, PIDGIN_MSG_DATA, &msg_data, -1);
+
+ pidgin_notify_message_full(msg_data->type, msg_data->title,
+ msg_data->primary, msg_data->secondary);
+}
+
+/********************************************************************
+ * Notify Pounces
+ *******************************************************************/
+static void
pounce_response_close(PidginNotifyDialog *dialog)
{
GtkTreeIter iter;
@@ -429,6 +595,54 @@ pounce_row_selected_cb(GtkTreeView *tv,
}
+void
+pidgin_notify_pounce_add(PurpleAccount *account, PurplePounce *pounce,
+ const char *alias, const char *event, const char *message, const char *date)
+{
+ GdkPixbuf *icon;
+ GtkTreeIter iter;
+ PidginNotifyPounceData *pounce_data;
+ gboolean first = (pounce_dialog == NULL);
+
+ if (pounce_dialog == NULL)
+ pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE);
+
+ icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
+
+ pounce_data = g_new(PidginNotifyPounceData, 1);
+
+ pounce_data->account = account;
+ pounce_data->pounce = pounce;
+ pounce_data->pouncee = g_strdup(purple_pounce_get_pouncee(pounce));
+
+ gtk_tree_store_append(pounce_dialog->treemodel, &iter, NULL);
+
+ gtk_tree_store_set(pounce_dialog->treemodel, &iter,
+ PIDGIN_POUNCE_ICON, icon,
+ PIDGIN_POUNCE_ALIAS, alias,
+ PIDGIN_POUNCE_EVENT, event,
+ PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"),
+ PIDGIN_POUNCE_DATE, date,
+ PIDGIN_POUNCE_DATA, pounce_data,
+ -1);
+
+ if (first) {
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
+ gtk_tree_selection_select_iter(selection, &iter);
+ }
+
+ if (icon)
+ g_object_unref(icon);
+
+ gtk_widget_show_all(pounce_dialog->dialog);
+
+ return;
+}
+
+/********************************************************************
+ * Notify Emails
+ *******************************************************************/
static void
reset_mail_dialog(GtkDialog *unused)
{
@@ -543,167 +757,7 @@ searchresults_callback_wrapper_cb(GtkWid
g_list_free(row);
}
-static GdkPixbuf *
-message_get_icon(PurpleNotifyMsgType type, const char *size)
-{
- GtkWidget *img = NULL;
- GdkPixbuf *pixbuf = NULL;
- const char *icon_name = NULL;
-
- switch (type)
- {
- case PURPLE_NOTIFY_MSG_ERROR:
- icon_name = PIDGIN_STOCK_DIALOG_ERROR;
- break;
-
- case PURPLE_NOTIFY_MSG_WARNING:
- icon_name = PIDGIN_STOCK_DIALOG_WARNING;
- break;
-
- case PURPLE_NOTIFY_MSG_INFO:
- icon_name = PIDGIN_STOCK_DIALOG_INFO;
- break;
-
- default:
- icon_name = NULL;
- break;
- }
-
-
- if (icon_name != NULL)
- {
- img = gtk_image_new();
- pixbuf = gtk_widget_render_icon(img, icon_name, gtk_icon_size_from_name(size), NULL);
- }
-
- return pixbuf;
-}
-
-static void *
-pidgin_notify_message(PurpleNotifyMsgType type, const char *title,
- const char *primary, const char *secondary)
-{
- PidginNotifyMsgData *msg_data;
- GtkTreeIter iter;
- gboolean first;
-
- first = (message_dialog == NULL);
-
- if (first)
- message_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_MESSAGE);
-
- msg_data = g_new(PidginNotifyMsgData, 1);
-
- msg_data->pixbuf = message_get_icon(type, PIDGIN_ICON_SIZE_TANGO_SMALL);
- msg_data->type = type;
- msg_data->title = g_strdup(title);
- msg_data->primary = g_strdup(primary);
- msg_data->secondary = g_strdup(secondary);
-
- gtk_tree_store_append(message_dialog->treemodel, &iter, NULL);
-
- gtk_tree_store_set(message_dialog->treemodel, &iter,
- PIDGIN_MSG_TYPE, msg_data->pixbuf,
- PIDGIN_MSG_TITLE, msg_data->title,
- PIDGIN_MSG_PRIMARY, msg_data->primary,
- PIDGIN_MSG_SECONDARY, msg_data->secondary,
- PIDGIN_MSG_DATA, msg_data,
- -1);
-
- if (first) {
- GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(message_dialog->treeview));
- gtk_tree_selection_select_iter(selection, &iter);
- }
-
- gtk_widget_show_all(message_dialog->dialog);
-
- return message_dialog->dialog;
-}
-
-static void *
-pidgin_notify_message_full(PurpleNotifyMsgType type, const char *title,
- const char *primary, const char *secondary)
-{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *img = NULL;
- GdkPixbuf *pixbuf;
- char label_text[2048];
- char *primary_esc, *secondary_esc;
-
- pixbuf = message_get_icon(type, PIDGIN_ICON_SIZE_TANGO_HUGE);
- img = gtk_image_new_from_pixbuf(pixbuf);
-
- dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE,
- NULL, 0, GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE, NULL);
-
- gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog");
-
- g_signal_connect(G_OBJECT(dialog), "response",
- G_CALLBACK(message_response_cb), dialog);
-
- gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
- gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER);
- gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE);
-
- hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
-
- if (img != NULL)
- gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
-
- primary_esc = g_markup_escape_text(primary, -1);
- secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
- g_snprintf(label_text, sizeof(label_text),
- "<span weight=\"bold\" size=\"larger\">%s</span>%s%s",
- primary_esc, (secondary ? "\n\n" : ""),
- (secondary ? secondary_esc : ""));
- g_free(primary_esc);
- g_free(secondary_esc);
-
- label = gtk_label_new(NULL);
-
- gtk_label_set_markup(GTK_LABEL(label), label_text);
- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
- gtk_label_set_selectable(GTK_LABEL(label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
- pidgin_auto_parent_window(dialog);
-
- gtk_widget_show_all(dialog);
-
- return dialog;
-}
-
static void
-message_row_activated_cb(GtkTreeView *tv, GtkTreePath *path,
- GtkTreeViewColumn *col, gpointer data)
-{
- GtkTreeSelection *selection;
- PidginNotifyMsgData *msg_data;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- model = GTK_TREE_MODEL(message_dialog->treemodel);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(message_dialog->treeview));
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter) )
- return;
-
- gtk_tree_model_get(model, &iter, PIDGIN_MSG_DATA, &msg_data, -1);
-
- pidgin_notify_message_full(msg_data->type, msg_data->title,
- msg_data->primary, msg_data->secondary);
-}
-
-static void
selection_changed_cb(GtkTreeSelection *sel, PidginNotifyDialog *dialog)
{
GtkTreeIter iter;
@@ -1551,51 +1605,6 @@ pidgin_notify_uri(const char *uri)
return NULL;
}
-void
-pidgin_notify_pounce_add(PurpleAccount *account, PurplePounce *pounce,
- const char *alias, const char *event, const char *message, const char *date)
-{
- GdkPixbuf *icon;
- GtkTreeIter iter;
- PidginNotifyPounceData *pounce_data;
- gboolean first = (pounce_dialog == NULL);
-
- if (pounce_dialog == NULL)
- pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE);
-
- icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
-
- pounce_data = g_new(PidginNotifyPounceData, 1);
-
- pounce_data->account = account;
- pounce_data->pounce = pounce;
- pounce_data->pouncee = g_strdup(purple_pounce_get_pouncee(pounce));
-
- gtk_tree_store_append(pounce_dialog->treemodel, &iter, NULL);
-
- gtk_tree_store_set(pounce_dialog->treemodel, &iter,
- PIDGIN_POUNCE_ICON, icon,
- PIDGIN_POUNCE_ALIAS, alias,
- PIDGIN_POUNCE_EVENT, event,
- PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"),
- PIDGIN_POUNCE_DATE, date,
- PIDGIN_POUNCE_DATA, pounce_data,
- -1);
-
- if (first) {
- GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
- gtk_tree_selection_select_iter(selection, &iter);
- }
-
- if (icon)
- g_object_unref(icon);
-
- gtk_widget_show_all(pounce_dialog->dialog);
-
- return;
-}
-
static PidginNotifyDialog *
pidgin_create_notification_dialog(PidginNotifyType type)
{
More information about the Commits
mailing list