[gnome-commander] GnomeCmdConList: more C++ rework
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] GnomeCmdConList: more C++ rework
- Date: Mon, 5 Sep 2011 19:08:42 +0000 (UTC)
commit 70168cd78eea6f7bb999e65d70cb6de332438d46
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Mon Sep 5 21:07:30 2011 +0200
GnomeCmdConList: more C++ rework
src/gnome-cmd-con-list.cc | 41 ++++++++++++++++++-----------------------
src/gnome-cmd-con-list.h | 16 ++++++----------
src/gnome-cmd-data.cc | 6 +++---
src/gnome-cmd-xml-config.cc | 2 +-
4 files changed, 28 insertions(+), 37 deletions(-)
---
diff --git a/src/gnome-cmd-con-list.cc b/src/gnome-cmd-con-list.cc
index af8bff3..b35e0e1 100755
--- a/src/gnome-cmd-con-list.cc
+++ b/src/gnome-cmd-con-list.cc
@@ -184,29 +184,25 @@ GtkType gnome_cmd_con_list_get_type ()
}
-void gnome_cmd_con_list_begin_update (GnomeCmdConList *con_list)
+void GnomeCmdConList::lock()
{
- g_return_if_fail (GNOME_CMD_IS_CON_LIST (con_list));
-
- con_list->priv->update_lock = TRUE;
- con_list->priv->changed = FALSE;
- con_list->priv->ftp_cons_changed = FALSE;
- con_list->priv->device_cons_changed = FALSE;
+ priv->update_lock = TRUE;
+ priv->changed = FALSE;
+ priv->ftp_cons_changed = FALSE;
+ priv->device_cons_changed = FALSE;
}
-void gnome_cmd_con_list_end_update (GnomeCmdConList *con_list)
+void GnomeCmdConList::unlock()
{
- g_return_if_fail (GNOME_CMD_IS_CON_LIST (con_list));
-
- if (con_list->priv->changed)
- gtk_signal_emit (GTK_OBJECT (con_list), signals[LIST_CHANGED]);
- if (con_list->priv->ftp_cons_changed)
- gtk_signal_emit (GTK_OBJECT (con_list), signals[FTP_LIST_CHANGED]);
- if (con_list->priv->device_cons_changed)
- gtk_signal_emit (GTK_OBJECT (con_list), signals[DEVICE_LIST_CHANGED]);
-
- con_list->priv->update_lock = FALSE;
+ if (priv->changed)
+ gtk_signal_emit (*this, signals[LIST_CHANGED]);
+ if (priv->ftp_cons_changed)
+ gtk_signal_emit (*this, signals[FTP_LIST_CHANGED]);
+ if (priv->device_cons_changed)
+ gtk_signal_emit (*this, signals[DEVICE_LIST_CHANGED]);
+
+ priv->update_lock = FALSE;
}
@@ -384,15 +380,14 @@ void gnome_cmd_con_list_set_all_dev (GnomeCmdConList *con_list, GList *dev_cons)
}
-GnomeCmdCon *gnome_cmd_con_list_find_alias (GnomeCmdConList *list, const gchar *alias)
+GnomeCmdCon *GnomeCmdConList::find_alias(const gchar *alias) const
{
- g_return_val_if_fail (list!=NULL, NULL);
g_return_val_if_fail (alias!=NULL, NULL);
- GnomeCmdCon c; // used as reference element to be looked for, no allocation necessary
- c.alias = (gchar *) alias;
+ GnomeCmdCon con; // used as reference element to be looked for, no allocation necessary
+ con.alias = (gchar *) alias;
- GList *elem = g_list_find_custom (list->priv->all_cons, &c, (GCompareFunc) compare_alias);
+ GList *elem = g_list_find_custom (priv->all_cons, &con, (GCompareFunc) compare_alias);
return elem ? (GnomeCmdCon *) elem->data : NULL;
}
diff --git a/src/gnome-cmd-con-list.h b/src/gnome-cmd-con-list.h
index d8e35d2..d779eb8 100755
--- a/src/gnome-cmd-con-list.h
+++ b/src/gnome-cmd-con-list.h
@@ -47,6 +47,12 @@ struct GnomeCmdConList
operator GObject * () const { return G_OBJECT (this); }
operator GtkObject * () const { return GTK_OBJECT (this); }
+
+ void lock();
+ void unlock();
+
+ GnomeCmdCon *find_alias(const gchar *alias) const;
+ gboolean has_alias(const gchar *alias) const { return find_alias(alias)!=NULL; }
};
struct GnomeCmdConListClass
@@ -71,9 +77,6 @@ inline GnomeCmdConList *gnome_cmd_con_list_get ()
return (GnomeCmdConList *) gnome_cmd_data_get_con_list ();
}
-void gnome_cmd_con_list_begin_update (GnomeCmdConList *list);
-void gnome_cmd_con_list_end_update (GnomeCmdConList *list);
-
void gnome_cmd_con_list_add_ftp (GnomeCmdConList *list, GnomeCmdConFtp *ftp_con);
void gnome_cmd_con_list_remove_ftp (GnomeCmdConList *list, GnomeCmdConFtp *ftp_con);
@@ -90,13 +93,6 @@ GList *gnome_cmd_con_list_get_all_quick_ftp (GnomeCmdConList *list);
GList *gnome_cmd_con_list_get_all_dev (GnomeCmdConList *list);
void gnome_cmd_con_list_set_all_dev (GnomeCmdConList *list, GList *dev_cons);
-GnomeCmdCon *gnome_cmd_con_list_find_alias (GnomeCmdConList *list, const gchar *alias);
-
-inline gboolean gnome_cmd_con_list_has_alias (GnomeCmdConList *list, const gchar *alias)
-{
- return gnome_cmd_con_list_find_alias (list, alias)!=NULL;
-}
-
GnomeCmdCon *gnome_cmd_con_list_get_home (GnomeCmdConList *list);
GnomeCmdCon *gnome_cmd_con_list_get_smb (GnomeCmdConList *list);
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 24ed5de..260a35c 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -297,7 +297,7 @@ inline gboolean load_connections (const gchar *fname)
gchar *alias = gnome_vfs_unescape_string (a[1].c_str(), NULL);
- if (gnome_cmd_con_list_has_alias (gnome_cmd_data.priv->con_list, alias))
+ if (gnome_cmd_data.priv->con_list->has_alias(alias))
g_warning ("%s: ignored duplicate entry: %s", path, alias);
else
{
@@ -1443,7 +1443,7 @@ void GnomeCmdData::load()
priv->con_list = gnome_cmd_con_list_new ();
- gnome_cmd_con_list_begin_update (priv->con_list);
+ priv->con_list->lock();
load_devices ("devices");
if (!gnome_cmd_xml_config_load (xml_cfg_path, *this))
@@ -1478,7 +1478,7 @@ void GnomeCmdData::load()
if (!XML_cfg_has_connections)
load_connections ("connections");
- gnome_cmd_con_list_end_update (priv->con_list);
+ priv->con_list->unlock();
// "/quick-connect/uri" must be read AFTER retrieving anonymous password
diff --git a/src/gnome-cmd-xml-config.cc b/src/gnome-cmd-xml-config.cc
index 7d84bbd..b976ca1 100644
--- a/src/gnome-cmd-xml-config.cc
+++ b/src/gnome-cmd-xml-config.cc
@@ -532,7 +532,7 @@ static void xml_start(GMarkupParseContext *context,
G_MARKUP_COLLECT_INVALID))
{
if (param4) // if remote...
- xml_con = gnome_cmd_con_list_find_alias (gnome_cmd_con_list_get (), param1);
+ xml_con = gnome_cmd_con_list_get()->find_alias(param1);
else
if (strcmp(param1,"Home")==0)
xml_con = gnome_cmd_con_list_get_home (gnome_cmd_con_list_get ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]