Yasumichi Akahoshi
yasum****@users*****
2005年 5月 16日 (月) 21:22:27 JST
Index: cxplorer/src/cxp-right-pane.c diff -u cxplorer/src/cxp-right-pane.c:1.48 cxplorer/src/cxp-right-pane.c:1.49 --- cxplorer/src/cxp-right-pane.c:1.48 Mon May 16 01:00:43 2005 +++ cxplorer/src/cxp-right-pane.c Mon May 16 21:22:27 2005 @@ -5,6 +5,7 @@ #endif #include <glib/gi18n.h> +#include <gdk/gdkkeysyms.h> #include <gconf/gconf-client.h> #include <errno.h> #include <fcntl.h> @@ -73,6 +74,7 @@ enum { DIR_DOUBLE_CLICKED_SIGNAL, + UP_DIR_REQUEST_SIGNAL, LAST_SIGNAL }; @@ -98,6 +100,7 @@ GtkTreePath * path, GtkTreeViewColumn * column, gpointer user_data); +static void cxp_right_pane_on_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data); static void cxp_right_pane_draw_icon (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell, GtkTreeModel * tree_model, @@ -182,6 +185,15 @@ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + cxp_right_pane_signals[UP_DIR_REQUEST_SIGNAL] = + g_signal_new ("up_dir_request", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (CxpRightPaneClass, + up_dir_request), NULL, + NULL, g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + parent_class = g_type_class_peek_parent (klass); } @@ -239,6 +251,8 @@ G_CALLBACK (cxp_right_pane_on_cursor_changed), self); g_signal_connect (priv->file_list, "row_activated", G_CALLBACK (cxp_right_pane_on_row_activated), self); + g_signal_connect (priv->file_list, "key-press-event", + G_CALLBACK (cxp_right_pane_on_key_pressed), self); g_signal_connect (priv->expander, "notify::expanded", G_CALLBACK (cxp_right_pane_preview_expanded), self); } @@ -485,6 +499,29 @@ g_free (fullpath); } +static void cxp_right_pane_on_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data) +{ + CxpRightPane *self = CXP_RIGHT_PANE (user_data); + CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (self); + + switch (event->keyval) + { + case GDK_F2: + cxp_right_pane_rename_file_request (self); + break; + case GDK_Delete: + cxp_right_pane_delete_selected_files (self); + break; + case GDK_BackSpace: + g_signal_emit (self, + cxp_right_pane_signals + [UP_DIR_REQUEST_SIGNAL], 0); + break; + default: + GTK_WIDGET_GET_CLASS(priv->file_list)->key_press_event (widget, event); + } +} + /** * This function is called back before pixbuf cell is painted. * @param tree_column [in] Pointer to instance fo GtkTreeViewColumn. @@ -570,7 +607,6 @@ gtk_tree_path_free (path); return; } - g_free (srcbase); dirname = g_path_get_dirname (srcpath); destbase_locale = g_locale_from_utf8 (new_text, -1, NULL, NULL, NULL); @@ -588,6 +624,10 @@ } else { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_EDITABLE, + FALSE, -1); + cxp_error_dialog_run_about_file (srcbase); + /* dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, @@ -596,10 +636,13 @@ g_strerror (errno)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + */ } } else { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_EDITABLE, + FALSE, -1); error_msg = g_strdup_printf (_("%s is already exists."), new_text); dialog = gtk_message_dialog_new (NULL, @@ -615,6 +658,7 @@ g_free (destbase_locale); g_free (dirname); g_free (srcpath); + g_free (srcbase); /* test */ gtk_tree_path_free (path); @@ -899,7 +943,7 @@ GTK_RESPONSE_YES) { cmd = g_strdup_printf ("rm -rf '%s'", - filename); + fullpath); g_spawn_command_line_sync (cmd, NULL, &standard_error, &exit_status, @@ -1094,13 +1138,23 @@ { CxpRightPanePrivate *priv = CXP_RIGHT_PANE_GET_PRIVATE (right_pane); GtkTreeSelection *selection; + GtkTreePath *path; + gchar *path_str; - selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list)); + gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->file_list), &path, NULL); + path_str = gtk_tree_path_to_string (path); + gtk_tree_path_free (path); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list)); gtk_tree_selection_selected_foreach (selection, cxp_right_pane_delete_selected_file_foreach, NULL); cxp_right_pane_change_directory (right_pane, priv->cur_dir); + + path = gtk_tree_path_new_from_string (path_str); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->file_list), path, NULL, FALSE); + gtk_tree_path_free (path); + g_free (path_str); } void cxp_right_pane_paste_from_clipboard (CxpRightPane * right_pane) @@ -1164,7 +1218,6 @@ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->file_list)); - //if (gtk_tree_selection_get_selected (selection, &model, &iter)) if (gtk_tree_selection_count_selected_rows (selection) == 1) { gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->file_list), @@ -1179,80 +1232,6 @@ TRUE, -1); gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->file_list), treepath, column, TRUE); - /* - gtk_tree_model_get (model, &iter, COL_FILE_PATH, &srcpath, - COL_TERMINATOR); - dirname = g_path_get_dirname (srcpath); - srcbase = cxp_path_get_basename_of_utf8 (srcpath); - dialog = cxp_entry_dialog_new (_("Rename"), - _("Please, input a new name."), - srcbase); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - destbase = - cxp_entry_dialog_get_entry_text - (CXP_ENTRY_DIALOG (dialog)); - gtk_widget_destroy (dialog); - destbase_locale = - g_locale_from_utf8 (destbase, -1, NULL, NULL, - NULL); - destpath = - g_build_filename (dirname, destbase_locale, - NULL); - - if (g_file_test (destpath, G_FILE_TEST_EXISTS) == FALSE) - { - if (rename (srcpath, destpath) == 0) - { - gtk_list_store_set (GTK_LIST_STORE - (model), &iter, - COL_FILE_PATH, - destpath, - COL_DISP_NAME, - destbase, - COL_TERMINATOR); - } - else - { - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", - g_strerror - (errno)); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else - { - error_msg = - g_strdup_printf (_ - ("%s is already exists."), - destbase); - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", - error_msg); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - g_free (error_msg); - } - - g_free (destbase); - g_free (destbase_locale); - } - else - { - gtk_widget_destroy (dialog); - } - g_free (dirname); - g_free (srcbase); - g_free (srcpath); - */ gtk_tree_path_free (treepath); } } Index: cxplorer/src/cxp-right-pane.h diff -u cxplorer/src/cxp-right-pane.h:1.15 cxplorer/src/cxp-right-pane.h:1.16 --- cxplorer/src/cxp-right-pane.h:1.15 Thu May 12 18:55:23 2005 +++ cxplorer/src/cxp-right-pane.h Mon May 16 21:22:27 2005 @@ -42,6 +42,7 @@ GtkVBoxClass parent; void (* dir_double_clicked) (CxpRightPane *right_pane); + void (* up_dir_request) (CxpRightPane *right_pane); }; /* used by CXP_TYPE_RIGHT_PANE */ Index: cxplorer/src/cxplorer-window.c diff -u cxplorer/src/cxplorer-window.c:1.50 cxplorer/src/cxplorer-window.c:1.51 --- cxplorer/src/cxplorer-window.c:1.50 Thu May 12 18:55:23 2005 +++ cxplorer/src/cxplorer-window.c Mon May 16 21:22:27 2005 @@ -298,6 +298,9 @@ g_signal_connect (right_pane, "dir_double_clicked", G_CALLBACK (cxplorer_window_on_dir_double_clicked), self); + g_signal_connect (right_pane, "up_dir_request", + G_CALLBACK (cxplorer_window_go_up_action), + self); } /**