gnome-commander r2013 - in trunk: . src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2013 - in trunk: . src
- Date: Wed, 27 Aug 2008 20:52:48 +0000 (UTC)
Author: epiotr
Date: Wed Aug 27 20:52:48 2008
New Revision: 2013
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2013&view=rev
Log:
Convert GnomeCmdFileList struct into C++ class, part 3
Modified:
trunk/ChangeLog
trunk/src/gnome-cmd-file-list.cc
trunk/src/gnome-cmd-file-list.h
trunk/src/gnome-cmd-file-selector.cc
trunk/src/gnome-cmd-quicksearch-popup.cc
trunk/src/gnome-cmd-user-actions.cc
Modified: trunk/src/gnome-cmd-file-list.cc
==============================================================================
--- trunk/src/gnome-cmd-file-list.cc (original)
+++ trunk/src/gnome-cmd-file-list.cc Wed Aug 27 20:52:48 2008
@@ -220,7 +220,7 @@
{
g_return_val_if_fail (GNOME_CMD_IS_FILE_LIST (fl), NULL);
- return (GnomeCmdFile *) gtk_clist_get_row_data (GTK_CLIST (fl), row);
+ return (GnomeCmdFile *) gtk_clist_get_row_data (*fl, row);
}
@@ -229,7 +229,7 @@
g_return_val_if_fail (GNOME_CMD_IS_FILE_LIST (fl), -1);
g_return_val_if_fail (finfo != NULL, -1);
- return gtk_clist_find_row_from_data (GTK_CLIST (fl), finfo);
+ return gtk_clist_find_row_from_data (*fl, finfo);
}
@@ -283,7 +283,7 @@
g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
GTK_CLIST (fl)->focus_row = row;
- gtk_clist_select_row (GTK_CLIST (fl), row, 0);
+ gtk_clist_select_row (*fl, row, 0);
fl->priv->cur_file = GTK_CLIST (fl)->focus_row;
}
@@ -309,14 +309,14 @@
if (!gnome_cmd_data_get_use_ls_colors ())
- gtk_clist_set_row_style (GTK_CLIST (fl), row, sel_list_style);
+ gtk_clist_set_row_style (*fl, row, sel_list_style);
else
{
GnomeCmdColorTheme *colors = gnome_cmd_data_get_current_color_theme ();
if (!colors->respect_theme)
{
- gtk_clist_set_foreground (GTK_CLIST (fl), row, colors->sel_fg);
- gtk_clist_set_background (GTK_CLIST (fl), row, colors->sel_bg);
+ gtk_clist_set_foreground (*fl, row, colors->sel_fg);
+ gtk_clist_set_background (*fl, row, colors->sel_bg);
}
}
@@ -326,7 +326,7 @@
gnome_cmd_file_ref (finfo);
fl->priv->selected_files = g_list_append (fl->priv->selected_files, finfo);
- gtk_signal_emit (GTK_OBJECT (fl), file_list_signals[SELECTION_CHANGED]);
+ gtk_signal_emit (*fl, file_list_signals[SELECTION_CHANGED]);
}
@@ -346,23 +346,19 @@
fl->priv->selected_files = g_list_remove (fl->priv->selected_files, finfo);
if (!gnome_cmd_data_get_use_ls_colors ())
- gtk_clist_set_row_style (GTK_CLIST (fl), row, list_style);
+ gtk_clist_set_row_style (*fl, row, list_style);
else
- {
- LsColor *col = ls_colors_get (finfo);
- GnomeCmdColorTheme *colors = gnome_cmd_data_get_current_color_theme ();
- GdkColor *fg, *bg;
- if (col)
+ if (LsColor *col = ls_colors_get (finfo))
{
- fg = col->fg;
- bg = col->bg;
- if (!fg) fg = colors->norm_fg;
- if (!bg) bg = colors->norm_bg;
- if (bg) gtk_clist_set_background (GTK_CLIST (fl), row, bg);
- if (fg) gtk_clist_set_foreground (GTK_CLIST (fl), row, fg);
+ GnomeCmdColorTheme *colors = gnome_cmd_data_get_current_color_theme ();
+ GdkColor *fg = col->fg ? col->fg : colors->norm_fg;
+ GdkColor *bg = col->bg ? col->bg : colors->norm_bg;
+
+ if (bg) gtk_clist_set_background (*fl, row, bg);
+ if (fg) gtk_clist_set_foreground (*fl, row, fg);
}
- }
- gtk_signal_emit (GTK_OBJECT (fl), file_list_signals[SELECTION_CHANGED]);
+
+ gtk_signal_emit (*fl, file_list_signals[SELECTION_CHANGED]);
}
@@ -501,7 +497,7 @@
static void create_column_titles (GnomeCmdFileList *fl)
{
- gtk_clist_column_title_passive (GTK_CLIST (fl), GnomeCmdFileList::COLUMN_ICON);
+ gtk_clist_column_title_passive (*fl, GnomeCmdFileList::COLUMN_ICON);
for (gint i=GnomeCmdFileList::COLUMN_NAME; i<GnomeCmdFileList::NUM_COLUMNS; i++)
{
@@ -512,33 +508,33 @@
hbox = gtk_hbox_new (FALSE, 1);
gtk_widget_ref (hbox);
- gtk_object_set_data_full (GTK_OBJECT (fl), "column-hbox", hbox, (GtkDestroyNotify) gtk_widget_unref);
+ gtk_object_set_data_full (*fl, "column-hbox", hbox, (GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (hbox);
fl->priv->column_labels[i] = gtk_label_new (_(file_list_column[i].title));
gtk_widget_ref (fl->priv->column_labels[i]);
- gtk_object_set_data_full (GTK_OBJECT (fl), "column-label", fl->priv->column_labels[i],
+ gtk_object_set_data_full (*fl, "column-label", fl->priv->column_labels[i],
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (fl->priv->column_labels[i]);
gtk_box_pack_start (GTK_BOX (hbox), fl->priv->column_labels[i], TRUE, TRUE, 0);
pixmap = gtk_pixmap_new (pm, bm);
gtk_widget_ref (pixmap);
- gtk_object_set_data_full (GTK_OBJECT (fl), "column-pixmap", pixmap, (GtkDestroyNotify) gtk_widget_unref);
+ gtk_object_set_data_full (*fl, "column-pixmap", pixmap, (GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (pixmap);
gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
fl->priv->column_pixmaps[i] = pixmap;
- gtk_clist_set_column_widget (GTK_CLIST (fl), i, hbox);
+ gtk_clist_set_column_widget (*fl, i, hbox);
}
for (gint i=GnomeCmdFileList::COLUMN_ICON; i<GnomeCmdFileList::NUM_COLUMNS; i++)
{
- gtk_clist_set_column_width (GTK_CLIST (fl), i, gnome_cmd_data_get_fs_col_width (i));
- gtk_clist_set_column_justification (GTK_CLIST (fl), i, file_list_column[i].justification);
+ gtk_clist_set_column_width (*fl, i, gnome_cmd_data_get_fs_col_width (i));
+ gtk_clist_set_column_justification (*fl, i, file_list_column[i].justification);
}
- gtk_clist_column_titles_show (GTK_CLIST (fl));
+ gtk_clist_column_titles_show (*fl);
}
@@ -685,7 +681,7 @@
drag_types, G_N_ELEMENTS (drag_types),
(GdkDragAction) (GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_DEFAULT));
- gtk_signal_connect (GTK_OBJECT (fl), "drag_data_get", GTK_SIGNAL_FUNC (drag_data_get), fl);
+ gtk_signal_connect (*fl, "drag_data_get", GTK_SIGNAL_FUNC (drag_data_get), fl);
}
@@ -706,7 +702,7 @@
if (!menu) return;
gtk_widget_ref (menu);
- gtk_object_set_data_full (GTK_OBJECT (fl), "file_popup_menu", menu, (GtkDestroyNotify) gtk_widget_unref);
+ gtk_object_set_data_full (*fl, "file_popup_menu", menu, (GtkDestroyNotify) gtk_widget_unref);
gnome_popup_menu_do_popup (menu, (GtkMenuPositionFunc) popup_position_function, fl, event, fl, NULL);
}
@@ -1046,18 +1042,18 @@
if (GTK_CLIST (fl)->clist_window != event->window)
return FALSE;
- gtk_signal_emit (GTK_OBJECT (fl), file_list_signals[LIST_CLICKED], event);
+ gtk_signal_emit (*fl, file_list_signals[LIST_CLICKED], event);
- gint row = gnome_cmd_clist_get_row (GNOME_CMD_CLIST (fl), event->x, event->y);
+ gint row = gnome_cmd_clist_get_row (*fl, event->x, event->y);
if (row < 0)
{
- gtk_signal_emit (GTK_OBJECT (fl), file_list_signals[EMPTY_SPACE_CLICKED], event);
+ gtk_signal_emit (*fl, file_list_signals[EMPTY_SPACE_CLICKED], event);
return FALSE;
}
GnomeCmdFile *finfo = get_file_at_row (fl, row);
- gtk_signal_emit (GTK_OBJECT (fl), file_list_signals[FILE_CLICKED], finfo, event);
+ gtk_signal_emit (*fl, file_list_signals[FILE_CLICKED], finfo, event);
gtk_signal_emit_stop_by_name (GTK_OBJECT (clist), "button-press-event");
@@ -1095,7 +1091,7 @@
gint prev_row = fl->priv->cur_file;
gint row = get_row_from_file (fl, finfo);
- gnome_cmd_file_list_select_row (fl, row);
+ fl->select_row(row);
gtk_widget_grab_focus (GTK_WIDGET (fl));
if (event->button == 1)
@@ -1155,14 +1151,14 @@
y = event->y;
y -= (clist->column_title_area.height - GTK_CONTAINER (clist)->border_width);
- row = gnome_cmd_clist_get_row (GNOME_CMD_CLIST (fl), event->x, y);
+ row = gnome_cmd_clist_get_row (*fl, event->x, y);
if (row != -1)
{
GnomeCmdFile *finfo = gnome_cmd_file_list_get_file_at_row (fl, row+1);
if (finfo)
{
- gnome_cmd_file_list_select_row (fl, row+1);
+ fl->select_row(row+1);
if (fl->priv->right_mouse_sel_state)
select_file (fl, finfo);
else
@@ -1182,7 +1178,7 @@
if (GTK_CLIST (fl)->clist_window != event->window)
return FALSE;
- gint row = gnome_cmd_clist_get_row (GNOME_CMD_CLIST (fl), event->x, event->y);
+ gint row = gnome_cmd_clist_get_row (*fl, event->x, event->y);
if (row < 0)
return FALSE;
@@ -1314,17 +1310,17 @@
init_dnd (fl);
for (gint i=0; i<GnomeCmdFileList::NUM_COLUMNS; i++)
- gtk_clist_set_column_resizeable (GTK_CLIST (fl), i, TRUE);
+ gtk_clist_set_column_resizeable (*fl, i, TRUE);
- gtk_signal_connect_after (GTK_OBJECT (fl), "scroll-vertical", GTK_SIGNAL_FUNC (on_scroll_vertical), fl);
- gtk_signal_connect (GTK_OBJECT (fl), "click-column", GTK_SIGNAL_FUNC (on_column_clicked), fl);
+ gtk_signal_connect_after (*fl, "scroll-vertical", GTK_SIGNAL_FUNC (on_scroll_vertical), fl);
+ gtk_signal_connect (*fl, "click-column", GTK_SIGNAL_FUNC (on_column_clicked), fl);
- gtk_signal_connect (GTK_OBJECT (fl), "button-press-event", GTK_SIGNAL_FUNC (on_button_press), fl);
- gtk_signal_connect (GTK_OBJECT (fl), "button-release-event", GTK_SIGNAL_FUNC (on_button_release), fl);
- gtk_signal_connect (GTK_OBJECT (fl), "motion-notify-event", GTK_SIGNAL_FUNC (on_motion_notify), fl);
+ gtk_signal_connect (*fl, "button-press-event", GTK_SIGNAL_FUNC (on_button_press), fl);
+ gtk_signal_connect (*fl, "button-release-event", GTK_SIGNAL_FUNC (on_button_release), fl);
+ gtk_signal_connect (*fl, "motion-notify-event", GTK_SIGNAL_FUNC (on_motion_notify), fl);
gtk_signal_connect_after (GTK_OBJECT (fl), "realize", GTK_SIGNAL_FUNC (on_realize), fl);
- gtk_signal_connect (GTK_OBJECT (fl), "file-clicked", GTK_SIGNAL_FUNC (on_file_clicked), fl);
+ gtk_signal_connect (*fl, "file-clicked", GTK_SIGNAL_FUNC (on_file_clicked), fl);
}
@@ -1380,9 +1376,9 @@
void gnome_cmd_file_list_update_style (GnomeCmdFileList *fl)
{
- gtk_clist_set_row_height (GTK_CLIST (fl), gnome_cmd_data_get_list_row_height ());
+ gtk_clist_set_row_height (*fl, gnome_cmd_data_get_list_row_height ());
- gnome_cmd_clist_update_style (GNOME_CMD_CLIST (fl));
+ gnome_cmd_clist_update_style (*fl);
}
@@ -1478,10 +1474,10 @@
else
tmp = list;
- gtk_clist_freeze (GTK_CLIST (fl));
+ gtk_clist_freeze (*fl);
for (; tmp; tmp = tmp->next)
fl->append_file(GNOME_CMD_FILE (tmp->data));
- gtk_clist_thaw (GTK_CLIST (fl));
+ gtk_clist_thaw (*fl);
if (list)
g_list_free (list);
@@ -1524,7 +1520,7 @@
FileFormatData data(finfo, FALSE);
for (gint i=1; i<GnomeCmdFileList::NUM_COLUMNS; i++)
- gtk_clist_set_text (GTK_CLIST (fl), row, i, data.text[i]);
+ gtk_clist_set_text (*fl, row, i, data.text[i]);
}
@@ -1540,7 +1536,7 @@
FileFormatData data(finfo,TRUE);
for (gint i=1; i<GnomeCmdFileList::NUM_COLUMNS; i++)
- gtk_clist_set_text (GTK_CLIST (fl), row, i, data.text[i]);
+ gtk_clist_set_text (*fl, row, i, data.text[i]);
}
@@ -1759,28 +1755,24 @@
}
-void gnome_cmd_file_list_toggle (GnomeCmdFileList *fl)
+void GnomeCmdFileList::toggle()
{
- g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
+ GnomeCmdFile *f = get_file_at_row (this, priv->cur_file);
- GnomeCmdFile *finfo = get_file_at_row (fl, fl->priv->cur_file);
-
- if (finfo)
- toggle_file (fl, finfo);
+ if (f)
+ toggle_file (this, f);
}
-void gnome_cmd_file_list_toggle_and_step (GnomeCmdFileList *fl)
+void GnomeCmdFileList::toggle_and_step()
{
- g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
+ GnomeCmdFile *f = get_file_at_row (this, priv->cur_file);
- GnomeCmdFile *finfo = get_file_at_row (fl, fl->priv->cur_file);
-
- if (finfo)
- toggle_file (fl, finfo);
- if (fl->priv->cur_file < fl->size()-1)
- focus_file_at_row (fl, fl->priv->cur_file+1);
+ if (f)
+ toggle_file (this, f);
+ if (priv->cur_file < size()-1)
+ focus_file_at_row (this, priv->cur_file+1);
}
@@ -1804,7 +1796,7 @@
fl->priv->cur_file = row;
focus_file_at_row (fl, row);
if (scroll_to_file)
- gtk_clist_moveto (GTK_CLIST (fl), row, 0, 0, 0);
+ gtk_clist_moveto (*fl, row, 0, 0, 0);
return;
}
}
@@ -1816,9 +1808,9 @@
}
-void gnome_cmd_file_list_select_row (GnomeCmdFileList *fl, gint row)
+void GnomeCmdFileList::select_row(gint row)
{
- focus_file_at_row (fl, row == -1 ? fl->priv->cur_file : row);
+ focus_file_at_row (this, row==-1 ? priv->cur_file : row);
}
@@ -1940,7 +1932,7 @@
if (selfile && GTK_WIDGET_HAS_FOCUS (this))
{
gint selrow = get_row_from_file (this, selfile);
- gnome_cmd_file_list_select_row (this, selrow);
+ select_row(selrow);
gtk_clist_moveto (GTK_CLIST (this), selrow, -1, 1, 0);
}
@@ -2140,7 +2132,7 @@
if (fl->priv->quicksearch_popup)
return;
- gtk_clist_unselect_all (GTK_CLIST (fl));
+ gtk_clist_unselect_all (*fl);
fl->priv->quicksearch_popup = gnome_cmd_quicksearch_popup_new (fl);
text[0] = c;
@@ -2303,7 +2295,7 @@
case GDK_Insert:
case GDK_KP_Insert:
- gnome_cmd_file_list_toggle (this);
+ toggle();
gtk_signal_emit_by_name (GTK_OBJECT (this), "scroll-vertical", GTK_SCROLL_STEP_FORWARD, 0.0, NULL);
return TRUE;
Modified: trunk/src/gnome-cmd-file-list.h
==============================================================================
--- trunk/src/gnome-cmd-file-list.h (original)
+++ trunk/src/gnome-cmd-file-list.h Wed Aug 27 20:52:48 2008
@@ -54,6 +54,10 @@
Private *priv;
+ operator GtkObject * () { return GTK_OBJECT (this); }
+ operator GtkCList * () { return GTK_CLIST (this); }
+ operator GnomeCmdCList * () { return GNOME_CMD_CLIST (this); }
+
enum ColumnID
{
COLUMN_ICON,
@@ -69,7 +73,9 @@
};
int size();
- bool empty() { return size()==0; }
+ bool empty();
+ // int size() { return g_list_length (all_files()); }
+ // bool empty() { return all_files()==NULL; } // FIXME should be: size()==0
void clear();
void append_file(GnomeCmdFile *f);
@@ -77,11 +83,16 @@
void remove_file(GnomeCmdFile *f);
void remove_file(const gchar *uri_str);
void remove_files(GList *files);
- void remove_all_files() { clear(); }
+ void remove_all_files() { clear(); }
void select_all();
void unselect_all();
+ void select_row(gint row);
+
+ void toggle();
+ void toggle_and_step();
+
void sort();
GList *sort_selection(GList *list);
@@ -131,21 +142,21 @@
GList *gnome_cmd_file_list_get_selected_files (GnomeCmdFileList *fl);
GList *gnome_cmd_file_list_get_marked_files (GnomeCmdFileList *fl);
-inline int GnomeCmdFileList::size()
-{
- return g_list_length (gnome_cmd_file_list_get_all_files (this));
-}
-
GnomeCmdFile *gnome_cmd_file_list_get_focused_file (GnomeCmdFileList *fl);
GnomeCmdFile *gnome_cmd_file_list_get_selected_file (GnomeCmdFileList *fl);
GnomeCmdFile *gnome_cmd_file_list_get_first_selected_file (GnomeCmdFileList *fl);
-void gnome_cmd_file_list_toggle (GnomeCmdFileList *fl);
-void gnome_cmd_file_list_toggle_and_step (GnomeCmdFileList *fl);
-
void gnome_cmd_file_list_focus_file (GnomeCmdFileList *fl, const gchar *focus_file, gboolean scroll_to_file);
-void gnome_cmd_file_list_select_row (GnomeCmdFileList *fl, gint row);
+inline int GnomeCmdFileList::size()
+{
+ return g_list_length (gnome_cmd_file_list_get_all_files (this));
+}
+
+inline bool GnomeCmdFileList::empty()
+{
+ return gnome_cmd_file_list_get_all_files (this)==NULL;
+}
void gnome_cmd_file_list_select_pattern (GnomeCmdFileList *fl, const gchar *pattern, gboolean case_sens);
void gnome_cmd_file_list_unselect_pattern (GnomeCmdFileList *fl, const gchar *pattern, gboolean case_sens);
@@ -157,7 +168,6 @@
void gnome_cmd_file_list_compare_directories (GnomeCmdFileList *fl1, GnomeCmdFileList *fl2);
GnomeCmdFile *gnome_cmd_file_list_get_file_at_row (GnomeCmdFileList *fl, gint row);
-
gint gnome_cmd_file_list_get_row_from_file (GnomeCmdFileList *fl, GnomeCmdFile *finfo);
void gnome_cmd_file_list_show_advrename_dialog (GnomeCmdFileList *fl);
Modified: trunk/src/gnome-cmd-file-selector.cc
==============================================================================
--- trunk/src/gnome-cmd-file-selector.cc (original)
+++ trunk/src/gnome-cmd-file-selector.cc Wed Aug 27 20:52:48 2008
@@ -374,7 +374,7 @@
if (fs->priv->realized)
update_selected_files_label (fs);
if (fs->priv->active)
- gnome_cmd_file_list_select_row (fs->file_list(), 0);
+ fs->file_list()->select_row(0);
if (list2)
g_list_free (list2);
@@ -1588,7 +1588,7 @@
if (value)
{
gtk_widget_grab_focus (list_widget);
- gnome_cmd_file_list_select_row (list, GTK_CLIST (list)->focus_row);
+ list->select_row(GTK_CLIST (list)->focus_row);
}
else
gtk_clist_unselect_all (GTK_CLIST (list));
@@ -2020,7 +2020,7 @@
{
case GDK_space:
set_cursor_busy ();
- gnome_cmd_file_list_toggle (fs->file_list());
+ fs->file_list()->toggle();
show_selected_dir_tree_size (fs);
stop_kp (GTK_OBJECT (fs->file_list()));
update_selected_files_label (fs);
Modified: trunk/src/gnome-cmd-quicksearch-popup.cc
==============================================================================
--- trunk/src/gnome-cmd-quicksearch-popup.cc (original)
+++ trunk/src/gnome-cmd-quicksearch-popup.cc Wed Aug 27 20:52:48 2008
@@ -137,7 +137,7 @@
{
case GDK_Escape:
case GDK_Return:
- gnome_cmd_file_list_select_row (popup->priv->fl, GNOME_CMD_CLIST (popup->priv->fl)->drag_motion_row);
+ popup->priv->fl->select_row(GNOME_CMD_CLIST (popup->priv->fl)->drag_motion_row);
hide_popup (popup);
return TRUE;
@@ -147,7 +147,7 @@
case GDK_F5:
case GDK_F6:
case GDK_F8:
- gnome_cmd_file_list_select_row (popup->priv->fl, GNOME_CMD_CLIST (popup->priv->fl)->drag_motion_row);
+ popup->priv->fl->select_row(GNOME_CMD_CLIST (popup->priv->fl)->drag_motion_row);
hide_popup (popup);
gnome_cmd_main_win_keypressed (main_win, event);
return TRUE;
Modified: trunk/src/gnome-cmd-user-actions.cc
==============================================================================
--- trunk/src/gnome-cmd-user-actions.cc (original)
+++ trunk/src/gnome-cmd-user-actions.cc Wed Aug 27 20:52:48 2008
@@ -1110,13 +1110,13 @@
/************** Mark Menu **************/
void mark_toggle (GtkMenuItem *menuitem, gpointer not_used)
{
- gnome_cmd_file_list_toggle (get_fl (ACTIVE));
+ get_fl (ACTIVE)->toggle();
}
void mark_toggle_and_step (GtkMenuItem *menuitem, gpointer not_used)
{
- gnome_cmd_file_list_toggle_and_step (get_fl (ACTIVE));
+ get_fl (ACTIVE)->toggle_and_step();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]