[Cxplorer-cvs 01102] CVS update: cxplorer/src

Zurück zum Archiv-Index

Yasumichi Akahoshi yasum****@users*****
2005年 5月 10日 (火) 23:59:57 JST


Index: cxplorer/src/cxp-right-pane.c
diff -u cxplorer/src/cxp-right-pane.c:1.39 cxplorer/src/cxp-right-pane.c:1.40
--- cxplorer/src/cxp-right-pane.c:1.39	Tue May 10 23:26:45 2005
+++ cxplorer/src/cxp-right-pane.c	Tue May 10 23:59:56 2005
@@ -59,6 +59,7 @@
 	COL_DISP_NAME,		/**< displayname */
 	COL_FILE_PATH,		/**< Full path of file */
 	COL_FILE_SIZE,		/**< File size */
+	COL_FILE_TYPE,		/**< string of file type. */
 	COL_FILE_MODE,		/**< File type */
 	COL_UPDATE_TIME,	/**< Update time of file */
 	COL_COUNT		/**< Count of columns */
@@ -103,16 +104,11 @@
 				      GtkCellRenderer * cell,
 				      GtkTreeModel * tree_model,
 				      GtkTreeIter * iter, gpointer data);
-static void cxp_right_pane_draw_file_type (GtkTreeViewColumn * tree_column,
-					   GtkCellRenderer * cell,
-					   GtkTreeModel * tree_model,
-					   GtkTreeIter * iter, gpointer data);
 static gint cxp_right_pane_compare_by_default (GtkTreeModel * model,
 					       GtkTreeIter * iter_a,
 					       GtkTreeIter * iter_b,
 					       gpointer user_data);
-static GtkTreeIter cxp_right_pane_append_file (GtkListStore * store,
-					       const gchar * fullpath);
+static GtkTreeIter cxp_right_pane_append_file (CxpRightPane *self, GtkListStore * store, const gchar * fullpath);
 static void cxp_right_pane_show_preview (CxpRightPane * self,
 					 GtkTextBuffer * text_buffer,
 					 const gchar * filename);
@@ -304,8 +300,7 @@
 	GtkTreeSortable *sortable;
 
 	file_list = gtk_tree_view_new ();
-	store = gtk_list_store_new (COL_COUNT, G_TYPE_STRING, G_TYPE_STRING,
-				    G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+	store = gtk_list_store_new (COL_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT);
 	gtk_tree_view_set_model (GTK_TREE_VIEW (file_list),
 				 GTK_TREE_MODEL (store));
 
@@ -336,24 +331,19 @@
 	/* 2nd column */
 	renderer = gtk_cell_renderer_text_new ();
 	g_object_set (renderer, "xalign", 1.0, NULL);
-	column = gtk_tree_view_column_new_with_attributes (_("Size"),
-							   renderer, "text",
-							   COL_FILE_SIZE, NULL);
+	column = gtk_tree_view_column_new_with_attributes (_("Size"), renderer, "text", COL_FILE_SIZE, NULL);
 	gtk_tree_view_column_set_resizable (column, TRUE);
 	gtk_tree_view_column_set_sort_column_id (column, COL_FILE_SIZE);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (file_list), column);
 
 	/* 3rd column */
 	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Type"),
-							   renderer, NULL);
+	column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer, "text", COL_FILE_TYPE, NULL);
 	gtk_tree_view_column_set_resizable (column, TRUE);
 	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
 	gtk_tree_view_column_set_fixed_width (column, 100);
+	gtk_tree_view_column_set_sort_column_id (column, COL_FILE_TYPE);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (file_list), column);
-	gtk_tree_view_column_set_cell_data_func (column, renderer,
-						 cxp_right_pane_draw_file_type,
-						 self, NULL);
 
 	/* 4th column */
 	renderer = gtk_cell_renderer_text_new ();
