[gnome-commander] GnomeCmdMainWin: more C++ rework



commit 18375289d210ee9dbea75b372cc04f7049a6a85e
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Sep 26 00:00:35 2009 +0200

    GnomeCmdMainWin: more C++ rework

 src/gnome-cmd-bookmark-dialog.cc |    4 +-
 src/gnome-cmd-cmdline.cc         |    2 +-
 src/gnome-cmd-data.cc            |    2 +-
 src/gnome-cmd-file-selector.cc   |   20 ++--
 src/gnome-cmd-main-menu.cc       |    2 +-
 src/gnome-cmd-main-win.cc        |  252 +++++++++++++++++---------------------
 src/gnome-cmd-main-win.h         |   34 +++---
 src/gnome-cmd-options-dialog.cc  |    2 +-
 src/gnome-cmd-user-actions.cc    |    6 +-
 src/gnome-cmd-xfer.cc            |    4 +-
 src/plugin_manager.cc            |    2 +-
 11 files changed, 154 insertions(+), 176 deletions(-)
---
diff --git a/src/gnome-cmd-bookmark-dialog.cc b/src/gnome-cmd-bookmark-dialog.cc
index ddebfd5..8af0fd5 100644
--- a/src/gnome-cmd-bookmark-dialog.cc
+++ b/src/gnome-cmd-bookmark-dialog.cc
@@ -451,7 +451,7 @@ static void destroy (GtkObject *object)
     g_list_free (dialog->priv->groups);
     g_free (dialog->priv);
 
-    gnome_cmd_main_win_update_bookmarks (main_win);
+    main_win->update_bookmarks();
 
     if (GTK_OBJECT_CLASS (parent_class)->destroy)
         (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -636,7 +636,7 @@ void gnome_cmd_bookmark_add_current ()
 
         group->bookmarks = g_list_append (group->bookmarks, bookmark);
 
-        gnome_cmd_main_win_update_bookmarks (main_win);
+        main_win->update_bookmarks();
     }
     else
     {
diff --git a/src/gnome-cmd-cmdline.cc b/src/gnome-cmd-cmdline.cc
index 906457a..1388fd8 100644
--- a/src/gnome-cmd-cmdline.cc
+++ b/src/gnome-cmd-cmdline.cc
@@ -477,7 +477,7 @@ gboolean gnome_cmd_cmdline_keypressed (GnomeCmdCmdline *cmdline, GdkEventKey *ev
 
                     case GDK_Escape:
                         gnome_cmd_cmdline_set_text (cmdline, "");
-                        gnome_cmd_main_win_focus_file_lists (main_win);
+                        main_win->focus_file_lists();
                         return TRUE;
 
                     case GDK_Up:
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 14a11ba..d46d90e 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -813,7 +813,7 @@ inline void GnomeCmdData::save_cmdline_history()
     if (!cmdline_visibility)
         return;
 
-    cmdline_history = gnome_cmd_cmdline_get_history (gnome_cmd_main_win_get_cmdline (main_win));
+    cmdline_history = gnome_cmd_cmdline_get_history (main_win->get_cmdline());
 
     gnome_cmd_data_set_string_history ("/cmdline-history/line%d", cmdline_history);
 }
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 4039275..e7072cb 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -663,8 +663,8 @@ inline void add_file_to_cmdline (GnomeCmdFileSelector *fs, gboolean fullpath)
         gchar *text = fullpath ? gnome_cmd_file_get_quoted_real_path (f) :
                                  gnome_cmd_file_get_quoted_name (f);
 
-        gnome_cmd_cmdline_append_text (gnome_cmd_main_win_get_cmdline (main_win), text);
-        gnome_cmd_cmdline_focus (gnome_cmd_main_win_get_cmdline (main_win));
+        gnome_cmd_cmdline_append_text (main_win->get_cmdline(), text);
+        gnome_cmd_cmdline_focus (main_win->get_cmdline());
         g_free (text);
     }
 }
