Changeset 13938
- Timestamp:
- Feb 2, 2013, 11:01:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/filter.c
r13927 r13938 113 113 114 114 static gboolean 115 tracker_filter_model_update ( GtkTreeStore *store)115 tracker_filter_model_update (gpointer gstore) 116 116 { 117 117 int i, n; … … 119 119 int store_pos; 120 120 GtkTreeIter iter; 121 GtkTreeModel * model = GTK_TREE_MODEL (store); 121 GObject * o = G_OBJECT (gstore); 122 GtkTreeStore * store = GTK_TREE_STORE (gstore); 123 GtkTreeModel * model = GTK_TREE_MODEL (gstore); 122 124 GPtrArray * hosts = g_ptr_array_new (); 123 125 GStringChunk * strings = g_string_chunk_new (4096); 124 126 GHashTable * hosts_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); 125 GObject * o = G_OBJECT (store);126 127 GtkTreeModel * tmodel = GTK_TREE_MODEL (g_object_get_qdata (o, TORRENT_MODEL_KEY)); 127 128 const int first_tracker_pos = 2; /* offset past the "All" and the separator */ … … 267 268 g_hash_table_unref (hosts_hash); 268 269 g_string_chunk_free (strings); 269 return FALSE;270 return G_SOURCE_REMOVE; 270 271 } 271 272 … … 308 309 if (!pending) 309 310 { 310 GSourceFunc func = (GSourceFunc)tracker_filter_model_update;311 GSourceFunc func = tracker_filter_model_update; 311 312 g_object_set_qdata (o, DIRTY_KEY, GINT_TO_POINTER (1)); 312 313 gdk_threads_add_idle (func, tracker_model); … … 543 544 } 544 545 545 static void546 activity_filter_model_update ( GtkListStore *store)546 static gboolean 547 activity_filter_model_update (gpointer gstore) 547 548 { 548 549 GtkTreeIter iter; 550 GObject * o = G_OBJECT (gstore); 551 GtkListStore * store = GTK_LIST_STORE (gstore); 549 552 GtkTreeModel * model = GTK_TREE_MODEL (store); 550 GObject * o = G_OBJECT (store);551 553 GtkTreeModel * tmodel = GTK_TREE_MODEL (g_object_get_qdata (o, TORRENT_MODEL_KEY)); 552 554 … … 572 574 573 575 status_model_update_count (store, &iter, hits); 574 575 576 } 576 577 while (gtk_tree_model_iter_next (model, &iter)); 578 579 return G_SOURCE_REMOVE; 577 580 } 578 581 … … 646 649 if (!pending) 647 650 { 648 GSourceFunc func = (GSourceFunc)activity_filter_model_update;651 GSourceFunc func = activity_filter_model_update; 649 652 g_object_set_qdata (o, DIRTY_KEY, GINT_TO_POINTER (1)); 650 653 gdk_threads_add_idle (func, activity_model); … … 860 863 ***/ 861 864 862 static void863 update_count_label ( struct filter_data *data)865 static gboolean 866 update_count_label (gpointer gdata) 864 867 { 865 868 char buf[512]; 866 GtkTreeModel * tmodel = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (data->filter_model)); 867 const int torrentCount = gtk_tree_model_iter_n_children (tmodel, NULL); 868 const int visibleCount = gtk_tree_model_iter_n_children (data->filter_model, NULL); 869 int visibleCount; 870 int trackerCount; 871 int activityCount; 872 GtkTreeModel * model; 873 GtkComboBox * combo; 874 GtkTreeIter iter; 875 struct filter_data * data = gdata; 876 877 /* get the visible count */ 878 visibleCount = gtk_tree_model_iter_n_children (data->filter_model, NULL); 879 880 /* get the tracker count */ 881 combo = GTK_COMBO_BOX (data->tracker); 882 model = gtk_combo_box_get_model (combo); 883 if (gtk_combo_box_get_active_iter (combo, &iter)) 884 gtk_tree_model_get (model, &iter, TRACKER_FILTER_COL_COUNT, &trackerCount, -1); 885 else 886 trackerCount = 0; 887 888 /* get the activity count */ 889 combo = GTK_COMBO_BOX (data->activity); 890 model = gtk_combo_box_get_model (combo); 891 if (gtk_combo_box_get_active_iter (combo, &iter)) 892 gtk_tree_model_get (model, &iter, ACTIVITY_FILTER_COL_COUNT, &activityCount, -1); 893 else 894 activityCount = 0; 869 895 870 896 /* set the text */ 871 if (visibleCount == torrentCount)897 if (visibleCount == MIN (activityCount, trackerCount)) 872 898 g_snprintf (buf, sizeof(buf), _("_Show:")); 873 899 else 874 g_snprintf (buf, sizeof(buf), _("_Show %'d :"), visibleCount);900 g_snprintf (buf, sizeof(buf), _("_Show %'d of:"), visibleCount); 875 901 gtk_label_set_markup_with_mnemonic (GTK_LABEL (data->show_lb), buf); 902 903 g_object_steal_qdata (G_OBJECT(data->show_lb), DIRTY_KEY); 904 return G_SOURCE_REMOVE; 905 } 906 907 static void 908 update_count_label_idle (struct filter_data * data) 909 { 910 GObject * o = G_OBJECT (data->show_lb); 911 const gboolean pending = g_object_get_qdata (o, DIRTY_KEY) != NULL; 912 if (!pending) 913 { 914 g_object_set_qdata (o, DIRTY_KEY, GINT_TO_POINTER (1)); 915 gdk_threads_add_idle (update_count_label, data); 916 } 876 917 } 877 918 … … 882 923 gpointer data) 883 924 { 884 update_count_label (data);925 update_count_label_idle (data); 885 926 } 886 927 … … 890 931 gpointer data UNUSED) 891 932 { 892 update_count_label (data);933 update_count_label_idle (data); 893 934 } 894 935
Note: See TracChangeset
for help on using the changeset viewer.