@@ -485,32 +475,6 @@
 }
 
 /**
- * This function is called back before file type is shown.
- * @param tree_column [in] Pointer to instance fo GtkTreeViewColumn.
- * @param cell [in] Pointer to instance of GtkCellRender which render text.
- * @param tree_model [in] Pointer to memory model of GtkTreeView.
- * @param iter [in] Iterator of node which want to be paint by GtkCellRender.
- * @param data [in] Pointer to data which is defined by user.
- */
-static void cxp_right_pane_draw_file_type (GtkTreeViewColumn * tree_column,
-					   GtkCellRenderer * cell,
-					   GtkTreeModel * tree_model,
-					   GtkTreeIter * iter, gpointer data)
-{
-	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (data);
-	gchar *fullpath;
-	gchar **filetype;
-
-	gtk_tree_model_get (tree_model, iter, COL_FILE_PATH,
-			    &fullpath, COL_TERMINATOR);
-
-	filetype =
-		g_strsplit (magic_file (priv->normal_cookie, fullpath), ",", 2);
-	g_object_set (cell, "text", filetype[0], NULL);
-	g_strfreev (filetype);
-}
-
-/**
  * This function is called back before update time is shown.
  * @param tree_column [in] Pointer to instance fo GtkTreeViewColumn.
  * @param cell [in] Pointer to instance of GtkCellRender which render text.
@@ -598,21 +562,21 @@
  * @param gcLabel [in] UTF-8 string.
  * @return GtkTreeIter of appendded row.
  */
-static GtkTreeIter cxp_right_pane_append_file (GtkListStore * store,
-					       const gchar * fullpath)
+static GtkTreeIter cxp_right_pane_append_file (CxpRightPane *self, GtkListStore * store, const gchar * fullpath)
 {
+	CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (self);
 	GtkTreeIter iter;
 	struct stat status;
 	gchar *dispname;
+	gchar **filetype;
 
 	dispname = cxp_path_get_basename_of_utf8 (fullpath);
+	filetype = g_strsplit (magic_file (priv->normal_cookie, fullpath), ",", 2);
 	stat (fullpath, &status);
 	gtk_list_store_prepend (store, &iter);
-	gtk_list_store_set (store, &iter, COL_DISP_NAME, dispname,
-			    COL_FILE_PATH, fullpath, COL_FILE_SIZE,
-			    status.st_size, COL_FILE_MODE, status.st_mode,
-			    COL_UPDATE_TIME, status.st_mtime, COL_TERMINATOR);
+	gtk_list_store_set (store, &iter, COL_DISP_NAME, dispname, COL_FILE_PATH, fullpath, COL_FILE_SIZE, status.st_size, COL_FILE_TYPE, filetype[0], COL_FILE_MODE, status.st_mode, COL_UPDATE_TIME, status.st_mtime, COL_TERMINATOR);
 	g_free (dispname);
+	g_strfreev (filetype);
 
 	return iter;
 }
@@ -752,8 +716,7 @@
 				continue;
 			}
 			fullpath = g_build_filename (dirname, filename, NULL);
-			cxp_right_pane_append_file (GTK_LIST_STORE (model),
-						    fullpath);
+			cxp_right_pane_append_file (self, GTK_LIST_STORE (model), fullpath);
 			g_free (fullpath);
 		}
 		g_dir_close (dir);
@@ -819,8 +782,7 @@
 		{
 			model = gtk_tree_view_get_model (GTK_TREE_VIEW
 							 (priv->file_list));
-			iter = cxp_right_pane_append_file (GTK_LIST_STORE
-							   (model), fullpath);
+			iter = cxp_right_pane_append_file (right_pane, GTK_LIST_STORE (model), fullpath);
 			treepath = gtk_tree_model_get_path (model, &iter);
 			gtk_tree_view_set_cursor (GTK_TREE_VIEW
 						  (priv->


Cxplorer-cvs メーリングリストの案内
Zurück zum Archiv-Index