@@ -677,10 +677,10 @@ inline void add_cwd_to_cmdline (GnomeCmdFileSelector *fs)
     if (gnome_cmd_data.cmdline_visibility)
     {
         gchar *dpath = gnome_cmd_file_get_real_path (GNOME_CMD_FILE (fs->get_directory()));
-        gnome_cmd_cmdline_append_text (gnome_cmd_main_win_get_cmdline (main_win), dpath);
+        gnome_cmd_cmdline_append_text (main_win->get_cmdline(), dpath);
         g_free (dpath);
 
-        gnome_cmd_cmdline_focus (gnome_cmd_main_win_get_cmdline (main_win));
+        gnome_cmd_cmdline_focus (main_win->get_cmdline());
     }
 }
 
@@ -761,7 +761,7 @@ static void on_con_combo_item_selected (GnomeCmdCombo *con_combo, GnomeCmdCon *c
 
 static void on_combo_popwin_hidden (GnomeCmdCombo *combo, GnomeCmdFileSelector *fs)
 {
-    gnome_cmd_main_win_refocus (main_win);
+    main_win->refocus();
 }
 
 
@@ -1071,8 +1071,8 @@ static gboolean on_list_key_pressed_private (GtkCList *clist, GdkEventKey *event
             else
             {
                 text[0] = event->keyval;
-                gnome_cmd_cmdline_append_text (gnome_cmd_main_win_get_cmdline (main_win), text);
-                gnome_cmd_cmdline_focus (gnome_cmd_main_win_get_cmdline (main_win));
+                gnome_cmd_cmdline_append_text (main_win->get_cmdline(), text);
+                gnome_cmd_cmdline_focus (main_win->get_cmdline());
             }
             return TRUE;
         }
@@ -1780,15 +1780,15 @@ gboolean GnomeCmdFileSelector::key_pressed(GdkEventKey *event)
             case GDK_Return:
             case GDK_KP_Enter:
                 if (gnome_cmd_data.cmdline_visibility
-                    && gnome_cmd_cmdline_is_empty (gnome_cmd_main_win_get_cmdline (main_win)))
-                    gnome_cmd_cmdline_exec (gnome_cmd_main_win_get_cmdline (main_win));
+                    && gnome_cmd_cmdline_is_empty (main_win->get_cmdline()))
+                    gnome_cmd_cmdline_exec (main_win->get_cmdline());
                 else
                     do_file_specific_action (this, file_list()->get_focused_file());
                 return TRUE;
 
             case GDK_Escape:
                 if (gnome_cmd_data.cmdline_visibility)
-                    gnome_cmd_cmdline_set_text (gnome_cmd_main_win_get_cmdline (main_win), "");
+                    gnome_cmd_cmdline_set_text (main_win->get_cmdline(), "");
                 return TRUE;
         }
     }
diff --git a/src/gnome-cmd-main-menu.cc b/src/gnome-cmd-main-menu.cc
index dec2248..83b6c50 100644
--- a/src/gnome-cmd-main-menu.cc
+++ b/src/gnome-cmd-main-menu.cc
@@ -355,7 +355,7 @@ static void on_switch_orientation (GtkMenuItem *menu_item, GnomeCmdMainMenu *mai
 {
     gnome_cmd_data.list_orientation = !gnome_cmd_data.list_orientation;
 
-    gnome_cmd_main_win_update_list_orientation (main_win);
+    main_win->update_list_orientation();
 
     update_view_menu (main_menu);
 }
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 8e4c9d1..49848df 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -423,40 +423,39 @@ static void on_quit_clicked (GtkButton *button, GnomeCmdMainWin *mw)
 }
 
 
