[gnome-commander] tab lock: added protection against closing locked tabs
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] tab lock: added protection against closing locked tabs
- Date: Tue, 11 Jan 2011 19:25:43 +0000 (UTC)
commit fbb104c916d7591c86d40505b9c75dd951a7b071
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Tue Jan 11 20:25:06 2011 +0100
tab lock: added protection against closing locked tabs
src/gnome-cmd-file-selector.cc | 14 ++++++++++++--
src/gnome-cmd-user-actions.cc | 16 ++++++++++++----
2 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 47427e2..6866eb7 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -603,7 +603,12 @@ static gboolean on_notebook_button_pressed (GtkWidget *widget, GdkEventButton *e
tab_clicked = notebook->find_tab_num_at_pos(event->x_root, event->y_root);
if (tab_clicked>=0)
- fs->close_tab(tab_clicked);
+ {
+ GnomeCmdFileList *fl = fs->file_list(tab_clicked);
+
+ if (!fl->locked || gnome_cmd_prompt_message (*main_win, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The tab is locked, close anyway ?"))==GTK_RESPONSE_OK)
+ fs->close_tab(tab_clicked);
+ }
return tab_clicked>=0;
@@ -673,7 +678,12 @@ static gboolean on_notebook_button_pressed (GtkWidget *widget, GdkEventButton *e
tab_clicked = notebook->find_tab_num_at_pos(event->x_root, event->y_root);
if (tab_clicked>=0)
- fs->close_tab(tab_clicked);
+ {
+ GnomeCmdFileList *fl = fs->file_list(tab_clicked);
+
+ if (!fl->locked || gnome_cmd_prompt_message (*main_win, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The tab is locked, close anyway ?"))==GTK_RESPONSE_OK)
+ fs->close_tab(tab_clicked);
+ }
else
fs->new_tab(fs->get_directory());
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index d9476d5..6303b30 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1514,10 +1514,18 @@ void view_close_tab (GtkMenuItem *menuitem, gpointer file_list)
GnomeCmdFileList *fl = GNOME_CMD_FILE_LIST (file_list);
GnomeCmdFileSelector *fs = GNOME_CMD_FILE_SELECTOR (gtk_widget_get_ancestor (*fl, GNOME_CMD_TYPE_FILE_SELECTOR));
- fs->close_tab(gtk_notebook_page_num (*fs->notebook, gtk_widget_get_parent (*fl)));
+ if (fs->notebook->size()>1)
+ if (!fl->locked || gnome_cmd_prompt_message (*main_win, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The tab is locked, close anyway ?"))==GTK_RESPONSE_OK)
+ fs->close_tab(gtk_notebook_page_num (*fs->notebook, gtk_widget_get_parent (*fl)));
}
else
- get_fs (ACTIVE)->close_tab();
+ {
+ GnomeCmdFileSelector *fs = get_fs (ACTIVE);
+
+ if (fs->notebook->size()>1)
+ if (!fs->file_list()->locked || gnome_cmd_prompt_message (*main_win, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, _("The tab is locked, close anyway ?"))==GTK_RESPONSE_OK)
+ fs->close_tab();
+ }
}
@@ -1528,7 +1536,7 @@ void view_close_all_tabs (GtkMenuItem *menuitem, gpointer file_selector)
gint n = notebook->get_current_page();
for (gint i=notebook->size(); i--;)
- if (i!=n)
+ if (i!=n && !fs->file_list(i)->locked)
notebook->remove_page(i);
}
@@ -1547,7 +1555,7 @@ void view_close_duplicate_tabs (GtkMenuItem *menuitem, gpointer file_selector)
{
GnomeCmdFileList *fl = GNOME_CMD_FILE_LIST (gtk_bin_get_child (GTK_BIN (notebook->page(i))));
- if (fl)
+ if (fl && !fl->locked)
dirs[fl->cwd].insert(i);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]