| 49 |
49 |
| 50 /****************************************************************************** |
50 /****************************************************************************** |
| 51 * Helpers |
51 * Helpers |
| 52 *****************************************************************************/ |
52 *****************************************************************************/ |
| 53 static GtkWidget * |
53 static GtkWidget * |
| 54 pidgin_notification_list_unknown_notification(PurpleNotification *notification) { |
|
| 55 GtkWidget *widget = NULL; |
|
| 56 gchar *label = NULL; |
|
| 57 const gchar *title = NULL; |
|
| 58 |
|
| 59 title = purple_notification_get_title(notification); |
|
| 60 if(title != NULL) { |
|
| 61 label = g_strdup_printf(_("Unknown notification type %d: %s"), |
|
| 62 purple_notification_get_notification_type(notification), |
|
| 63 title); |
|
| 64 } else { |
|
| 65 label = g_strdup_printf(_("Unknown notification type %d"), |
|
| 66 purple_notification_get_notification_type(notification)); |
|
| 67 } |
|
| 68 |
|
| 69 widget = gtk_label_new(label); |
|
| 70 |
|
| 71 g_free(label); |
|
| 72 |
|
| 73 return widget; |
|
| 74 } |
|
| 75 |
|
| 76 static GtkWidget * |
|
| 77 pidgin_notification_generic_new(PurpleNotification *notification) { |
54 pidgin_notification_generic_new(PurpleNotification *notification) { |
| 78 GtkWidget *row = NULL; |
55 GtkWidget *row = NULL; |
| 79 GtkWidget *icon = NULL; |
56 GtkWidget *icon = NULL; |
| 80 |
57 |
| 81 icon = gtk_image_new(); |
58 icon = gtk_image_new(); |
| 147 GtkWidget *widget = NULL; |
124 GtkWidget *widget = NULL; |
| 148 |
125 |
| 149 notification = gtk_list_item_get_item(item); |
126 notification = gtk_list_item_get_item(item); |
| 150 |
127 |
| 151 switch(purple_notification_get_notification_type(notification)) { |
128 switch(purple_notification_get_notification_type(notification)) { |
| 152 case PURPLE_NOTIFICATION_TYPE_GENERIC: |
|
| 153 widget = pidgin_notification_generic_new(notification); |
|
| 154 break; |
|
| 155 case PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR: |
129 case PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR: |
| 156 widget = pidgin_notification_connection_error_new(notification); |
130 widget = pidgin_notification_connection_error_new(notification); |
| 157 break; |
131 break; |
| 158 case PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST: |
132 case PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST: |
| 159 widget = pidgin_notification_authorization_request_new(notification); |
133 widget = pidgin_notification_authorization_request_new(notification); |
| 160 break; |
134 break; |
| 161 case PURPLE_NOTIFICATION_TYPE_ADD_CONTACT: |
135 case PURPLE_NOTIFICATION_TYPE_ADD_CONTACT: |
| 162 widget = pidgin_notification_add_contact_new(notification); |
136 widget = pidgin_notification_add_contact_new(notification); |
| 163 break; |
137 break; |
| |
138 case PURPLE_NOTIFICATION_TYPE_GENERIC: |
| 164 default: |
139 default: |
| 165 widget = pidgin_notification_list_unknown_notification(notification); |
140 widget = pidgin_notification_generic_new(notification); |
| 166 break; |
141 break; |
| 167 } |
|
| 168 |
|
| 169 if(!GTK_IS_WIDGET(widget)) { |
|
| 170 widget = pidgin_notification_list_unknown_notification(notification); |
|
| 171 } |
142 } |
| 172 |
143 |
| 173 gtk_list_item_set_child(item, widget); |
144 gtk_list_item_set_child(item, widget); |
| 174 } |
145 } |
| 175 |
146 |