-static void create_buttonbar (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::create_buttonbar()
 {
-    mw->priv->buttonbar_sep = create_separator (FALSE);
-
-    mw->priv->buttonbar = gtk_hbox_new (FALSE, 0);
-    gtk_widget_ref (mw->priv->buttonbar);
-    gtk_object_set_data_full (GTK_OBJECT (main_win), "buttonbar", mw->priv->buttonbar,
-                              (GtkDestroyNotify) gtk_widget_unref);
-    gtk_widget_show (mw->priv->buttonbar);
-
-    mw->priv->view_btn = add_buttonbar_button(_("F3 View"), main_win, "view_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->edit_btn = add_buttonbar_button(_("F4 Edit"), main_win, "edit_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->copy_btn = add_buttonbar_button(_("F5 Copy"), main_win, "copy_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->move_btn = add_buttonbar_button(_("F6 Move"), main_win, "move_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->mkdir_btn = add_buttonbar_button(_("F7 Mkdir"), main_win, "mkdir_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->delete_btn = add_buttonbar_button(_("F8 Delete"), main_win, "delete_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->find_btn = add_buttonbar_button(_("F9 Search"), main_win, "find_btn", mw->priv->accel_group, 0);
-    gtk_box_pack_start (GTK_BOX (mw->priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
-    mw->priv->quit_btn = add_buttonbar_button(_("F10 Quit"), main_win, "quit_btn", mw->priv->accel_group, 0);
-
-    g_signal_connect (mw->priv->view_btn, "clicked", G_CALLBACK (on_view_clicked), mw);
-    g_signal_connect (mw->priv->edit_btn, "clicked", G_CALLBACK (on_edit_clicked), mw);
-    g_signal_connect (mw->priv->copy_btn, "clicked", G_CALLBACK (on_copy_clicked), mw);
-    g_signal_connect (mw->priv->move_btn, "clicked", G_CALLBACK (on_move_clicked), mw);
-    g_signal_connect (mw->priv->mkdir_btn, "clicked", G_CALLBACK (on_mkdir_clicked), mw);
-    g_signal_connect (mw->priv->delete_btn, "clicked", G_CALLBACK (on_delete_clicked), mw);
-    g_signal_connect (mw->priv->find_btn, "clicked", G_CALLBACK (on_search_clicked), mw);
-    g_signal_connect (mw->priv->quit_btn, "clicked", G_CALLBACK (on_quit_clicked), mw);
+    priv->buttonbar_sep = create_separator (FALSE);
+
+    priv->buttonbar = gtk_hbox_new (FALSE, 0);
+    gtk_widget_ref (priv->buttonbar);
+    gtk_object_set_data_full (*this, "buttonbar", priv->buttonbar, (GtkDestroyNotify) gtk_widget_unref);
+    gtk_widget_show (priv->buttonbar);
+
+    priv->view_btn = add_buttonbar_button(_("F3 View"), this, "view_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->edit_btn = add_buttonbar_button(_("F4 Edit"), this, "edit_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->copy_btn = add_buttonbar_button(_("F5 Copy"), this, "copy_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->move_btn = add_buttonbar_button(_("F6 Move"), this, "move_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->mkdir_btn = add_buttonbar_button(_("F7 Mkdir"), this, "mkdir_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->delete_btn = add_buttonbar_button(_("F8 Delete"), this, "delete_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->find_btn = add_buttonbar_button(_("F9 Search"), this, "find_btn", priv->accel_group, 0);
+    gtk_box_pack_start (GTK_BOX (priv->buttonbar), create_separator (TRUE), FALSE, TRUE, 0);
+    priv->quit_btn = add_buttonbar_button(_("F10 Quit"), this, "quit_btn", priv->accel_group, 0);
+
+    g_signal_connect (priv->view_btn, "clicked", G_CALLBACK (on_view_clicked), this);
+    g_signal_connect (priv->edit_btn, "clicked", G_CALLBACK (on_edit_clicked), this);
+    g_signal_connect (priv->copy_btn, "clicked", G_CALLBACK (on_copy_clicked), this);
+    g_signal_connect (priv->move_btn, "clicked", G_CALLBACK (on_move_clicked), this);
+    g_signal_connect (priv->mkdir_btn, "clicked", G_CALLBACK (on_mkdir_clicked), this);
+    g_signal_connect (priv->delete_btn, "clicked", G_CALLBACK (on_delete_clicked), this);
+    g_signal_connect (priv->find_btn, "clicked", G_CALLBACK (on_search_clicked), this);
+    g_signal_connect (priv->quit_btn, "clicked", G_CALLBACK (on_quit_clicked), this);
 }
 
 
@@ -809,7 +808,7 @@ static void init (GnomeCmdMainWin *mw)
                               (GtkDestroyNotify) gtk_widget_unref);
     gtk_widget_show (mw->priv->paned);
     gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->paned, TRUE, TRUE, 0);
-    create_buttonbar (mw);
+    mw->create_buttonbar();
 
     mw->priv->file_selector[LEFT] = gnome_cmd_file_selector_new ();
     gtk_widget_ref (mw->priv->file_selector[LEFT]);
@@ -827,9 +826,9 @@ static void init (GnomeCmdMainWin *mw)
     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);
+    main_win->update_toolbar_visibility();
+    main_win->update_cmdline_visibility();
+    main_win->update_buttonbar_visibility();
 
     g_signal_connect (mw, "realize", G_CALLBACK (on_main_win_realize), mw);
     g_signal_connect (mw->fs(LEFT), "dir-changed", G_CALLBACK (on_fs_dir_change), mw);
@@ -854,7 +853,7 @@ static void init (GnomeCmdMainWin *mw)
     mw->fs(RIGHT)->goto_directory(start_dir_right ? start_dir_right : gnome_cmd_data_get_start_dir (RIGHT));
 
     gtk_window_add_accel_group (GTK_WINDOW (main_win), mw->priv->accel_group);
-    gnome_cmd_main_win_focus_file_lists (main_win);
+    main_win->focus_file_lists();
 
     mw->priv->key_snooper_id = gtk_key_snooper_install ((GtkKeySnoopFunc) gnome_cmd_key_snooper, mw);
 }
@@ -916,44 +915,33 @@ GnomeCmdFileSelector *GnomeCmdMainWin::fs(FileSelectorID id)
 }
 
 
-void gnome_cmd_main_win_update_style (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_style()
 {
-    g_return_if_fail (mw != NULL);
-    g_return_if_fail (mw->priv != NULL);
+    g_return_if_fail (priv != NULL);
 
     IMAGE_clear_mime_cache ();
 
-    mw->fs(LEFT)->update_style();
-    mw->fs(RIGHT)->update_style();
+    fs(LEFT)->update_style();
+    fs(RIGHT)->update_style();
 
     if (gnome_cmd_data.cmdline_visibility)
-        gnome_cmd_cmdline_update_style (GNOME_CMD_CMDLINE (mw->priv->cmdline));
+        gnome_cmd_cmdline_update_style (GNOME_CMD_CMDLINE (priv->cmdline));
 }
 
 
-void gnome_cmd_main_win_focus_cmdline (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::focus_file_lists()
 {
-    if (gnome_cmd_data.cmdline_visibility)
-    {
-        gnome_cmd_cmdline_focus (GNOME_CMD_CMDLINE (mw->priv->cmdline));
-        mw->priv->focused_widget = mw->priv->cmdline;
-    }
-}
-
+    fs(ACTIVE)->set_active(TRUE);
+    fs(INACTIVE)->set_active(FALSE);
 
-void gnome_cmd_main_win_focus_file_lists (GnomeCmdMainWin *mw)
-{
-    mw->fs(ACTIVE)->set_active(TRUE);
-    mw->fs(INACTIVE)->set_active(FALSE);
-
-    mw->priv->focused_widget = mw->priv->file_selector[mw->priv->current_fs];
+    priv->focused_widget = priv->file_selector[priv->current_fs];
 }
 
 
-void gnome_cmd_main_win_refocus (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::refocus()
 {
-    if (mw->priv->focused_widget)
-        gtk_widget_grab_focus (mw->priv->focused_widget);
+    if (priv->focused_widget)
+        gtk_widget_grab_focus (priv->focused_widget);
 }
 
 
@@ -993,7 +981,7 @@ gboolean GnomeCmdMainWin::key_pressed(GdkEventKey *event)
             case GDK_h:
                 gnome_cmd_data.filter_settings.hidden = !gnome_cmd_data.filter_settings.hidden;
                 gnome_cmd_style_create ();
-                gnome_cmd_main_win_update_style (this);
+                update_style();
                 gnome_cmd_data.save();
                 return TRUE;
         }
@@ -1031,7 +1019,7 @@ gboolean GnomeCmdMainWin::key_pressed(GdkEventKey *event)
                     priv->file_selector[RIGHT] = swap;
 
                     // refocus ACTIVE fs
-                    gnome_cmd_main_win_focus_file_lists (this);
+                    focus_file_lists();
 
                     // update cmdline only for different directories
                     if (fs1->get_directory()!=fs2->get_directory())
@@ -1144,26 +1132,20 @@ static void gnome_cmd_main_win_real_switch_fs (GnomeCmdMainWin *mw, GnomeCmdFile
 }
 
 
-GnomeCmdCmdline *gnome_cmd_main_win_get_cmdline (GnomeCmdMainWin *mw)
+GnomeCmdCmdline *GnomeCmdMainWin::get_cmdline()
 {
-    g_return_val_if_fail (GNOME_CMD_IS_MAIN_WIN (mw), NULL);
-
-    return GNOME_CMD_CMDLINE (mw->priv->cmdline);
+    return GNOME_CMD_CMDLINE (priv->cmdline);
 }
 
 
-void gnome_cmd_main_win_update_bookmarks (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_bookmarks()
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
-    gnome_cmd_main_menu_update_bookmarks (GNOME_CMD_MAIN_MENU (mw->priv->menubar));
+    gnome_cmd_main_menu_update_bookmarks (GNOME_CMD_MAIN_MENU (priv->menubar));
 }
 
 
-void gnome_cmd_main_win_update_toolbar_visibility (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_toolbar_visibility()
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
     static GnomeUIInfo toolbar_uiinfo[] =
     {
         GNOMEUIINFO_ITEM_STOCK(NULL, _("Refresh"), view_refresh, GTK_STOCK_REFRESH),
@@ -1190,121 +1172,113 @@ void gnome_cmd_main_win_update_toolbar_visibility (GnomeCmdMainWin *mw)
 
     if (gnome_cmd_data.toolbar_visibility)
     {
-        create_toolbar (mw, toolbar_uiinfo);
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->toolbar, FALSE, TRUE, 0);
-        gtk_box_reorder_child (GTK_BOX (mw->priv->vbox), mw->priv->toolbar, 2);
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->toolbar_sep, FALSE, TRUE, 0);
-        gtk_box_reorder_child (GTK_BOX (mw->priv->vbox), mw->priv->toolbar_sep, 3);
+        create_toolbar (this, toolbar_uiinfo);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->toolbar, FALSE, TRUE, 0);
+        gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->toolbar, 2);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->toolbar_sep, FALSE, TRUE, 0);
+        gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->toolbar_sep, 3);
     }
     else
     {
-        if (mw->priv->toolbar)
-            gtk_widget_destroy (mw->priv->toolbar);
-        if (mw->priv->toolbar_sep)
-            gtk_widget_destroy (mw->priv->toolbar_sep);
-        mw->priv->toolbar = NULL;
-        mw->priv->toolbar_sep = NULL;
+        if (priv->toolbar)
+            gtk_widget_destroy (priv->toolbar);
+        if (priv->toolbar_sep)
+            gtk_widget_destroy (priv->toolbar_sep);
+        priv->toolbar = NULL;
+        priv->toolbar_sep = NULL;
     }
 
-    update_drop_con_button (mw, mw->fs(ACTIVE));
+    update_drop_con_button (this, fs(ACTIVE));
 }
 
 
-void gnome_cmd_main_win_update_buttonbar_visibility (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_buttonbar_visibility()
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
     if (gnome_cmd_data.buttonbar_visibility)
     {
-        create_buttonbar (mw);
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->buttonbar_sep, FALSE, TRUE, 0);
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->buttonbar, FALSE, TRUE, 0);
+        create_buttonbar();
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->buttonbar_sep, FALSE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->buttonbar, FALSE, TRUE, 0);
     }
     else
     {
-        if (mw->priv->buttonbar)
-            gtk_widget_destroy (mw->priv->buttonbar);
-        if (mw->priv->buttonbar_sep)
-            gtk_widget_destroy (mw->priv->buttonbar_sep);
-        mw->priv->buttonbar = NULL;
-        mw->priv->buttonbar_sep = NULL;
+        if (priv->buttonbar)
+            gtk_widget_destroy (priv->buttonbar);
+        if (priv->buttonbar_sep)
+            gtk_widget_destroy (priv->buttonbar_sep);
+        priv->buttonbar = NULL;
+        priv->buttonbar_sep = NULL;
     }
 }
 
 
