[gnome-commander] Convert GnomeCmdMainWin struct into C++ class
- From: Piotr Eljasiak <epiotr src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-commander] Convert GnomeCmdMainWin struct into C++ class
- Date: Tue, 21 Jul 2009 19:27:53 +0000 (UTC)
commit a54a5c4181d40683da6b1bfe05509d5d448ad65d
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Tue Jul 21 21:14:39 2009 +0200
Convert GnomeCmdMainWin struct into C++ class
src/cap.cc | 8 ++++----
src/gnome-cmd-main-win.cc | 38 ++++++++++++++++++++++----------------
src/gnome-cmd-main-win.h | 39 ++++++++++++++++++---------------------
src/gnome-cmd-user-actions.cc | 2 +-
4 files changed, 45 insertions(+), 42 deletions(-)
---
diff --git a/src/cap.cc b/src/cap.cc
index c8802c8..4655a2a 100644
--- a/src/cap.cc
+++ b/src/cap.cc
@@ -66,7 +66,7 @@ inline void cut_and_paste (GnomeCmdDir *to)
GTK_SIGNAL_FUNC (on_xfer_done), _files);
_files = NULL;
_fl = NULL;
- gnome_cmd_main_win_set_cap_state (main_win, FALSE);
+ main_win->set_cap_state(FALSE);
}
@@ -82,7 +82,7 @@ inline void copy_and_paste (GnomeCmdDir *to)
GTK_SIGNAL_FUNC (on_xfer_done), _files);
_files = NULL;
_fl = NULL;
- gnome_cmd_main_win_set_cap_state (main_win, FALSE);
+ main_win->set_cap_state(FALSE);
}
@@ -91,7 +91,7 @@ void cap_cut_files (GnomeCmdFileList *fl, GList *files)
update_refs (fl, files);
_type = GNOME_CMD_CUTTED;
- gnome_cmd_main_win_set_cap_state (main_win, TRUE);
+ main_win->set_cap_state(TRUE);
}
@@ -101,7 +101,7 @@ void cap_copy_files (GnomeCmdFileList *fl, GList *files)
update_refs (fl, files);
_type = GNOME_CMD_COPIED;
- gnome_cmd_main_win_set_cap_state (main_win, TRUE);
+ main_win->set_cap_state(TRUE);
}
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index a967c8c..f199c23 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -73,7 +73,15 @@ enum
};
-struct GnomeCmdMainWinPrivate
+struct GnomeCmdMainWinClass
+{
+ GnomeAppClass parent_class;
+
+ void (* switch_fs) (GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs);
+};
+
+
+struct GnomeCmdMainWin::Private
{
FileSelectorID current_fs;
GnomeCmdState state;
@@ -116,10 +124,10 @@ struct GnomeCmdMainWinPrivate
static GnomeAppClass *parent_class = NULL;
-static guint main_win_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0 };
static GtkTooltips *toolbar_tooltips = NULL;
-extern gchar *start_dir_left; //main.cc
-extern gchar *start_dir_right; //main.cc
+extern gchar *start_dir_left; // main.cc
+extern gchar *start_dir_right; // main.cc
static void gnome_cmd_main_win_real_switch_fs (GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs);
@@ -476,14 +484,14 @@ static gboolean on_slide_button_press (GtkWidget *widget, GdkEventButton *event,
static void on_main_win_realize (GtkWidget *widget, GnomeCmdMainWin *mw)
{
- gnome_cmd_main_win_set_equal_panes (mw);
+ mw->set_equal_panes();
gnome_cmd_main_win_get_fs (mw, LEFT)->set_active(TRUE);
gnome_cmd_main_win_get_fs (mw, RIGHT)->set_active(FALSE);
// if (gnome_cmd_data.cmdline_visibility)
// {
- // gchar *dpath = gnome_cmd_file_get_path (GNOME_CMD_FILE (gnome_cmd_main_win_get_fs (mw, LEFT)->get_directory()));
+ // gchar *dpath = gnome_cmd_file_get_path (GNOME_CMD_FILE (mw->fs(LEFT)->get_directory()));
// gnome_cmd_cmdline_set_dir (GNOME_CMD_CMDLINE (mw->priv->cmdline), dpath);
// g_free (dpath);
// }
@@ -637,11 +645,11 @@ static void on_fs_dir_change (GnomeCmdFileSelector *fs, const gchar dir, GnomeCm
}
-static void restore_size_and_pos (GnomeCmdMainWin *mw)
+inline void restore_size_and_pos (GnomeCmdMainWin *mw)
{
gint x, y;
- gtk_widget_set_size_request (GTK_WIDGET (main_win),
+ gtk_widget_set_size_request (*mw,
gnome_cmd_data.main_win_width,
gnome_cmd_data.main_win_height);
@@ -737,7 +745,7 @@ static void class_init (GnomeCmdMainWinClass *klass)
parent_class = (GnomeAppClass *) gtk_type_class (gnome_app_get_type ());
- main_win_signals[SWITCH_FS] =
+ signals[SWITCH_FS] =
gtk_signal_new ("switch-fs",
GTK_RUN_LAST,
G_OBJECT_CLASS_TYPE (object_class),
@@ -759,7 +767,7 @@ static void init (GnomeCmdMainWin *mw)
main_win = GNOME_CMD_MAIN_WIN (mw);
mw->advrename_dlg = NULL;
- mw->priv = g_new0 (GnomeCmdMainWinPrivate, 1);
+ mw->priv = g_new0 (GnomeCmdMainWin::Private, 1);
mw->priv->current_fs = LEFT;
mw->priv->accel_group = gtk_accel_group_new ();
mw->priv->toolbar = NULL;
@@ -1112,7 +1120,7 @@ void gnome_cmd_main_win_switch_fs (GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs
g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
g_return_if_fail (GNOME_CMD_IS_FILE_SELECTOR (fs));
- gtk_signal_emit (GTK_OBJECT (mw), main_win_signals[SWITCH_FS], fs);
+ gtk_signal_emit (*mw, signals[SWITCH_FS], fs);
}
@@ -1318,15 +1326,13 @@ GnomeCmdState *gnome_cmd_main_win_get_state (GnomeCmdMainWin *mw)
}
-void gnome_cmd_main_win_set_cap_state (GnomeCmdMainWin *mw, gboolean state)
+void GnomeCmdMainWin::set_cap_state (gboolean state)
{
- g_return_if_fail (GNOME_CMD_IS_MAIN_WIN (mw));
-
- gtk_widget_set_sensitive (mw->priv->tb_cap_paste_btn, state);
+ gtk_widget_set_sensitive (priv->tb_cap_paste_btn, state);
}
-void gnome_cmd_main_win_set_equal_panes (GnomeCmdMainWin *mw)
+void GnomeCmdMainWin::set_equal_panes()
{
slide_set_50_50 (NULL, NULL);
}
diff --git a/src/gnome-cmd-main-win.h b/src/gnome-cmd-main-win.h
index 72b0527..8968f3b 100644
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -21,40 +21,41 @@
#ifndef __GNOME_CMD_MAIN_WIN_H__
#define __GNOME_CMD_MAIN_WIN_H__
-#define GNOME_CMD_MAIN_WIN(obj) \
- GTK_CHECK_CAST(obj, gnome_cmd_main_win_get_type (), GnomeCmdMainWin)
-#define GNOME_CMD_MAIN_WIN_CLASS(klass) \
- GTK_CHECK_CLASS_CAST(klass, gnome_cmd_main_win_get_type (), GnomeCmdMainWinClass)
-#define GNOME_CMD_IS_MAIN_WIN(obj) \
- GTK_CHECK_TYPE(obj, gnome_cmd_main_win_get_type ())
-
-struct GnomeCmdMainWinPrivate;
-
#include "gnome-cmd-file-selector.h"
#include "gnome-cmd-advrename-dialog.h"
#include "gnome-cmd-cmdline.h"
#include "plugin_manager.h"
+#define GNOME_CMD_MAIN_WIN(obj) GTK_CHECK_CAST(obj, gnome_cmd_main_win_get_type (), GnomeCmdMainWin)
+#define GNOME_CMD_MAIN_WIN_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gnome_cmd_main_win_get_type (), GnomeCmdMainWinClass)
+#define GNOME_CMD_IS_MAIN_WIN(obj) GTK_CHECK_TYPE(obj, gnome_cmd_main_win_get_type ())
+
+
+GtkType gnome_cmd_main_win_get_type ();
+
+
struct GnomeCmdMainWin
{
GnomeApp parent;
+
+ struct Private;
+
+ Private *priv;
+
+ operator GtkObject * () { return GTK_OBJECT (this); }
+ operator GtkWidget * () { return GTK_WIDGET (this); }
+
GnomeCmdAdvrenameDialog *advrename_dlg;
- GnomeCmdMainWinPrivate *priv;
-};
-struct GnomeCmdMainWinClass
-{
- GnomeAppClass parent_class;
+ void set_equal_panes();
- void (* switch_fs) (GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs);
+ void set_cap_state(gboolean state);
};
extern GnomeCmdMainWin *main_win;
-GtkType gnome_cmd_main_win_get_type ();
-
GtkWidget *gnome_cmd_main_win_new ();
GnomeCmdFileSelector *gnome_cmd_main_win_get_fs (GnomeCmdMainWin *mw, FileSelectorID fs);
@@ -82,8 +83,4 @@ void gnome_cmd_main_win_add_plugin_menu (GnomeCmdMainWin *mw, PluginData *data);
GnomeCmdState *gnome_cmd_main_win_get_state (GnomeCmdMainWin *mw);
-void gnome_cmd_main_win_set_cap_state (GnomeCmdMainWin *mw, gboolean state);
-
-void gnome_cmd_main_win_set_equal_panes (GnomeCmdMainWin *mw);
-
#endif // __GNOME_CMD_MAIN_WIN_H__
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 17303e1..6d1a4c8 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1364,7 +1364,7 @@ void view_refresh (GtkMenuItem *menuitem, gpointer not_used)
void view_equal_panes (GtkMenuItem *menuitem, gpointer not_used)
{
- gnome_cmd_main_win_set_equal_panes (GNOME_CMD_MAIN_WIN (main_win));
+ main_win->set_equal_panes();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]