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

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 4月 9日 (土) 17:32:42 JST


Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.18 cxplorer/src/cxplorer-window.c:1.19
--- cxplorer/src/cxplorer-window.c:1.18	Sat Apr  9 17:14:16 2005
+++ cxplorer/src/cxplorer-window.c	Sat Apr  9 17:32:42 2005
@@ -29,6 +29,7 @@
 
 #include <cxp.h>
 #include <glib/gi18n.h>
+#include <errno.h>
 #include "cxp-dir-view.h"
 #include "cxp-right-pane.h"
 #include "cxp-property-dialog.h"
@@ -74,6 +75,7 @@
 						   gpointer user_data);
 static void cxplorer_window_new_win_action (GtkWidget *widget, gpointer user_data);
 void cxplorer_window_new_file_action (GtkWidget * widget, gpointer user_data);
+void cxplorer_window_new_directory_action (GtkWidget *widget, gpointer user_data);
 void cxplorer_window_delete_action (GtkWidget * widget, gpointer user_data);
 static void cxplorer_window_rename_action (GtkWidget *widget, gpointer user_data);
 static void cxplorer_window_property_action (GtkWidget * widget, gpointer user_data);
@@ -93,7 +95,7 @@
 	{"NewMenuAction", NULL, N_("_New"), NULL, NULL, NULL},
 	{"NewWinAction", NULL, N_("_Window"), NULL, NULL, G_CALLBACK(cxplorer_window_new_win_action)},
 	{"NewFileAction", "gtk-new", N_("_File..."), NULL, NULL, G_CALLBACK(cxplorer_window_new_file_action)},
-	{"NewDirAction", NULL, N_("_Directory..."), NULL, NULL, NULL},
+	{"NewDirAction", NULL, N_("_Directory..."), NULL, NULL, G_CALLBACK(cxplorer_window_new_directory_action)},
 	{"DeleteAction", "gtk-delete", N_("_Delete"), NULL, NULL, G_CALLBACK(cxplorer_window_delete_action)},
 	{"RenameAction", NULL, N_("_Rename..."), NULL, NULL, G_CALLBACK(cxplorer_window_rename_action)},
 	{"SendAction", NULL, N_("_Send to"), NULL, NULL, NULL},
@@ -387,6 +389,55 @@
 }
 
 /**
+ * This function generate new directory when user click "File->New->Directory".
+ * @param menuitem [in] Pointer to menu item "File->New->Directory".
+ * @param user_data [in] Pointer to data which is defined user_data.
+ */
+void cxplorer_window_new_directory_action (GtkWidget *widget, gpointer user_data)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
+	gchar *current_dir;
+	gchar *fullpath;
+	gchar *label;
+	gchar *locale_name;
+	GtkWidget *dialog;
+
+	dialog = cxp_entry_dialog_new(_("New directory"), _("Please input the name of a new directory."), _("NewDirectory"));
+	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+	{
+		label = cxp_entry_dialog_get_entry_text(CXP_ENTRY_DIALOG(dialog));
+		gtk_widget_destroy(dialog);
+		locale_name = g_locale_from_utf8 (label, -1, NULL, NULL, NULL);
+		if (locale_name != NULL)
+		{
+			current_dir = cxp_dir_view_get_current_directory (CXP_DIR_VIEW(private->dirview));
+			fullpath = g_build_filename (current_dir, locale_name, NULL);
+			g_free (current_dir);
+			if (mkdir (fullpath, S_IFDIR | 0777) == 0)
+			{
+				cxp_dir_view_refresh(CXP_DIR_VIEW(private->dirview));
+			}
+			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);
+			}
+			g_free (label);
+		}
+	}
+	else
+	{
+		gtk_widget_destroy(dialog);
+	}
+}
+
+/**
  * This function delete selected file when user clicked "File->Delete".
  * @param menuitem [in] Pointer to menu item "File->Delete".
  * @param user_data [in] Pointer to instance of Cxplorer.


Cxplorer-cvs メーリングリストの案内
Back to archive index