-void gnome_cmd_main_win_update_cmdline_visibility (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_cmdline_visibility()
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
     if (gnome_cmd_data.cmdline_visibility)
     {
         gint pos = 3;
-        mw->priv->cmdline_sep = create_separator (FALSE);
-        mw->priv->cmdline = gnome_cmd_cmdline_new ();
-        gtk_widget_ref (mw->priv->cmdline);
-        gtk_object_set_data_full (GTK_OBJECT (main_win), "cmdline", mw->priv->cmdline,
+        priv->cmdline_sep = create_separator (FALSE);
+        priv->cmdline = gnome_cmd_cmdline_new ();
+        gtk_widget_ref (priv->cmdline);
+        gtk_object_set_data_full (GTK_OBJECT (main_win), "cmdline", priv->cmdline,
                                   (GtkDestroyNotify) gtk_widget_unref);
-        gtk_widget_show (mw->priv->cmdline);
+        gtk_widget_show (priv->cmdline);
         if (gnome_cmd_data.toolbar_visibility)
             pos += 2;
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->cmdline_sep, FALSE, TRUE, 0);
-        gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->cmdline, FALSE, TRUE, 1);
-        gtk_box_reorder_child (GTK_BOX (mw->priv->vbox), mw->priv->cmdline_sep, pos);
-        gtk_box_reorder_child (GTK_BOX (mw->priv->vbox), mw->priv->cmdline, pos+1);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->cmdline_sep, FALSE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX (priv->vbox), priv->cmdline, FALSE, TRUE, 1);
+        gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->cmdline_sep, pos);
+        gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->cmdline, pos+1);
     }
     else
     {
-        if (mw->priv->cmdline)
-            gtk_widget_destroy (mw->priv->cmdline);
-        if (mw->priv->cmdline_sep)
-            gtk_widget_destroy (mw->priv->cmdline_sep);
-        mw->priv->cmdline = NULL;
-        mw->priv->cmdline_sep = NULL;
+        if (priv->cmdline)
+            gtk_widget_destroy (priv->cmdline);
+        if (priv->cmdline_sep)
+            gtk_widget_destroy (priv->cmdline_sep);
+        priv->cmdline = NULL;
+        priv->cmdline_sep = NULL;
     }
 }
 
 
