Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sat, 04 Aug 2012 15:08:40 Commit: f145c138f775c8e9a949ad13107a8a22f3b7b037 https://github.com/geany/geany-plugins/commit/f145c138f775c8e9a949ad13107a8a...
Log Message: ----------- commander: Reorder a few functions for better readability
Modified Paths: -------------- commander/src/commander-plugin.c
Modified: commander/src/commander-plugin.c 192 files changed, 96 insertions(+), 96 deletions(-) =================================================================== @@ -154,30 +154,6 @@ enum { return key; }
-static gint -sort_func (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer dummy) -{ - gint dista; - gint distb; - gchar *patha; - gchar *pathb; - const gchar *key = get_key (NULL); - - gtk_tree_model_get (model, a, COL_PATH, &patha, -1); - gtk_tree_model_get (model, b, COL_PATH, &pathb, -1); - - dista = key_dist (key, patha); - distb = key_dist (key, pathb); - - g_free (patha); - g_free (pathb); - - return dista - distb; -} - static void tree_view_set_active_cell (GtkTreeView *view, GtkTreeIter *iter) @@ -248,78 +224,6 @@ enum { } }
-static gboolean -on_panel_key_press_event (GtkWidget *widget, - GdkEventKey *event, - gpointer dummy) -{ - switch (event->keyval) { - case GDK_KEY_Escape: - gtk_widget_hide (widget); - return TRUE; - - case GDK_KEY_Tab: - /* avoid leaving the entry */ - return TRUE; - - case GDK_KEY_Return: - case GDK_KEY_KP_Enter: - case GDK_KEY_ISO_Enter: { - GtkTreeIter iter; - GtkTreeView *view = GTK_TREE_VIEW (plugin_data.view); - GtkTreeSelection *selection = gtk_tree_view_get_selection (view); - GtkTreeModel *model; - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - GtkTreePath *path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_row_activated (view, path, NULL); - gtk_tree_path_free (path); - } - - return TRUE; - } - - case GDK_KEY_Page_Up: - case GDK_KEY_Page_Down: - tree_view_move_focus (GTK_TREE_VIEW (plugin_data.view), - GTK_MOVEMENT_PAGES, - event->keyval == GDK_KEY_Page_Up ? -1 : 1); - return TRUE; - - case GDK_KEY_Up: - case GDK_KEY_Down: { - tree_view_move_focus (GTK_TREE_VIEW (plugin_data.view), - GTK_MOVEMENT_DISPLAY_LINES, - event->keyval == GDK_KEY_Up ? -1 : 1); - return TRUE; - } - } - - return FALSE; -} - -static void -on_entry_text_notify (GObject *object, - GParamSpec *pspec, - gpointer dummy) -{ - GtkTreeIter iter; - GtkTreeView *view = GTK_TREE_VIEW (plugin_data.view); - GtkTreeModel *model = gtk_tree_view_get_model (view); - - /* we force re-sorting the whole model from how it was before, and the - * back to the new filter. this is somewhat hackish but since we don't - * know the original sorting order, and GtkTreeSortable don't have a - * resort() API anyway. */ - gtk_tree_model_sort_reset_default_sort_func (GTK_TREE_MODEL_SORT (model)); - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model), - sort_func, NULL, NULL); - - if (gtk_tree_model_get_iter_first (model, &iter)) { - tree_view_set_active_cell (view, &iter); - } -} - static void store_populate_menu_items (GtkListStore *store, GtkMenuShell *menu, @@ -457,6 +361,102 @@ enum { } }
+static gint +sort_func (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer dummy) +{ + gint dista; + gint distb; + gchar *patha; + gchar *pathb; + const gchar *key = get_key (NULL); + + gtk_tree_model_get (model, a, COL_PATH, &patha, -1); + gtk_tree_model_get (model, b, COL_PATH, &pathb, -1); + + dista = key_dist (key, patha); + distb = key_dist (key, pathb); + + g_free (patha); + g_free (pathb); + + return dista - distb; +} + +static gboolean +on_panel_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer dummy) +{ + switch (event->keyval) { + case GDK_KEY_Escape: + gtk_widget_hide (widget); + return TRUE; + + case GDK_KEY_Tab: + /* avoid leaving the entry */ + return TRUE; + + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: + case GDK_KEY_ISO_Enter: { + GtkTreeIter iter; + GtkTreeView *view = GTK_TREE_VIEW (plugin_data.view); + GtkTreeSelection *selection = gtk_tree_view_get_selection (view); + GtkTreeModel *model; + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { + GtkTreePath *path = gtk_tree_model_get_path (model, &iter); + gtk_tree_view_row_activated (view, path, NULL); + gtk_tree_path_free (path); + } + + return TRUE; + } + + case GDK_KEY_Page_Up: + case GDK_KEY_Page_Down: + tree_view_move_focus (GTK_TREE_VIEW (plugin_data.view), + GTK_MOVEMENT_PAGES, + event->keyval == GDK_KEY_Page_Up ? -1 : 1); + return TRUE; + + case GDK_KEY_Up: + case GDK_KEY_Down: { + tree_view_move_focus (GTK_TREE_VIEW (plugin_data.view), + GTK_MOVEMENT_DISPLAY_LINES, + event->keyval == GDK_KEY_Up ? -1 : 1); + return TRUE; + } + } + + return FALSE; +} + +static void +on_entry_text_notify (GObject *object, + GParamSpec *pspec, + gpointer dummy) +{ + GtkTreeIter iter; + GtkTreeView *view = GTK_TREE_VIEW (plugin_data.view); + GtkTreeModel *model = gtk_tree_view_get_model (view); + + /* we force re-sorting the whole model from how it was before, and the + * back to the new filter. this is somewhat hackish but since we don't + * know the original sorting order, and GtkTreeSortable don't have a + * resort() API anyway. */ + gtk_tree_model_sort_reset_default_sort_func (GTK_TREE_MODEL_SORT (model)); + gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model), + sort_func, NULL, NULL); + + if (gtk_tree_model_get_iter_first (model, &iter)) { + tree_view_set_active_cell (view, &iter); + } +} + static void on_panel_hide (GtkWidget *widget, gpointer dummy)
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).