comparison src/dupe.c @ 1420:3a9fb1b52559

Use gboolean where applicable, for the sake of consistency.
author zas_
date Thu, 12 Mar 2009 21:06:37 +0000
parents a0bd58a6535f
children cf4029d10d38
comparison
equal deleted inserted replaced
1419:c520cfd40aef 1420:3a9fb1b52559
89 * Window updates 89 * Window updates
90 * ------------------------------------------------------------------ 90 * ------------------------------------------------------------------
91 */ 91 */
92 92
93 93
94 static void dupe_window_update_count(DupeWindow *dw, gint count_only) 94 static void dupe_window_update_count(DupeWindow *dw, gboolean count_only)
95 { 95 {
96 gchar *text; 96 gchar *text;
97 97
98 if (!dw->list) 98 if (!dw->list)
99 { 99 {
131 static gint dupe_iterations(gint n) 131 static gint dupe_iterations(gint n)
132 { 132 {
133 return (n * ((n + 1) / 2)); 133 return (n * ((n + 1) / 2));
134 } 134 }
135 135
136 static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdouble value, gint force) 136 static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdouble value, gboolean force)
137 { 137 {
138 const gchar *status_text; 138 const gchar *status_text;
139 139
140 if (status) 140 if (status)
141 { 141 {
679 g_list_free(slist); 679 g_list_free(slist);
680 680
681 return g_list_reverse(list); 681 return g_list_reverse(list);
682 } 682 }
683 683
684 static gint dupe_listview_item_is_selected(DupeWindow *dw, DupeItem *di, GtkWidget *listview) 684 static gboolean dupe_listview_item_is_selected(DupeWindow *dw, DupeItem *di, GtkWidget *listview)
685 { 685 {
686 GtkTreeModel *store; 686 GtkTreeModel *store;
687 GtkTreeSelection *selection; 687 GtkTreeSelection *selection;
688 GList *slist; 688 GList *slist;
689 GList *work; 689 GList *work;
690 gint found = FALSE; 690 gboolean found = FALSE;
691 691
692 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview)); 692 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview));
693 slist = gtk_tree_selection_get_selected_rows(selection, &store); 693 slist = gtk_tree_selection_get_selected_rows(selection, &store);
694 work = slist; 694 work = slist;
695 while (!found && work) 695 while (!found && work)
786 { 786 {
787 dupe_match_unlink_child(a, b); 787 dupe_match_unlink_child(a, b);
788 dupe_match_unlink_child(b, a); 788 dupe_match_unlink_child(b, a);
789 } 789 }
790 790
791 static void dupe_match_link_clear(DupeItem *parent, gint unlink_children) 791 static void dupe_match_link_clear(DupeItem *parent, gboolean unlink_children)
792 { 792 {
793 GList *work; 793 GList *work;
794 794
795 work = parent->group; 795 work = parent->group;
796 while (work) 796 while (work)
1110 * ------------------------------------------------------------------ 1110 * ------------------------------------------------------------------
1111 * Match group tests 1111 * Match group tests
1112 * ------------------------------------------------------------------ 1112 * ------------------------------------------------------------------
1113 */ 1113 */
1114 1114
1115 static gint dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble *rank, gint fast) 1115 static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble *rank, gint fast)
1116 { 1116 {
1117 *rank = 0.0; 1117 *rank = 0.0;
1118 1118
1119 if (a == b) return FALSE; 1119 if (a == b) return FALSE;
1120 1120
1418 if (dw->second_set && g_list_first(p) == dw->list) return dw->second_list; 1418 if (dw->second_set && g_list_first(p) == dw->list) return dw->second_list;
1419 1419
1420 return NULL; 1420 return NULL;
1421 } 1421 }
1422 1422
1423 static gint dupe_check_cb(gpointer data) 1423 static gboolean dupe_check_cb(gpointer data)
1424 { 1424 {
1425 DupeWindow *dw = data; 1425 DupeWindow *dw = data;
1426 1426
1427 if (dw->idle_id == -1) return FALSE; 1427 if (dw->idle_id == -1) return FALSE;
1428 1428
1694 dupe_item_free(di); 1694 dupe_item_free(di);
1695 1695
1696 dupe_window_update_count(dw, FALSE); 1696 dupe_window_update_count(dw, FALSE);
1697 } 1697 }
1698 1698
1699 static gint dupe_item_remove_by_path(DupeWindow *dw, const gchar *path) 1699 static gboolean dupe_item_remove_by_path(DupeWindow *dw, const gchar *path)
1700 { 1700 {
1701 DupeItem *di; 1701 DupeItem *di;
1702 1702
1703 di = dupe_item_find_path(dw, path); 1703 di = dupe_item_find_path(dw, path);
1704 if (!di) return FALSE; 1704 if (!di) return FALSE;
1707 1707
1708 return TRUE; 1708 return TRUE;
1709 } 1709 }
1710 1710
1711 static void dupe_files_add(DupeWindow *dw, CollectionData *collection, CollectInfo *info, 1711 static void dupe_files_add(DupeWindow *dw, CollectionData *collection, CollectInfo *info,
1712 FileData *fd, gint recurse) 1712 FileData *fd, gboolean recurse)
1713 { 1713 {
1714 DupeItem *di = NULL; 1714 DupeItem *di = NULL;
1715 1715
1716 if (info) 1716 if (info)
1717 { 1717 {
1775 } 1775 }
1776 1776
1777 dupe_check_start(dw); 1777 dupe_check_start(dw);
1778 } 1778 }
1779 1779
1780 void dupe_window_add_files(DupeWindow *dw, GList *list, gint recurse) 1780 void dupe_window_add_files(DupeWindow *dw, GList *list, gboolean recurse)
1781 { 1781 {
1782 GList *work; 1782 GList *work;
1783 1783
1784 work = list; 1784 work = list;
1785 while (work) 1785 while (work)
2291 G_CALLBACK(dupe_menu_close_cb), dw); 2291 G_CALLBACK(dupe_menu_close_cb), dw);
2292 2292
2293 return menu; 2293 return menu;
2294 } 2294 }
2295 2295
2296 static gint dupe_listview_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 2296 static gboolean dupe_listview_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
2297 { 2297 {
2298 DupeWindow *dw = data; 2298 DupeWindow *dw = data;
2299 GtkTreeModel *store; 2299 GtkTreeModel *store;
2300 GtkTreePath *tpath; 2300 GtkTreePath *tpath;
2301 GtkTreeIter iter; 2301 GtkTreeIter iter;
2374 } 2374 }
2375 2375
2376 return FALSE; 2376 return FALSE;
2377 } 2377 }
2378 2378
2379 static gint dupe_listview_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 2379 static gboolean dupe_listview_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
2380 { 2380 {
2381 DupeWindow *dw = data; 2381 DupeWindow *dw = data;
2382 GtkTreeModel *store; 2382 GtkTreeModel *store;
2383 GtkTreePath *tpath; 2383 GtkTreePath *tpath;
2384 GtkTreeIter iter; 2384 GtkTreeIter iter;
2553 } 2553 }
2554 2554
2555 static GtkWidget *dupe_menu_popup_second(DupeWindow *dw, DupeItem *di) 2555 static GtkWidget *dupe_menu_popup_second(DupeWindow *dw, DupeItem *di)
2556 { 2556 {
2557 GtkWidget *menu; 2557 GtkWidget *menu;
2558 gint notempty; 2558 gboolean notempty = (dw->second_list != NULL);
2559 gint on_row; 2559 gboolean on_row = (di != NULL);
2560
2561 on_row = (di != NULL);
2562 notempty = (dw->second_list != NULL);
2563 2560
2564 menu = popup_menu_short_lived(); 2561 menu = popup_menu_short_lived();
2565 menu_item_add_sensitive(menu, _("_View"), on_row, 2562 menu_item_add_sensitive(menu, _("_View"), on_row,
2566 G_CALLBACK(dupe_second_menu_view_cb), dw); 2563 G_CALLBACK(dupe_second_menu_view_cb), dw);
2567 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row, 2564 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row,
2722 g_object_set(G_OBJECT(cell), 2719 g_object_set(G_OBJECT(cell),
2723 "cell-background-gdk", dupe_listview_color_shifted(dw->listview), 2720 "cell-background-gdk", dupe_listview_color_shifted(dw->listview),
2724 "cell-background-set", set, NULL); 2721 "cell-background-set", set, NULL);
2725 } 2722 }
2726 2723
2727 static void dupe_listview_add_column(DupeWindow *dw, GtkWidget *listview, gint n, const gchar *title, gint image, gint right_justify) 2724 static void dupe_listview_add_column(DupeWindow *dw, GtkWidget *listview, gint n, const gchar *title, gboolean image, gboolean right_justify)
2728 { 2725 {
2729 GtkTreeViewColumn *column; 2726 GtkTreeViewColumn *column;
2730 GtkCellRenderer *renderer; 2727 GtkCellRenderer *renderer;
2731 2728
2732 column = gtk_tree_view_column_new(); 2729 column = gtk_tree_view_column_new();
2766 } 2763 }
2767 2764
2768 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column); 2765 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column);
2769 } 2766 }
2770 2767
2771 static void dupe_listview_set_height(GtkWidget *listview, gint thumb) 2768 static void dupe_listview_set_height(GtkWidget *listview, gboolean thumb)
2772 { 2769 {
2773 GtkTreeViewColumn *column; 2770 GtkTreeViewColumn *column;
2774 GtkCellRenderer *cell; 2771 GtkCellRenderer *cell;
2775 GList *list; 2772 GList *list;
2776 2773
2853 popup_menu_position_clamp(menu, &cx, &cy, 0); 2850 popup_menu_position_clamp(menu, &cx, &cy, 0);
2854 *x = cx; 2851 *x = cx;
2855 *y = cy; 2852 *y = cy;
2856 } 2853 }
2857 2854
2858 static gint dupe_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) 2855 static gboolean dupe_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
2859 { 2856 {
2860 DupeWindow *dw = data; 2857 DupeWindow *dw = data;
2861 gint stop_signal = FALSE; 2858 gboolean stop_signal = FALSE;
2862 gint on_second; 2859 gboolean on_second;
2863 GtkWidget *listview; 2860 GtkWidget *listview;
2864 GtkTreeModel *store; 2861 GtkTreeModel *store;
2865 GtkTreeSelection *selection; 2862 GtkTreeSelection *selection;
2866 GList *slist; 2863 GList *slist;
2867 DupeItem *di = NULL; 2864 DupeItem *di = NULL;
3468 dupe_window_add_files(dw, list, FALSE); 3465 dupe_window_add_files(dw, list, FALSE);
3469 filelist_free(list); 3466 filelist_free(list);
3470 } 3467 }
3471 } 3468 }
3472 3469
3473 static void dupe_dest_set(GtkWidget *widget, gint enable) 3470 static void dupe_dest_set(GtkWidget *widget, gboolean enable)
3474 { 3471 {
3475 if (enable) 3472 if (enable)
3476 { 3473 {
3477 gtk_drag_dest_set(widget, 3474 gtk_drag_dest_set(widget,
3478 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, 3475 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,