[gnac/devel] Code cleanup



commit 0182253c693fb2cc4229a28c56d325c1d2420c43
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date:   Sat Oct 29 01:46:15 2011 +0100

    Code cleanup

 src/gnac-file-list.c |   46 ++++++++++++++++++++--------------------------
 1 files changed, 20 insertions(+), 26 deletions(-)
---
diff --git a/src/gnac-file-list.c b/src/gnac-file-list.c
index 9ddc2ef..01bc5ea 100644
--- a/src/gnac-file-list.c
+++ b/src/gnac-file-list.c
@@ -36,7 +36,7 @@
 #include "libgnac-debug.h"
 
 
-static GtkWidget        *view = NULL;
+static GtkTreeView      *view = NULL;
 static GtkTreeModel     *model = NULL;
 static GtkTreeSelection *selection = NULL;
 static GHashTable       *reference_table = NULL;
@@ -125,42 +125,42 @@ gnac_file_list_new(void)
   reference_table = g_hash_table_new_full(g_str_hash, g_str_equal,
       g_free, (GDestroyNotify)gtk_tree_row_reference_free);
 
-  view = gnac_ui_get_widget("file_list");
-  gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view), COL_TOOLTIP);
+  view = GTK_TREE_VIEW(gnac_ui_get_widget("file_list"));
+  gtk_tree_view_set_tooltip_column(view, COL_TOOLTIP);
 
   model = GTK_TREE_MODEL(gtk_list_store_new(NUM_COLS, 
       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING));
 
   renderer = gtk_cell_renderer_pixbuf_new();
-  gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), -1,
+  gtk_tree_view_insert_column_with_data_func(view, -1,
       "Status", renderer, gnac_file_list_display_stock, NULL, NULL);
 
   renderer = gtk_cell_renderer_text_new();
   g_object_set(G_OBJECT(renderer), "ypad", 5, NULL);
-  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1,
+  gtk_tree_view_insert_column_with_attributes(view, -1,
       "Filelist", renderer, "text", COL_DISPLAY, NULL);
 
-  gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
-  gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
+  gtk_tree_view_set_model(view, model);
+  gtk_tree_view_set_rules_hint(view, TRUE);
   
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(view),COL_URI);
-  gtk_tree_view_column_set_sort_column_id (column,COL_URI);
-  gtk_tree_view_column_clicked (column);
+  column = gtk_tree_view_get_column(view, COL_URI);
+  gtk_tree_view_column_set_sort_column_id(column,COL_URI);
+  gtk_tree_view_column_clicked(column);
 
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(view),COL_STOCK);
+  column = gtk_tree_view_get_column(view, COL_STOCK);
   gtk_tree_view_column_set_visible(column, FALSE);
   
   g_signal_connect(G_OBJECT(model), "row-inserted", 
       G_CALLBACK(gnac_file_list_on_row_inserted_cb), NULL);
 
-  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+  selection = gtk_tree_view_get_selection(view);
   gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
   g_signal_connect(G_OBJECT(selection), "changed", 
       G_CALLBACK(gnac_file_list_selection_changed_cb), NULL);
   
   g_object_unref(model);
 
-  return view;
+  return GTK_WIDGET(view);
 }
 
 
@@ -168,11 +168,11 @@ void
 gnac_file_list_attach_default_model(gboolean attach)
 {
   if (attach) {
-    gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
+    gtk_tree_view_set_model(view, model);
     g_object_unref(G_OBJECT(model));
   } else {
     g_object_ref(G_OBJECT(model));
-    gtk_tree_view_set_model(GTK_TREE_VIEW(view), NULL);
+    gtk_tree_view_set_model(view, NULL);
   }
 }
 
@@ -284,15 +284,10 @@ gnac_file_list_remove_all(void)
   gtk_list_store_clear(GTK_LIST_STORE(model));
   g_hash_table_remove_all(reference_table);
   gnac_file_list_attach_default_model(TRUE);
-  gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
+  gtk_tree_view_columns_autosize(view);
 }
 
 
-/*  
- *  WARNING : To free the return value, use :
- *  g_list_foreach (list, (GFunc)gtk_tree_row_reference_free, NULL);
- *  g_list_free (list);
- */
 GList *
 gnac_file_list_get_selected_rows(void)
 {
@@ -302,7 +297,6 @@ gnac_file_list_get_selected_rows(void)
 
   row_path = gtk_tree_selection_get_selected_rows(selection, &model);
   
-  /* Convert path to GtkTreeRowReference */
   next = row_path;
   while (next) {
     row_references = g_list_prepend(row_references, 
@@ -436,7 +430,7 @@ gnac_file_list_select_row_and_follow(GtkTreeRowReference *reference)
   if (!path) return;
   
   gtk_tree_selection_unselect_all(selection);
-  gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(view), path, NULL, TRUE, 0.5, 0.0);
+  gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
   gtk_tree_selection_select_path(selection, path);
   gtk_tree_path_free(path);
 }
@@ -464,7 +458,7 @@ gnac_file_list_visual_error(const gchar *uri,
   GtkTreeRowReference *ref = NULL;
   GtkTreeViewColumn   *column;
 
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(view),COL_STOCK);
+  column = gtk_tree_view_get_column(view,COL_STOCK);
 
   ref = g_hash_table_lookup(reference_table, uri);
   g_return_if_fail(ref);
@@ -489,7 +483,7 @@ void
 gnac_file_list_hide_visual_bar(void)
 {
   GtkTreeViewColumn *column; 
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(view),COL_STOCK);
+  column = gtk_tree_view_get_column(view,COL_STOCK);
   gtk_tree_view_column_set_visible(column, FALSE);
 }
 
@@ -570,7 +564,7 @@ gnac_file_list_update_cursor(void)
   {
     cursor = gdk_cursor_new(GDK_WATCH);
   }
-  gdk_window_set_cursor(view->window, cursor);
+  gdk_window_set_cursor(GTK_WIDGET(view)->window, cursor);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]