[gnome-commander] Fixed problem #377463 (mkdir dialog loses focus)
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Fixed problem #377463 (mkdir dialog loses focus)
- Date: Sun, 12 Dec 2010 19:59:29 +0000 (UTC)
commit 4c8634413b739ab2fe2386910a0136180812408e
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sun Dec 12 20:54:15 2010 +0100
Fixed problem #377463 (mkdir dialog loses focus)
NEWS | 1 +
doc/C/gnome-commander.xml | 3 +
po/POTFILES.in | 2 +-
src/Makefile.am | 1 -
src/dialogs/Makefile.am | 1 +
src/dialogs/gnome-cmd-mkdir-dialog.cc | 225 +++++++++++++++++++++++++++++++
src/dialogs/gnome-cmd-mkdir-dialog.h | 28 ++++
src/gnome-cmd-mkdir-dialog.cc | 235 ---------------------------------
src/gnome-cmd-mkdir-dialog.h | 55 --------
src/gnome-cmd-user-actions.cc | 10 +-
10 files changed, 263 insertions(+), 298 deletions(-)
---
diff --git a/NEWS b/NEWS
index c544ba4..a7c857f 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ gnome-commander 1.4
---------------
Bug fixes:
+ * Fixed problem #377463 (mkdir dialog loses focus)
* Fixed problem #617140 (GNOME Goal: Use accessor functions instead direct access)
* Fixed problems #632064, #632208, #633107, #633167, #633331, #634972 (bugs in in gnome-commander-help.master.po)
* Fixed Ubuntu problem #117226 (bookmarks unification)
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index ca1e1b1..f31b01d 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -7405,6 +7405,9 @@
<para>
<itemizedlist>
<listitem>
+ <para>Fixed problem #377463 (mkdir dialog loses focus)</para>
+ </listitem>
+ <listitem>
<para>Fixed problem #617140 (GNOME Goal: Use accessor functions instead direct access)</para>
</listitem>
<listitem>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a28339a..3677348 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@ src/dialogs/gnome-cmd-edit-profile-dialog.cc
src/dialogs/gnome-cmd-key-shortcuts-dialog.cc
src/dialogs/gnome-cmd-manage-bookmarks-dialog.cc
src/dialogs/gnome-cmd-manage-profiles-dialog.cc
+src/dialogs/gnome-cmd-mkdir-dialog.cc
src/dirlist.cc
src/eggcellrendererkeys.cc
src/gnome-cmd-about-plugin.cc
@@ -40,7 +41,6 @@ src/gnome-cmd-list-popmenu.cc
src/gnome-cmd-main-menu.cc
src/gnome-cmd-main-win.cc
src/gnome-cmd-make-copy-dialog.cc
-src/gnome-cmd-mkdir-dialog.cc
src/gnome-cmd-options-dialog.cc
src/gnome-cmd-patternsel-dialog.cc
src/gnome-cmd-prepare-copy-dialog.cc
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ccf5e4..a48ef65 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,7 +55,6 @@ gnome_commander_SOURCES = \
gnome-cmd-main-win.h gnome-cmd-main-win.cc \
gnome-cmd-make-copy-dialog.h gnome-cmd-make-copy-dialog.cc \
gnome-cmd-menu-button.h gnome-cmd-menu-button.cc \
- gnome-cmd-mkdir-dialog.h gnome-cmd-mkdir-dialog.cc \
gnome-cmd-notebook.h gnome-cmd-notebook.cc \
gnome-cmd-options-dialog.h gnome-cmd-options-dialog.cc \
gnome-cmd-path.h gnome-cmd-path.cc \
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 6986bb5..61deac5 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -20,6 +20,7 @@ libgcmd_dialogs_a_SOURCES = \
gnome-cmd-advrename-regex-dialog.h gnome-cmd-advrename-regex-dialog.cc \
gnome-cmd-edit-bookmark-dialog.h gnome-cmd-edit-bookmark-dialog.cc \
gnome-cmd-manage-bookmarks-dialog.h gnome-cmd-manage-bookmarks-dialog.cc \
+ gnome-cmd-mkdir-dialog.h gnome-cmd-mkdir-dialog.cc \
gnome-cmd-key-shortcuts-dialog.h gnome-cmd-key-shortcuts-dialog.cc \
gnome-cmd-edit-profile-dialog.h gnome-cmd-edit-profile-dialog.cc \
gnome-cmd-manage-profiles-dialog.h gnome-cmd-manage-profiles-dialog.cc
diff --git a/src/dialogs/gnome-cmd-mkdir-dialog.cc b/src/dialogs/gnome-cmd-mkdir-dialog.cc
new file mode 100644
index 0000000..5f26fda
--- /dev/null
+++ b/src/dialogs/gnome-cmd-mkdir-dialog.cc
@@ -0,0 +1,225 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2010 Piotr Eljasiak
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <config.h>
+
+#include "gnome-cmd-includes.h"
+#include "gnome-cmd-mkdir-dialog.h"
+#include "gnome-cmd-dir.h"
+#include "gnome-cmd-main-win.h"
+#include "utils.h"
+
+using namespace std;
+
+
+struct GnomeCmdMkdirDialogPrivate
+{
+ GnomeCmdDir *dir;
+ GnomeCmdMainWin *mw;
+};
+
+
+inline GSList *make_uri_list (GnomeCmdDir *dir, string filename)
+{
+ g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), NULL);
+
+ // make an absolute filename from one that is starting with a tilde
+ if (filename.compare(0, 2, "~/")==0)
+ if (gnome_cmd_dir_is_local (dir))
+ stringify (filename, gnome_vfs_expand_initial_tilde (filename.c_str()));
+ else
+ filename.erase(0,1);
+
+ // smb exception handling: test if we are in a samba share...
+ // if not - change filename so that we can get a proper error message
+ GnomeVFSURI *dir_uri = gnome_cmd_dir_get_uri (dir);
+
+ if (strcmp (gnome_vfs_uri_get_scheme (dir_uri), "smb")==0 && g_path_is_absolute (filename.c_str()))
+ {
+ string mime_type = stringify (gnome_vfs_get_mime_type (gnome_vfs_uri_to_string (dir_uri, GNOME_VFS_URI_HIDE_NONE)));
+
+ if (mime_type=="x-directory/normal" && !gnome_vfs_uri_has_parent (dir_uri))
+ filename.erase(0,1);
+ }
+ gnome_vfs_uri_unref (dir_uri);
+
+ GSList *uri_list = NULL;
+
+ if (g_path_is_absolute (filename.c_str()))
+ while (filename.compare("/")!=0)
+ {
+ uri_list = g_slist_prepend (uri_list, gnome_cmd_dir_get_absolute_path_uri (dir, filename));
+ stringify (filename, g_path_get_dirname (filename.c_str()));
+ }
+ else
+ while (filename.compare(".")!=0) // support for mkdir -p
+ {
+ uri_list = g_slist_prepend (uri_list, gnome_cmd_dir_get_child_uri (dir, filename.c_str()));
+ stringify (filename, g_path_get_dirname (filename.c_str()));
+ }
+
+ return uri_list;
+}
+
+
+static void response_callback (GtkDialog *dialog, int response_id, GnomeCmdDir *dir)
+{
+ switch (response_id)
+ {
+ case GTK_RESPONSE_HELP:
+ gnome_cmd_help_display ("gnome-commander.xml", "gnome-commander-create-folder");
+ g_signal_stop_emission_by_name (dialog, "response");
+ break;
+
+ case GTK_RESPONSE_OK:
+ {
+ const gchar *filename = gtk_entry_get_text (GTK_ENTRY (lookup_widget (GTK_WIDGET (dialog), "name")));
+
+ // don't create any directory if no name was passed or cancel was selected
+ if (!filename || *filename==0)
+ {
+ gnome_cmd_show_message(GTK_WINDOW (dialog), _("A directory name must be entered"));
+ g_signal_stop_emission_by_name (dialog, "response");
+ }
+ else
+ {
+ GnomeVFSURI *dir_uri = gnome_cmd_dir_get_uri (dir);
+ gboolean new_dir_focused = FALSE;
+
+ // the list of uri's to be created
+ GSList *uri_list = make_uri_list (dir, filename);
+
+ GnomeVFSResult result = GNOME_VFS_OK;
+
+ for (GSList *i = uri_list; i; i = g_slist_next (i))
+ {
+ GnomeVFSURI *mkdir_uri = (GnomeVFSURI *) i->data;
+
+ result = gnome_vfs_make_directory_for_uri (mkdir_uri,
+ GNOME_VFS_PERM_USER_READ|GNOME_VFS_PERM_USER_WRITE|GNOME_VFS_PERM_USER_EXEC|
+ GNOME_VFS_PERM_GROUP_READ|GNOME_VFS_PERM_GROUP_EXEC|
+ GNOME_VFS_PERM_OTHER_READ|GNOME_VFS_PERM_OTHER_EXEC);
+
+
+ if (result!=GNOME_VFS_OK)
+ {
+ string dirname = stringify (gnome_vfs_uri_extract_short_name (mkdir_uri));
+ gnome_cmd_show_message(GTK_WINDOW (dialog), dirname, gnome_vfs_result_to_string (result));
+ g_signal_stop_emission_by_name (dialog, "response");
+ break;
+ }
+
+ // focus the created directory (if possible)
+ if (gnome_vfs_uri_equal (gnome_vfs_uri_get_parent (mkdir_uri), dir_uri) == 1 && !new_dir_focused)
+ {
+ string focus_filename = stringify (gnome_vfs_uri_extract_short_name (mkdir_uri));
+ string mkdir_uri_str = stringify (gnome_vfs_uri_to_string (mkdir_uri, GNOME_VFS_URI_HIDE_NONE));
+
+ gnome_cmd_dir_file_created (dir, mkdir_uri_str.c_str());
+ main_win->fs(ACTIVE)->file_list()->focus_file(focus_filename.c_str(), TRUE);
+ new_dir_focused = TRUE;
+ }
+ }
+
+ for (GSList *i = uri_list; i; i = g_slist_next (i))
+ gnome_vfs_uri_unref ((GnomeVFSURI *) i->data);
+
+ g_slist_free (uri_list);
+ gnome_vfs_uri_unref (dir_uri);
+ }
+ }
+ break;
+
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ case GTK_RESPONSE_CANCEL:
+ break;
+
+ default :
+ g_assert_not_reached ();
+ }
+}
+
+
+gboolean gnome_cmd_mkdir_dialog_new (GnomeCmdDir *dir)
+{
+ GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Make Directory"), *main_win,
+ GtkDialogFlags (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+ GTK_STOCK_HELP, GTK_RESPONSE_HELP, // FIXME: ???
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+#endif
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+ // HIG defaults
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ gtk_box_set_spacing (GTK_BOX (content_area), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
+ gtk_box_set_spacing (GTK_BOX (content_area),6);
+#else
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area),6);
+#endif
+ GtkWidget *table, *align, *label, *entry;
+
+ table = gtk_table_new (3, 2, FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (table), 5);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ gtk_container_add (GTK_CONTAINER (content_area), table);
+#else
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
+#endif
+
+ label = gtk_label_new_with_mnemonic (_("Directory name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
+
+ entry = gtk_entry_new ();
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+ gtk_entry_set_text (GTK_ENTRY (entry), "PATTERN");
+ g_object_set_data (G_OBJECT (dialog), "name", entry);
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 0, 1);
+
+#if GTK_CHECK_VERSION (2, 14, 0)
+ gtk_widget_show_all (content_area);
+#else
+ gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
+#endif
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ g_signal_connect (dialog, "response", G_CALLBACK (response_callback), dir);
+
+ gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+
+ return result==GTK_RESPONSE_OK;
+}
diff --git a/src/dialogs/gnome-cmd-mkdir-dialog.h b/src/dialogs/gnome-cmd-mkdir-dialog.h
new file mode 100644
index 0000000..d15a2c6
--- /dev/null
+++ b/src/dialogs/gnome-cmd-mkdir-dialog.h
@@ -0,0 +1,28 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2010 Piotr Eljasiak
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __GNOME_CMD_MKDIR_DIALOG_H__
+#define __GNOME_CMD_MKDIR_DIALOG_H__
+
+#include "gnome-cmd-dir.h"
+
+gboolean gnome_cmd_mkdir_dialog_new (GnomeCmdDir *dir);
+
+#endif // __GNOME_CMD_MKDIR_DIALOG_H__
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 4cc26f4..b3cae98 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -35,7 +35,6 @@
#include "gnome-cmd-con-dialog.h"
#include "gnome-cmd-remote-dialog.h"
#include "gnome-cmd-main-win.h"
-#include "gnome-cmd-mkdir-dialog.h"
#include "gnome-cmd-options-dialog.h"
#include "gnome-cmd-make-copy-dialog.h"
#include "gnome-cmd-prepare-copy-dialog.h"
@@ -51,6 +50,7 @@
#include "dialogs/gnome-cmd-advrename-dialog.h"
#include "dialogs/gnome-cmd-key-shortcuts-dialog.h"
#include "dialogs/gnome-cmd-manage-bookmarks-dialog.h"
+#include "dialogs/gnome-cmd-mkdir-dialog.h"
using namespace std;
@@ -795,11 +795,9 @@ void file_mkdir (GtkMenuItem *menuitem, gpointer not_used)
GnomeCmdDir *dir = get_fs (ACTIVE)->get_directory();
g_return_if_fail (GNOME_CMD_IS_DIR (dir));
- GtkWidget *dialog = gnome_cmd_mkdir_dialog_new (dir);
- g_return_if_fail (GNOME_CMD_IS_DIALOG (dialog));
-
- g_object_ref (dialog);
- gtk_widget_show (dialog);
+ gnome_cmd_dir_ref (dir);
+ gnome_cmd_mkdir_dialog_new (dir);
+ gnome_cmd_dir_unref (dir);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]