gnome-commander r1736 - in trunk/src: . intviewer
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r1736 - in trunk/src: . intviewer
- Date: Tue, 29 Apr 2008 21:27:12 +0100 (BST)
Author: epiotr
Date: Tue Apr 29 20:27:12 2008
New Revision: 1736
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=1736&view=rev
Log:
Code cleanup
Modified:
trunk/src/gnome-cmd-advrename-dialog.cc
trunk/src/gnome-cmd-file-list.cc
trunk/src/gnome-cmd-main-win.cc
trunk/src/gnome-cmd-search-dialog.cc
trunk/src/intviewer/searcher.cc
trunk/src/intviewer/text-render.cc
Modified: trunk/src/gnome-cmd-advrename-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-advrename-dialog.cc (original)
+++ trunk/src/gnome-cmd-advrename-dialog.cc Tue Apr 29 20:27:12 2008
@@ -82,16 +82,16 @@
inline void insert_tag (GnomeCmdAdvrenameDialog *dialog, const gchar *text)
{
GtkEditable *editable = (GtkEditable *) dialog->priv->templ_entry;
- gint pos = gtk_editable_get_position(editable);
+ gint pos = gtk_editable_get_position (editable);
gtk_editable_insert_text (editable, text, strlen(text), &pos);
- gtk_editable_set_position(editable, pos);
- gtk_widget_grab_focus((GtkWidget *) editable);
- gtk_editable_select_region(editable,pos,pos);
+ gtk_editable_set_position (editable, pos);
+ gtk_widget_grab_focus ((GtkWidget *) editable);
+ gtk_editable_select_region (editable,pos,pos);
}
-static void insert_text_tag(gpointer data, guint n, GtkWidget *widget)
+static void insert_text_tag (gpointer data, guint n, GtkWidget *widget)
{
static const gchar *placeholder[] = {"$g",
"$p",
@@ -123,14 +123,14 @@
g_return_if_fail (n < G_N_ELEMENTS(placeholder));
- insert_tag((GnomeCmdAdvrenameDialog *) data, placeholder[n]);
+ insert_tag ((GnomeCmdAdvrenameDialog *) data, placeholder[n]);
}
static void insert_num_tag(gpointer data, guint tag, GtkWidget *widget)
{
gchar *s = g_strdup_printf ("$T(%s)", gcmd_tags_get_name((GnomeCmdTag) tag));
- insert_tag((GnomeCmdAdvrenameDialog *) data, s);
+ insert_tag ((GnomeCmdAdvrenameDialog *) data, s);
g_free(s);
}
@@ -141,10 +141,10 @@
GdkEventButton *event = (GdkEventButton *) gtk_get_current_event();
if (event == NULL)
- gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
else
if (event->button == 1)
- gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
}
@@ -434,11 +434,11 @@
GtkWidget *label = gtk_label_new (label_text);
GtkWidget *hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), arrow, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
- GtkWidget *button = gtk_button_new();
- gtk_container_add (GTK_CONTAINER(button), hbox);
+ GtkWidget *button = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), hbox);
dialog->priv->menu[menu_type] = create_placeholder_menu (dialog, menu_type);
@@ -554,7 +554,7 @@
format_entry (entry, text);
row = gtk_clist_append (GTK_CLIST (dialog->priv->pat_list), text);
- //gtk_clist_set_foreground(GTK_CLIST (dialog->priv->pat_list), row, entry->malformed_pattern ? &red : &black);
+ //gtk_clist_set_foreground (GTK_CLIST (dialog->priv->pat_list), row, entry->malformed_pattern ? &red : &black);
gtk_clist_set_row_data (GTK_CLIST (dialog->priv->pat_list), row, entry);
update_move_buttons (dialog, GTK_CLIST (dialog->priv->pat_list)->focus_row);
}
@@ -616,7 +616,7 @@
gchar *text[4];
format_entry (entry, text);
- //gtk_clist_set_foreground(GTK_CLIST (pat_list), row, entry->malformed_pattern ? &red : &black);
+ //gtk_clist_set_foreground (GTK_CLIST (pat_list), row, entry->malformed_pattern ? &red : &black);
gtk_clist_set_text (GTK_CLIST (pat_list), row, 0, text[0]);
gtk_clist_set_text (GTK_CLIST (pat_list), row, 1, text[1]);
gtk_clist_set_text (GTK_CLIST (pat_list), row, 2, text[2]);
@@ -909,7 +909,7 @@
static void on_help (GtkButton *button, GnomeCmdAdvrenameDialog *dialog)
{
- gnome_cmd_help_display("gnome-commander.xml", "gnome-commander-advanced-rename");
+ gnome_cmd_help_display ("gnome-commander.xml", "gnome-commander-advanced-rename");
}
Modified: trunk/src/gnome-cmd-file-list.cc
==============================================================================
--- trunk/src/gnome-cmd-file-list.cc (original)
+++ trunk/src/gnome-cmd-file-list.cc Tue Apr 29 20:27:12 2008
@@ -201,7 +201,7 @@
gint x0, y0;
- gdk_window_get_origin (GTK_CLIST(fl)->clist_window, &x0, &y0);
+ gdk_window_get_origin (GTK_CLIST (fl)->clist_window, &x0, &y0);
gint row = GTK_CLIST (fl)->focus_row;
gint rowh = GTK_CLIST (fl)->row_height + CELL_SPACING;
@@ -445,8 +445,6 @@
static void create_column_titles (GnomeCmdFileList *fl)
{
- gtk_clist_set_column_width (GTK_CLIST (fl), 0, gnome_cmd_data_get_fs_col_width (FILE_LIST_COLUMN_ICON));
- gtk_clist_set_column_justification (GTK_CLIST (fl), 0, file_list_column[FILE_LIST_COLUMN_ICON].justification);
gtk_clist_column_title_passive (GTK_CLIST (fl), FILE_LIST_COLUMN_ICON);
for (gint i=FILE_LIST_COLUMN_NAME; i<FILE_LIST_NUM_COLUMNS; i++)
@@ -478,7 +476,7 @@
gtk_clist_set_column_widget (GTK_CLIST (fl), i, hbox);
}
- for (gint i=FILE_LIST_COLUMN_NAME; i<FILE_LIST_NUM_COLUMNS; i++)
+ for (gint i=FILE_LIST_COLUMN_ICON; i<FILE_LIST_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);
@@ -637,7 +635,7 @@
static void popup_position_function (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
{
- GnomeCmdFileList *fl = GNOME_CMD_FILE_LIST(user_data);
+ GnomeCmdFileList *fl = GNOME_CMD_FILE_LIST (user_data);
gint w, h;
@@ -658,7 +656,7 @@
}
-static void show_file_popup_with_warp (GnomeCmdFileList *fl)
+inline void show_file_popup_with_warp (GnomeCmdFileList *fl)
{
gint x, y, w, h;
@@ -757,7 +755,7 @@
gboolean raising = fl->priv->sort_raising[fl->priv->current_col];
- if (!gnome_cmd_file_get_extension(f1) && !gnome_cmd_file_get_extension (f2))
+ if (!gnome_cmd_file_get_extension (f1) && !gnome_cmd_file_get_extension (f2))
return my_strcmp (gnome_cmd_get_collation_fname (f1), gnome_cmd_get_collation_fname (f2), fl->priv->sort_raising[1]);
if (!gnome_cmd_file_get_extension (f1))
@@ -1065,7 +1063,7 @@
if (event->button == 3)
if (strcmp (finfo->info->name, "..") != 0)
{
- if (gnome_cmd_data_get_right_mouse_button_mode() == RIGHT_BUTTON_SELECTS)
+ if (gnome_cmd_data_get_right_mouse_button_mode () == RIGHT_BUTTON_SELECTS)
{
if (g_list_index (fl->priv->selected_files, finfo) == -1)
{
@@ -1305,7 +1303,7 @@
GtkWidget *gnome_cmd_file_list_new ()
{
- GnomeCmdFileList *fl = (GnomeCmdFileList *) g_object_new (gnome_cmd_file_list_get_type(), "n-columns", FILE_LIST_NUM_COLUMNS, NULL);
+ GnomeCmdFileList *fl = (GnomeCmdFileList *) g_object_new (gnome_cmd_file_list_get_type (), "n-columns", FILE_LIST_NUM_COLUMNS, NULL);
create_column_titles (fl);
@@ -1360,7 +1358,7 @@
g_free (t1);
g_free (t2);
- if (gnome_cmd_data_get_ext_disp_mode() == GNOME_CMD_EXT_DISP_STRIPPED
+ if (gnome_cmd_data_get_ext_disp_mode () == GNOME_CMD_EXT_DISP_STRIPPED
&& finfo->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
{
gchar *t = strip_extension (gnome_cmd_file_get_name (finfo));
@@ -1370,7 +1368,7 @@
else
data.fname = get_utf8 (gnome_cmd_file_get_name (finfo));
- if (gnome_cmd_data_get_ext_disp_mode() != GNOME_CMD_EXT_DISP_WITH_FNAME)
+ if (gnome_cmd_data_get_ext_disp_mode () != GNOME_CMD_EXT_DISP_WITH_FNAME)
data.fext = get_utf8 (gnome_cmd_file_get_extension (finfo));
else
data.fext = NULL;
@@ -1580,7 +1578,7 @@
fl->priv->selected_files = g_list_remove (fl->priv->selected_files, finfo);
gnome_cmd_file_collection_remove (fl->priv->shown_files, finfo);
- focus_file_at_row (fl, MIN (row, GTK_CLIST(fl)->focus_row));
+ focus_file_at_row (fl, MIN (row, GTK_CLIST (fl)->focus_row));
}
}
@@ -1906,7 +1904,7 @@
static gint compare_filename (GnomeCmdFile *f1, GnomeCmdFile *f2)
{
- return strcmp(f1->info->name, f2->info->name);
+ return strcmp (f1->info->name, f2->info->name);
}
@@ -1922,7 +1920,7 @@
gnome_cmd_file_list_unselect_all (fl1);
gnome_cmd_file_list_select_all (fl2);
- for (GList *i=gnome_cmd_file_list_get_all_files(fl1); i; i=i->next)
+ for (GList *i=gnome_cmd_file_list_get_all_files (fl1); i; i=i->next)
{
GnomeCmdFile *f1 = (GnomeCmdFile *) i->data;
GnomeCmdFile *f2;
@@ -2163,9 +2161,9 @@
gboolean gnome_cmd_file_list_quicksearch_shown (GnomeCmdFileList *fl)
{
- g_return_val_if_fail(fl!=NULL,FALSE);
- g_return_val_if_fail(GNOME_CMD_IS_FILE_LIST(fl),FALSE);
- g_return_val_if_fail(fl->priv!=NULL,FALSE);
+ g_return_val_if_fail (fl!=NULL,FALSE);
+ g_return_val_if_fail (GNOME_CMD_IS_FILE_LIST (fl),FALSE);
+ g_return_val_if_fail (fl->priv!=NULL,FALSE);
return fl->priv->quicksearch_popup!=NULL;
}
Modified: trunk/src/gnome-cmd-main-win.cc
==============================================================================
--- trunk/src/gnome-cmd-main-win.cc (original)
+++ trunk/src/gnome-cmd-main-win.cc Tue Apr 29 20:27:12 2008
@@ -123,8 +123,8 @@
gint gnome_cmd_key_snooper(GtkWidget *grab_widget, GdkEventKey *event, GnomeCmdMainWin *mw)
{
- g_return_val_if_fail(mw!=NULL, FALSE);
- g_return_val_if_fail(mw->priv!=NULL,FALSE);
+ g_return_val_if_fail (mw!=NULL, FALSE);
+ g_return_val_if_fail (mw->priv!=NULL,FALSE);
if (event->type!=GDK_KEY_PRESS)
return FALSE;
@@ -144,13 +144,13 @@
if (fs==NULL || fs->list==NULL)
return FALSE;
- if (!GTK_WIDGET_HAS_FOCUS(GTK_WIDGET(fs->list)))
+ if (!GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (fs->list)))
return FALSE;
- if (gnome_cmd_file_list_quicksearch_shown(fs->list))
+ if (gnome_cmd_file_list_quicksearch_shown (fs->list))
return FALSE;
- gnome_cmd_file_list_show_quicksearch(fs->list, event->keyval);
+ gnome_cmd_file_list_show_quicksearch (fs->list, event->keyval);
return TRUE;
}
@@ -528,7 +528,7 @@
static void on_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
{
- switch(gnome_cmd_data_get_main_win_state())
+ switch (gnome_cmd_data_get_main_win_state())
{
case GDK_WINDOW_STATE_FULLSCREEN:
case GDK_WINDOW_STATE_ICONIFIED:
Modified: trunk/src/gnome-cmd-search-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-search-dialog.cc (original)
+++ trunk/src/gnome-cmd-search-dialog.cc Tue Apr 29 20:27:12 2008
@@ -51,8 +51,8 @@
struct SearchData
{
const gchar *name_pattern; // the pattern that filenames should match to end up in the file-list
- const gchar *content_pattern; // the pattern that the content of a file should match to end up in the file-list.
- const gchar *dir; // the current dir of the search routine.
+ const gchar *content_pattern; // the pattern that the content of a file should match to end up in the file-list
+ const gchar *dir; // the current dir of the search routine
Filter *name_filter;
regex_t *content_regex;
@@ -120,12 +120,10 @@
* Puts a string in the statusbar.
*
*/
-static void set_statusmsg (SearchData *data, gchar *msg)
+inline void set_statusmsg (SearchData *data, gchar *msg)
{
- if (!msg) return;
-
- gtk_statusbar_push (GTK_STATUSBAR (data->dialog->priv->statusbar),
- data->context_id, msg);
+ if (msg)
+ gtk_statusbar_push (GTK_STATUSBAR (data->dialog->priv->statusbar), data->context_id, msg);
}
/**
@@ -133,11 +131,11 @@
*/
inline void search_file_data_free (SearchFileData *searchfile_data)
{
- if (searchfile_data->handle != NULL)
- gnome_vfs_close (searchfile_data->handle);
+ if (searchfile_data->handle != NULL)
+ gnome_vfs_close (searchfile_data->handle);
- g_free (searchfile_data->uri_str);
- g_free (searchfile_data);
+ g_free (searchfile_data->uri_str);
+ g_free (searchfile_data);
}
/**
@@ -254,15 +252,15 @@
*/
static void search_dir_r (GnomeCmdDir *dir, SearchData *data)
{
- GList *tmp, *files;
- gchar *path;
+ if (!dir)
+ return;
// update the search status data
if (!data->dialog_destroyed)
{
g_mutex_lock (data->pdata.mutex);
- path = gnome_cmd_file_get_path (GNOME_CMD_FILE (dir));
+ gchar *path = gnome_cmd_file_get_path (GNOME_CMD_FILE (dir));
g_free (data->pdata.msg);
data->pdata.msg = g_strdup_printf (_("Searching in: %s"), path);
g_free (path);
@@ -275,32 +273,28 @@
if (data->stopped)
return;
- if (!dir)
- return;
+ GList *files;
gnome_cmd_dir_list_files (dir, FALSE);
gnome_cmd_dir_get_files (dir, &files);
- tmp = files;
- if (!tmp)
- return;
// Let's iterate through all files
- while (tmp)
+ for (GList *tmp=files; tmp; tmp=tmp->next)
{
- GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
-
// If the stop button was pressed let's abort here
if (data->stopped)
return;
+ GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
+
// If the current file is a directory lets continue our recursion
if (GNOME_CMD_IS_DIR (finfo) && data->recurse)
{
// we don't want to go backwards or follow symlinks
- if (strcmp (finfo->info->name, ".") != 0
- && strcmp (finfo->info->name, "..") != 0
- && !GNOME_VFS_FILE_INFO_SYMLINK(finfo->info))
+ if (strcmp (finfo->info->name, ".") != 0 &&
+ strcmp (finfo->info->name, "..") != 0 &&
+ !GNOME_VFS_FILE_INFO_SYMLINK (finfo->info))
{
GnomeCmdDir *new_dir = GNOME_CMD_DIR (finfo);
@@ -310,43 +304,35 @@
search_dir_r (new_dir, data);
gnome_cmd_dir_unref (new_dir);
}
-
- // If the stop button was pressed let's abort here
- if (data->stopped)
- return;
}
}
// if the file is a regular one it might match the search criteria
- else if (finfo->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
- {
- // if the name doesn't match lets go to the next file
- if (!name_matches (finfo->info->name, data))
- goto next;
-
- // if the user wants to we should do some content matching here
- if (data->content_search)
+ else
+ if (finfo->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
{
- if (!content_matches (finfo, data))
- goto next;
- }
+ // if the name doesn't match lets go to the next file
+ if (!name_matches (finfo->info->name, data))
+ continue;
+
+ // if the user wants to we should do some content matching here
+ if (data->content_search && !content_matches (finfo, data))
+ continue;
+
+ // the file matched the search criteria, lets add it to the list
+ g_mutex_lock (data->pdata.mutex);
+ data->pdata.files = g_list_append (data->pdata.files, finfo);
+ g_mutex_unlock (data->pdata.mutex);
- // the file matched the search criteria, lets add it to the list
- g_mutex_lock (data->pdata.mutex);
- data->pdata.files = g_list_append (data->pdata.files, finfo);
- g_mutex_unlock (data->pdata.mutex);
+ // also ref each directory that has a matching file
+ if (g_list_index (data->match_dirs, dir) == -1)
+ {
+ gnome_cmd_dir_ref (dir);
+ data->match_dirs = g_list_append (data->match_dirs, dir);
+ }
- // also ref each directory that has a matching file
- if (g_list_index (data->match_dirs, dir) == -1)
- {
- gnome_cmd_dir_ref (dir);
- data->match_dirs = g_list_append (data->match_dirs, dir);
+ // count the match
+ data->matches++;
}
-
- // count the match
- data->matches++;
- }
- next:
- tmp = tmp->next;
}
}
@@ -506,9 +492,7 @@
static gboolean start_search (GnomeCmdSearchDialog *dialog)
{
- GnomeCmdPath *path;
SearchData *data = dialog->priv->data;
- SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
if (data->thread)
{
@@ -531,6 +515,8 @@
data->case_sens = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_check));
// Save default settings
+ SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
+
defaults->case_sens = data->case_sens;
defaults->recursive = data->recurse;
defaults->name_patterns = string_history_add (defaults->name_patterns, data->name_pattern, PATTERN_HISTORY_SIZE);
@@ -554,10 +540,10 @@
}
if (dialog->priv->data->search_mem == NULL)
- dialog->priv->data->search_mem = (gchar *) g_malloc(SEARCH_BUFFER_SIZE);
+ dialog->priv->data->search_mem = (gchar *) g_malloc (SEARCH_BUFFER_SIZE);
// start the search
- path = gnome_cmd_con_create_path (dialog->priv->con, data->dir);
+ GnomeCmdPath *path = gnome_cmd_con_create_path (dialog->priv->con, data->dir);
data->start_dir = gnome_cmd_dir_new (dialog->priv->con, path);
gnome_cmd_dir_ref (data->start_dir);
@@ -566,7 +552,7 @@
if (data->pdata.mutex == NULL)
data->pdata.mutex = g_mutex_new ();
- data->thread = g_thread_create ((GThreadFunc)perform_search_operation, data, TRUE, NULL);
+ data->thread = g_thread_create ((GThreadFunc) perform_search_operation, data, TRUE, NULL);
gtk_widget_show (data->dialog->priv->pbar);
data->update_gui_timeout_id = gtk_timeout_add (gnome_cmd_data_get_gui_update_rate (),
@@ -706,11 +692,8 @@
{
GnomeCmdSearchDialog *dialog = GNOME_CMD_SEARCH_DIALOG (object);
- if (dialog->priv != NULL)
- {
- g_free (dialog->priv);
- dialog->priv = NULL;
- }
+ g_free (dialog->priv);
+ dialog->priv = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -742,15 +725,13 @@
*/
inline GtkWidget *create_label_with_mnemonic (GtkWidget *parent, const gchar *text, GtkWidget *for_widget)
{
- GtkWidget *label;
+ GtkWidget *label = gtk_label_new_with_mnemonic (text);
- label = gtk_label_new_with_mnemonic (text);
if (for_widget != NULL)
gtk_label_set_mnemonic_widget (GTK_LABEL (label), for_widget);
gtk_widget_ref (label);
- gtk_object_set_data_full (GTK_OBJECT (parent), "label", label,
- (GtkDestroyNotify) gtk_widget_unref);
+ gtk_object_set_data_full (GTK_OBJECT (parent), "label", label, (GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (label);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
@@ -779,8 +760,7 @@
{
GtkWidget *combo = gtk_combo_box_entry_new_text ();
gtk_widget_ref (combo);
- gtk_object_set_data_full (GTK_OBJECT (parent), "combo", combo,
- (GtkDestroyNotify) gtk_widget_unref);
+ gtk_object_set_data_full (GTK_OBJECT (parent), "combo", combo, (GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (combo);
return combo;
}
Modified: trunk/src/intviewer/searcher.cc
==============================================================================
--- trunk/src/intviewer/searcher.cc (original)
+++ trunk/src/intviewer/searcher.cc Tue Apr 29 20:27:12 2008
@@ -87,7 +87,7 @@
{
static GType type = 0;
- if(type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info = {
sizeof (GViewerSearcherClass),
Modified: trunk/src/intviewer/text-render.cc
==============================================================================
--- trunk/src/intviewer/text-render.cc (original)
+++ trunk/src/intviewer/text-render.cc Tue Apr 29 20:27:12 2008
@@ -428,7 +428,7 @@
if (!obj->priv->dp)
return FALSE;
- switch(event->keyval)
+ switch (event->keyval)
{
case GDK_Up:
obj->priv->current_offset =
@@ -619,7 +619,7 @@
return FALSE;
// Mouse scroll wheel
- switch(event->direction)
+ switch (event->direction)
{
case GDK_SCROLL_UP:
w->priv->current_offset = gv_scroll_lines(w->priv->dp, w->priv->current_offset, -4);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]