comparison src/gtkstatusbox.c @ 11738:992d49cf2b92

[gaim-migrate @ 14029] Add a separator in the gtkstatusbox after the standard status types and before Custom... and Saved... I'm fixin' to clean this up a tiny bit committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 23 Oct 2005 04:48:01 +0000
parents 03c813a42c76
children a25be0e70a67
comparison
equal deleted inserted replaced
11737:3959c29f340f 11738:992d49cf2b92
47 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); 47 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition);
48 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); 48 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation);
49 static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event); 49 static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event);
50 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); 50 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
51 enum { 51 enum {
52 ICON_COLUMN, 52 ICON_COLUMN, /* This is a GdkPixbuf (the other columns are strings) */
53 TEXT_COLUMN, 53 TEXT_COLUMN, /* A string */
54 TITLE_COLUMN, 54 TITLE_COLUMN, /* The plain-English title of this item */
55 DESC_COLUMN, 55 DESC_COLUMN, /* A plain-English description of this item */
56 TYPE_COLUMN, 56 TYPE_COLUMN, /* A text description of the GaimStatusPrimitive */
57 NUM_COLUMNS 57 NUM_COLUMNS
58 }; 58 };
59 59
60 enum { 60 enum {
61 PROP_0, 61 PROP_0,
284 /* hacks */ 284 /* hacks */
285 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Available"), NULL, "available"); 285 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Available"), NULL, "available");
286 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf2, _("Away"), NULL, "away"); 286 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf2, _("Away"), NULL, "away");
287 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf4, _("Invisible"), NULL, "invisible"); 287 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf4, _("Invisible"), NULL, "invisible");
288 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf3, _("Offline"), NULL, "offline"); 288 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf3, _("Offline"), NULL, "offline");
289 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box));
289 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Custom..."), NULL, "custom"); 290 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Custom..."), NULL, "custom");
290 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Saved..."), NULL, "saved"); 291 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Saved..."), NULL, "saved");
291 292
292 current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); 293 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
293 saved_status = gaim_savedstatus_find(current_savedstatus_name); 294 saved_status = gaim_savedstatus_find(current_savedstatus_name);
344 } 345 }
345 } 346 }
346 347
347 } 348 }
348 349
350 static gboolean
351 dropdown_store_row_separator_func(GtkTreeModel *model,
352 GtkTreeIter *iter, gpointer data)
353 {
354 GdkPixbuf *pixbuf;
355 gchar *text, *title, *description, *status_type_id;
356
357 gtk_tree_model_get(model, iter,
358 ICON_COLUMN, &pixbuf,
359 TEXT_COLUMN, &text,
360 TITLE_COLUMN, &title,
361 DESC_COLUMN, &description,
362 TYPE_COLUMN, &status_type_id,
363 -1);
364
365 if ((pixbuf == NULL) && (text == NULL) && (title == NULL) &&
366 (description == NULL) && (status_type_id != NULL) &&
367 !strcmp(status_type_id, "separator"))
368 {
369 return TRUE;
370 }
371
372 return FALSE;
373 }
374
349 static void 375 static void
350 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) 376 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box)
351 { 377 {
352 GtkCellRenderer *text_rend; 378 GtkCellRenderer *text_rend;
353 GtkCellRenderer *icon_rend; 379 GtkCellRenderer *icon_rend;
388 status_box->cell_view = gtk_cell_view_new(); 414 status_box->cell_view = gtk_cell_view_new();
389 gtk_widget_show (status_box->cell_view); 415 gtk_widget_show (status_box->cell_view);
390 416
391 status_box->store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); 417 status_box->store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
392 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); 418 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
419 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL);
393 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); 420 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store));
394 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); 421 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store));
395 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); 422 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0);
396 gtk_list_store_append(status_box->store, &(status_box->iter)); 423 gtk_list_store_append(status_box->store, &(status_box->iter));
397 gtk_gaim_status_box_refresh(status_box); 424 gtk_gaim_status_box_refresh(status_box);
533 TEXT_COLUMN, t, 560 TEXT_COLUMN, t,
534 TITLE_COLUMN, text, 561 TITLE_COLUMN, text,
535 DESC_COLUMN, sec_text, 562 DESC_COLUMN, sec_text,
536 TYPE_COLUMN, edit, -1); 563 TYPE_COLUMN, edit, -1);
537 g_free(t); 564 g_free(t);
565 }
566
567 void
568 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box)
569 {
570 GtkTreeIter iter;
571
572 gtk_list_store_append(status_box->dropdown_store, &iter);
573 gtk_list_store_set(status_box->dropdown_store, &iter,
574 ICON_COLUMN, NULL,
575 TEXT_COLUMN, NULL,
576 TITLE_COLUMN, NULL,
577 DESC_COLUMN, NULL,
578 TYPE_COLUMN, "separator", -1);
538 } 579 }
539 580
540 void 581 void
541 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) 582 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error)
542 { 583 {