| 99 NULL); |
100 NULL); |
| 100 |
101 |
| 101 return row; |
102 return row; |
| 102 } |
103 } |
| 103 |
104 |
| 104 static GtkWidget * |
105 /****************************************************************************** |
| 105 pidgin_notification_list_create_widget_func(gpointer item, |
106 * Callbacks |
| 106 G_GNUC_UNUSED gpointer data) |
107 *****************************************************************************/ |
| |
108 static void |
| |
109 pidgin_notification_list_bind_cb(G_GNUC_UNUSED GtkSignalListItemFactory *self, |
| |
110 GObject *object, |
| |
111 G_GNUC_UNUSED gpointer data) |
| 107 { |
112 { |
| 108 PurpleNotification *notification = item; |
113 PurpleNotification *notification = NULL; |
| |
114 GtkListItem *item = GTK_LIST_ITEM(object); |
| 109 GtkWidget *widget = NULL; |
115 GtkWidget *widget = NULL; |
| |
116 |
| |
117 notification = gtk_list_item_get_item(item); |
| 110 |
118 |
| 111 switch(purple_notification_get_notification_type(notification)) { |
119 switch(purple_notification_get_notification_type(notification)) { |
| 112 case PURPLE_NOTIFICATION_TYPE_GENERIC: |
120 case PURPLE_NOTIFICATION_TYPE_GENERIC: |
| 113 widget = pidgin_notification_generic_new(notification); |
121 widget = pidgin_notification_generic_new(notification); |
| 114 break; |
122 break; |
| 128 |
136 |
| 129 if(!GTK_IS_WIDGET(widget)) { |
137 if(!GTK_IS_WIDGET(widget)) { |
| 130 widget = pidgin_notification_list_unknown_notification(notification); |
138 widget = pidgin_notification_list_unknown_notification(notification); |
| 131 } |
139 } |
| 132 |
140 |
| 133 return widget; |
141 gtk_list_item_set_child(item, widget); |
| 134 } |
142 } |
| 135 |
143 |
| 136 /****************************************************************************** |
144 /****************************************************************************** |
| 137 * GObject Implementation |
145 * GObject Implementation |
| 138 *****************************************************************************/ |
146 *****************************************************************************/ |
| 139 static void |
147 static void |
| 140 pidgin_notification_list_init(PidginNotificationList *list) { |
148 pidgin_notification_list_init(PidginNotificationList *list) { |
| |
149 GListModel *model = NULL; |
| |
150 |
| 141 gtk_widget_init_template(GTK_WIDGET(list)); |
151 gtk_widget_init_template(GTK_WIDGET(list)); |
| 142 |
152 |
| 143 gtk_list_box_bind_model(GTK_LIST_BOX(list->list_box), |
153 model = purple_notification_manager_get_default_as_model(); |
| 144 purple_notification_manager_get_default_as_model(), |
154 gtk_single_selection_set_model(list->selection_model, model); |
| 145 pidgin_notification_list_create_widget_func, |
|
| 146 list, NULL); |
|
| 147 } |
155 } |
| 148 |
156 |
| 149 static void |
157 static void |
| 150 pidgin_notification_list_class_init(PidginNotificationListClass *klass) { |
158 pidgin_notification_list_class_init(PidginNotificationListClass *klass) { |
| 151 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
159 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
| 152 |
160 |
| 153 gtk_widget_class_set_template_from_resource( |
161 gtk_widget_class_set_template_from_resource( |
| 154 widget_class, |
162 widget_class, |
| 155 "/im/pidgin/Pidgin3/Notifications/list.ui" |
163 "/im/pidgin/Pidgin3/notificationlist.ui" |
| 156 ); |
164 ); |
| 157 |
165 |
| 158 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList, |
166 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList, |
| 159 list_box); |
167 list_view); |
| |
168 gtk_widget_class_bind_template_child(widget_class, PidginNotificationList, |
| |
169 selection_model); |
| |
170 |
| |
171 gtk_widget_class_bind_template_callback(widget_class, |
| |
172 pidgin_notification_list_bind_cb); |
| 160 } |
173 } |
| 161 |
174 |
| 162 /****************************************************************************** |
175 /****************************************************************************** |
| 163 * API |
176 * API |
| 164 *****************************************************************************/ |
177 *****************************************************************************/ |