-void gnome_cmd_main_win_update_list_orientation (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::update_list_orientation()
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
     gint pos = 2;
 
-    gtk_widget_ref (mw->priv->file_selector[LEFT]);
-    gtk_widget_ref (mw->priv->file_selector[RIGHT]);
-    gtk_container_remove (GTK_CONTAINER (mw->priv->paned), mw->priv->file_selector[LEFT]);
-    gtk_container_remove (GTK_CONTAINER (mw->priv->paned), mw->priv->file_selector[RIGHT]);
+    gtk_widget_ref (priv->file_selector[LEFT]);
+    gtk_widget_ref (priv->file_selector[RIGHT]);
+    gtk_container_remove (GTK_CONTAINER (priv->paned), priv->file_selector[LEFT]);
+    gtk_container_remove (GTK_CONTAINER (priv->paned), priv->file_selector[RIGHT]);
 
-    gtk_object_destroy (GTK_OBJECT (mw->priv->paned));
+    gtk_object_destroy (GTK_OBJECT (priv->paned));
 
-    mw->priv->paned = gnome_cmd_data.list_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
+    priv->paned = gnome_cmd_data.list_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
 
-    gtk_widget_ref (mw->priv->paned);
-    gtk_object_set_data_full (GTK_OBJECT (main_win), "paned", mw->priv->paned, (GtkDestroyNotify) gtk_widget_unref);
-    gtk_widget_show (mw->priv->paned);
+    gtk_widget_ref (priv->paned);
+    gtk_object_set_data_full (*this, "paned", priv->paned, (GtkDestroyNotify) gtk_widget_unref);
+    gtk_widget_show (priv->paned);
 
-    gtk_paned_pack1 (GTK_PANED (mw->priv->paned), mw->priv->file_selector[LEFT], TRUE, TRUE);
-    gtk_paned_pack2 (GTK_PANED (mw->priv->paned), mw->priv->file_selector[RIGHT], TRUE, TRUE);
+    gtk_paned_pack1 (GTK_PANED (priv->paned), priv->file_selector[LEFT], TRUE, TRUE);
+    gtk_paned_pack2 (GTK_PANED (priv->paned), priv->file_selector[RIGHT], TRUE, TRUE);
 
     if (gnome_cmd_data.toolbar_visibility)
         pos += 2;
 
-    gtk_box_pack_start (GTK_BOX (mw->priv->vbox), mw->priv->paned, TRUE, TRUE, 0);
-    gtk_box_reorder_child (GTK_BOX (mw->priv->vbox), mw->priv->paned, pos);
+    gtk_box_pack_start (GTK_BOX (priv->vbox), priv->paned, TRUE, TRUE, 0);
+    gtk_box_reorder_child (GTK_BOX (priv->vbox), priv->paned, pos);
 
-    gtk_widget_unref (mw->priv->file_selector[LEFT]);
-    gtk_widget_unref (mw->priv->file_selector[RIGHT]);
+    gtk_widget_unref (priv->file_selector[LEFT]);
+    gtk_widget_unref (priv->file_selector[RIGHT]);
 
-    g_signal_connect (mw->priv->paned, "button-press-event", G_CALLBACK (on_slide_button_press), mw);
+    g_signal_connect (priv->paned, "button-press-event", G_CALLBACK (on_slide_button_press), this);
     slide_set_50_50 (NULL, NULL);
 }
 
 
