[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gcmd-dev] Tabbed Browsing
From: |
André |
Subject: |
Re: [gcmd-dev] Tabbed Browsing |
Date: |
Sun, 18 Jan 2009 14:55:31 +0100 |
User-agent: |
Thunderbird 2.0.0.18 (X11/20081229) |
the first (cleaned) patch
i removed the tab labels as switching the tabs left the old tabs incorrectly
labelled
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -80,6 +80,7 @@ struct _GnomeCmdMainWinPrivate
GtkWidget *vbox;
GtkWidget *paned;
GtkWidget *file_selector[2];
+ GtkWidget *tabs[2];
GtkWidget *focused_widget;
GtkAccelGroup *accel_group;
@@ -770,6 +771,8 @@ static void init (GnomeCmdMainWin *mw)
mw->priv->buttonbar_sep = NULL;
mw->priv->file_selector[LEFT] = NULL;
mw->priv->file_selector[RIGHT] = NULL;
+ mw->priv->tabs[LEFT] = NULL;
+ mw->priv->tabs[RIGHT] = NULL;
gnome_app_construct (GNOME_APP (main_win), "gnome-commander", geteuid() ?
_("GNOME Commander") :
_("GNOME Commander - ROOT PRIVILEGES"));
@@ -803,6 +806,19 @@ static void init (GnomeCmdMainWin *mw)
gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->paned, TRUE, TRUE,
0);
create_buttonbar (mw);
+ mw->priv->tabs[LEFT] = gtk_notebook_new();
+ gtk_widget_show (mw->priv->tabs[LEFT]);
+ gtk_paned_pack1 (GTK_PANED (mw->priv->paned), mw->priv->tabs[LEFT], TRUE,
TRUE);
+ gnome_cmd_main_win_tab_new(mw, LEFT);
+ gtk_signal_connect (GTK_OBJECT (mw->priv->tabs[LEFT]), "switch-page",
GTK_SIGNAL_FUNC (on_main_win_tab_changed), NULL);
+
+ mw->priv->tabs[RIGHT] = gtk_notebook_new();
+ gtk_widget_show (mw->priv->tabs[RIGHT]);
+ gtk_paned_pack2 (GTK_PANED (mw->priv->paned), mw->priv->tabs[RIGHT],
TRUE, TRUE);
+ gnome_cmd_main_win_tab_new(mw, RIGHT);
+ gtk_signal_connect (GTK_OBJECT (mw->priv->tabs[RIGHT]), "switch-page",
GTK_SIGNAL_FUNC (on_main_win_tab_changed), NULL);
+
+/*
mw->priv->file_selector[LEFT] = gnome_cmd_file_selector_new ();
gtk_widget_ref (mw->priv->file_selector[LEFT]);
gtk_object_set_data_full (GTK_OBJECT (main_win), "left_file_selector",
@@ -818,12 +834,13 @@ static void init (GnomeCmdMainWin *mw)
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (mw->priv->file_selector[RIGHT]);
gtk_paned_pack2 (GTK_PANED (mw->priv->paned),
mw->priv->file_selector[RIGHT], TRUE, TRUE);
-
+*/
gnome_cmd_main_win_update_toolbar_visibility (main_win);
gnome_cmd_main_win_update_cmdline_visibility (main_win);
gnome_cmd_main_win_update_buttonbar_visibility (main_win);
gtk_signal_connect (GTK_OBJECT (main_win), "realize", GTK_SIGNAL_FUNC
(on_main_win_realize), mw);
+/*
gtk_signal_connect (GTK_OBJECT (mw->priv->file_selector[LEFT]),
"changed-dir", GTK_SIGNAL_FUNC (on_fs_dir_change), mw);
gtk_signal_connect (GTK_OBJECT (mw->priv->file_selector[RIGHT]),
"changed-dir", GTK_SIGNAL_FUNC (on_fs_dir_change), mw);
@@ -837,6 +854,7 @@ static void init (GnomeCmdMainWin *mw)
"button-press-event", GTK_SIGNAL_FUNC
(on_left_fs_select), mw);
gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[RIGHT])->file_list()),
"button-press-event", GTK_SIGNAL_FUNC
(on_right_fs_select), mw);
+*/
gtk_signal_connect (GTK_OBJECT (mw), "size-allocate", GTK_SIGNAL_FUNC
(on_size_allocate), mw);
gtk_signal_connect (GTK_OBJECT (mw), "delete-event", GTK_SIGNAL_FUNC
(on_delete_event), mw);
gtk_signal_connect (GTK_OBJECT (mw->priv->paned), "button-press-event",
GTK_SIGNAL_FUNC (on_slide_button_press), mw);
@@ -1327,3 +1345,111 @@ void gnome_cmd_main_win_set_equal_panes
(GnomeCmdMainWin *mw)
{
slide_set_50_50 (NULL, NULL);
}
+
+
+FileSelectorID gnome_cmd_main_win_get_fsID (GnomeCmdMainWin *mw,
FileSelectorID fs)
+{
+ g_return_val_if_fail (GNOME_CMD_IS_MAIN_WIN (mw), fs);
+
+ switch (fs)
+ {
+ case LEFT:
+ case RIGHT:
+ return fs;
+
+ case ACTIVE:
+ return mw->priv->current_fs;
+
+ case INACTIVE:
+ return !mw->priv->current_fs;
+
+ default:
+ return fs;
+ }
+}
+
+
+void gnome_cmd_main_win_tab_new (GnomeCmdMainWin *mw, FileSelectorID fs)
+{
+
+ g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
+
+ FileSelectorID fsID = gnome_cmd_main_win_get_fsID (mw, fs);
+ mw->priv->file_selector[fsID] = gnome_cmd_file_selector_new();
+ gtk_widget_ref (mw->priv->file_selector[fsID]);
+ gtk_signal_connect (GTK_OBJECT (mw->priv->file_selector[fsID]),
"changed-dir", GTK_SIGNAL_FUNC (on_fs_dir_change), mw);
+ switch (fsID)
+ {
+ LEFT:
+ gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[fsID])->file_list()),
+ "button-press-event", GTK_SIGNAL_FUNC
(on_left_fs_select), mw);
+ gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[fsID])->file_list()),
+ "button-press-event", GTK_SIGNAL_FUNC
(on_left_fs_select), mw);
+ gtk_object_set_data_full (GTK_OBJECT (main_win),
"left_file_selector",
+ mw->priv->file_selector[fsID],
+ (GtkDestroyNotify) gtk_widget_unref);
+ break;
+ RIGHT:
+ gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[fsID])->file_list()),
+ "button-press-event", GTK_SIGNAL_FUNC
(on_right_fs_select), mw);
+ gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[fsID])->file_list()),
+ "button-press-event", GTK_SIGNAL_FUNC
(on_right_fs_select), mw);
+ gtk_object_set_data_full (GTK_OBJECT (main_win),
"right_file_selector",
+ mw->priv->file_selector[fsID],
+ (GtkDestroyNotify) gtk_widget_unref);
+ break;
+ }
+ // Todo: --> heavy, because both fs needed, but only one was created
+ //gtk_signal_connect (GTK_OBJECT (GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[RIGHT])->file_list()),
+ // "resize-column", GTK_SIGNAL_FUNC
(on_fs_list_resize_column),
+ // GNOME_CMD_FILE_SELECTOR
(mw->priv->file_selector[LEFT])->file_list());
+
+ GtkWidget *tab_lable = gtk_label_new("new");
+ gtk_notebook_append_page (GTK_NOTEBOOK(mw->priv->tabs[fsID]),
mw->priv->file_selector[fsID], tab_lable);
+ gtk_notebook_next_page (GTK_NOTEBOOK(mw->priv->tabs[fsID]));
+ if (gtk_notebook_get_n_pages (GTK_NOTEBOOK(mw->priv->tabs[fsID])) == 2)
+ {
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK(mw->priv->tabs[fsID]), TRUE);
+ }
+}
+
+
+void gnome_cmd_main_win_tab_close (GnomeCmdMainWin *mw, FileSelectorID fs)
+{
+ g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
+
+ FileSelectorID fsID = gnome_cmd_main_win_get_fsID (mw, fs);
+ if(gtk_notebook_get_n_pages (GTK_NOTEBOOK(mw->priv->tabs[fsID])) > 1)
+ {
+ gtk_notebook_remove_page (GTK_NOTEBOOK(mw->priv->tabs[fsID]),
gtk_notebook_get_current_page (GTK_NOTEBOOK(mw->priv->tabs[fsID])));
+ if(gtk_notebook_get_n_pages (GTK_NOTEBOOK(mw->priv->tabs[fsID])) == 1)
+ {
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK(mw->priv->tabs[fsID]),
FALSE);
+ }
+ }
+}
+
+
+void on_main_win_tab_changed (GtkNotebook *nb, GtkNotebookPage *page, guint
page_num, gpointer user_data)
+{
+ FileSelectorID fsID = gnome_cmd_main_win_get_fsID(main_win, ACTIVE);
+
+ // Diffrent from *page --> gtk-api-bug !?
+ GtkWidget *ppage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb), page_num);
+
+ main_win->priv->file_selector[fsID] = ppage;
+ switch (fsID)
+ {
+ LEFT:
+ gtk_object_set_data_full (GTK_OBJECT (main_win),
"left_file_selector",
+ ppage,
+ (GtkDestroyNotify) gtk_widget_unref);
+ break;
+ RIGHT:
+ gtk_object_set_data_full (GTK_OBJECT (main_win),
"right_file_selector",
+ ppage,
+ (GtkDestroyNotify) gtk_widget_unref);
+ break;
+ }
+}
+
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -88,4 +88,9 @@ void gnome_cmd_main_win_set_cap_state (GnomeCmdMainWin *mw,
gboolean state);
void gnome_cmd_main_win_set_equal_panes (GnomeCmdMainWin *mw);
+FileSelectorID gnome_cmd_main_win_get_fsID (GnomeCmdMainWin *mw,
FileSelectorID fs);
+
+void gnome_cmd_main_win_tab_new (GnomeCmdMainWin *mw, FileSelectorID fs);
+void gnome_cmd_main_win_tab_close (GnomeCmdMainWin *mw, FileSelectorID fs);
+void on_main_win_tab_changed (GtkNotebook *nb, GtkNotebookPage *page, guint
page_num, gpointer user_data);
#endif // __GNOME_CMD_MAIN_WIN_H__
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1381,11 +1381,13 @@ void view_root (GtkMenuItem *menuitem, gpointer
not_used)
void view_new_tab (GtkMenuItem *menuitem, gpointer not_used)
{
+ gnome_cmd_main_win_tab_new(main_win, ACTIVE);
}
void view_close_tab (GtkMenuItem *menuitem, gpointer not_used)
{
+ gnome_cmd_main_win_tab_close(main_win, ACTIVE);
}