-void gnome_cmd_main_win_add_plugin_menu (GnomeCmdMainWin *mw, PluginData *data)
+void GnomeCmdMainWin::add_plugin_menu(PluginData *data)
 {
-    g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
-    gnome_cmd_main_menu_add_plugin_menu (GNOME_CMD_MAIN_MENU (mw->priv->menubar), data);
+    gnome_cmd_main_menu_add_plugin_menu (GNOME_CMD_MAIN_MENU (priv->menubar), data);
 }
 
 
diff --git a/src/gnome-cmd-main-win.h b/src/gnome-cmd-main-win.h
index d788108..2b9916e 100644
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -38,6 +38,12 @@ struct GnomeCmdMainWin
 {
     GnomeApp parent;
 
+  public:       //  FIXME:  change to private
+
+    void create_buttonbar();
+
+  public:
+
     struct Private;
 
     Private *priv;
@@ -56,28 +62,26 @@ struct GnomeCmdMainWin
     void set_equal_panes();
     GnomeCmdState *get_state();
     void set_cap_state(gboolean state);
-};
-
 
-extern GnomeCmdMainWin *main_win;
+    GnomeCmdCmdline *get_cmdline();
 
+    void focus_file_lists();
+    void refocus();
 
-GtkWidget *gnome_cmd_main_win_new ();
+    void update_style();
+    void update_bookmarks();
+    void update_toolbar_visibility();
+    void update_cmdline_visibility();
+    void update_buttonbar_visibility();
+    void update_list_orientation();
 
-GnomeCmdCmdline *gnome_cmd_main_win_get_cmdline (GnomeCmdMainWin *mw);
+    void add_plugin_menu(PluginData *data);
+};
 
-void gnome_cmd_main_win_update_style (GnomeCmdMainWin *mw);
 
-void gnome_cmd_main_win_focus_cmdline (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_focus_file_lists (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_refocus (GnomeCmdMainWin *mw);
+GtkWidget *gnome_cmd_main_win_new ();
 
-void gnome_cmd_main_win_update_bookmarks (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_update_toolbar_visibility (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_update_cmdline_visibility (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_update_buttonbar_visibility (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_update_list_orientation (GnomeCmdMainWin *mw);
 
-void gnome_cmd_main_win_add_plugin_menu (GnomeCmdMainWin *mw, PluginData *data);
+extern GnomeCmdMainWin *main_win;
 
 #endif // __GNOME_CMD_MAIN_WIN_H__
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 3567c93..15935fc 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -1712,7 +1712,7 @@ static void on_options_dialog_close (GtkButton *button, GtkWidget *dialog)
     gtk_widget_destroy (dialog);
 
     gnome_cmd_style_create ();
-    gnome_cmd_main_win_update_style (main_win);
+    main_win->update_style();
 
     gnome_cmd_data.save();
 }
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 75aa917..bb36d43 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1327,7 +1327,7 @@ void view_toolbar (GtkMenuItem *menuitem, gpointer not_used)
 
     GtkCheckMenuItem *checkitem = (GtkCheckMenuItem *) menuitem;
     gnome_cmd_data.toolbar_visibility = checkitem->active;
-    gnome_cmd_main_win_update_toolbar_visibility (main_win);
+    main_win->update_toolbar_visibility();
 }
 
 
@@ -1337,7 +1337,7 @@ void view_buttonbar (GtkMenuItem *menuitem, gpointer not_used)
 
     GtkCheckMenuItem *checkitem = (GtkCheckMenuItem *) menuitem;
     gnome_cmd_data.buttonbar_visibility = checkitem->active;
-    gnome_cmd_main_win_update_buttonbar_visibility (main_win);
+    main_win->update_buttonbar_visibility();
 }
 
 
@@ -1347,7 +1347,7 @@ void view_cmdline (GtkMenuItem *menuitem, gpointer not_used)
 
     GtkCheckMenuItem *checkitem = (GtkCheckMenuItem *) menuitem;
     gnome_cmd_data.cmdline_visibility = checkitem->active;
-    gnome_cmd_main_win_update_cmdline_visibility (main_win);
+    main_win->update_cmdline_visibility();
 }
 
 
diff --git a/src/gnome-cmd-xfer.cc b/src/gnome-cmd-xfer.cc
index 5e77846..3f7cd3b 100644
--- a/src/gnome-cmd-xfer.cc
+++ b/src/gnome-cmd-xfer.cc
@@ -198,7 +198,7 @@ static gint async_xfer_callback (GnomeVFSAsyncHandle *handle, GnomeVFSXferProgre
 
     if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED)
     {
-        gnome_cmd_main_win_focus_file_lists (main_win);
+        main_win->focus_file_lists();
         data->done = TRUE;
     }
 
@@ -290,7 +290,7 @@ static gboolean update_xfer_gui_func (XferData *data)
         if (data->to_dir)
         {
             gnome_cmd_dir_relist_files (data->to_dir, FALSE);
-            gnome_cmd_main_win_focus_file_lists (main_win);
+            main_win->focus_file_lists();
             gnome_cmd_dir_unref (data->to_dir);
             data->to_dir = NULL;
         }
diff --git a/src/plugin_manager.cc b/src/plugin_manager.cc
index ed81b95..c13ba37 100644
--- a/src/plugin_manager.cc
+++ b/src/plugin_manager.cc
@@ -126,7 +126,7 @@ static void activate_plugin (PluginData *data)
     GnomeCmdState *state = main_win->get_state();
     data->menu = gnome_cmd_plugin_create_main_menu (data->plugin, state);
     if (data->menu)
-        gnome_cmd_main_win_add_plugin_menu (main_win, data);
+        main_win->add_plugin_menu(data);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]