[buoh/cleanups: 1/2] Rename Buoh class to BuohApplication
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh/cleanups: 1/2] Rename Buoh class to BuohApplication
- Date: Sat, 6 Oct 2018 23:21:54 +0000 (UTC)
commit 3b6bc77848c60a9e843a1dae7b40a395577638f0
Author: Jan Tojnar <jtojnar gmail com>
Date: Sun Oct 7 00:52:07 2018 +0200
Rename Buoh class to BuohApplication
For porting to G_DECLARE_FINAL_TYPE, the class needs both a module
and an object name.
In the future, the class is also going to extend GApplication.
src/buoh-add-comic-dialog.c | 4 +-
src/{buoh.c => buoh-application.c} | 94 +++++++++++++++++++-------------------
src/buoh-application.h | 72 +++++++++++++++++++++++++++++
src/buoh-comic-cache.c | 4 +-
src/buoh-comic-list.c | 2 +-
src/buoh-comic-loader.c | 2 +-
src/buoh-comic-manager-date.c | 2 +-
src/buoh-comic-manager.c | 2 +-
src/buoh-comic.c | 2 +-
src/buoh-properties-dialog.c | 2 +-
src/buoh-view-comic.c | 2 +-
src/buoh-view.c | 2 +-
src/buoh-window.c | 8 ++--
src/buoh.h | 74 ------------------------------
src/main.c | 8 ++--
src/meson.build | 2 +-
16 files changed, 140 insertions(+), 142 deletions(-)
---
diff --git a/src/buoh-add-comic-dialog.c b/src/buoh-add-comic-dialog.c
index 922aa95..94e81a6 100644
--- a/src/buoh-add-comic-dialog.c
+++ b/src/buoh-add-comic-dialog.c
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
#include "buoh-add-comic-dialog.h"
-#include "buoh.h"
+#include "buoh-application.h"
struct _BuohAddComicDialog {
GtkDialog parent;
@@ -54,7 +54,7 @@ buoh_add_comic_dialog_init (BuohAddComicDialog *dialog)
{
gtk_widget_init_template (GTK_WIDGET (dialog));
- dialog->model = buoh_get_comics_model (BUOH);
+ dialog->model = buoh_application_get_comics_model (buoh_application_get_instance ());
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view), dialog->model);
diff --git a/src/buoh.c b/src/buoh-application.c
similarity index 81%
rename from src/buoh.c
rename to src/buoh-application.c
index 21319a4..0b92d73 100644
--- a/src/buoh.c
+++ b/src/buoh-application.c
@@ -35,31 +35,31 @@
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-window.h"
#include "buoh-comic.h"
#include "buoh-comic-manager.h"
#include "buoh-comic-manager-date.h"
-struct _BuohPrivate {
+struct _BuohApplicationPrivate {
BuohWindow *window;
GtkTreeModel *comic_list;
gchar *datadir;
};
-static void buoh_init (Buoh *buoh);
-static void buoh_class_init (BuohClass *klass);
-static void buoh_finalize (GObject *object);
+static void buoh_application_init (BuohApplication *buoh);
+static void buoh_application_class_init (BuohApplicationClass *klass);
+static void buoh_application_finalize (GObject *object);
-static GList *buoh_parse_selected (Buoh *buoh);
-static GtkTreeModel *buoh_create_model_from_file (Buoh *buoh);
-static void buoh_save_comic_list (GtkTreeModel *model,
- GtkTreePath *arg1,
- GtkTreeIter *arg2,
- gpointer gdata);
-static void buoh_create_user_dir (Buoh *buoh);
+static GList *buoh_application_parse_selected (BuohApplication *buoh);
+static GtkTreeModel *buoh_application_create_model_from_file (BuohApplication *buoh);
+static void buoh_application_save_comic_list (GtkTreeModel *model,
+ GtkTreePath *arg1,
+ GtkTreeIter *arg2,
+ gpointer gdata);
+static void buoh_application_create_user_dir (BuohApplication *buoh);
-G_DEFINE_TYPE_WITH_PRIVATE (Buoh, buoh, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (BuohApplication, buoh_application, G_TYPE_OBJECT)
void
buoh_debug (const gchar *format, ...)
@@ -82,7 +82,7 @@ buoh_debug (const gchar *format, ...)
}
static GList *
-buoh_parse_selected (Buoh *buoh)
+buoh_application_parse_selected (BuohApplication *buoh)
{
GList *list = NULL;
xmlDocPtr doc;
@@ -126,7 +126,7 @@ buoh_parse_selected (Buoh *buoh)
}
static GtkTreeModel *
-buoh_create_model_from_file (Buoh *buoh)
+buoh_application_create_model_from_file (BuohApplication *buoh)
{
GtkListStore *model = NULL;
GtkTreeIter iter;
@@ -143,7 +143,7 @@ buoh_create_model_from_file (Buoh *buoh)
gchar *filename;
GList *selected = NULL;
- selected = buoh_parse_selected (buoh);
+ selected = buoh_application_parse_selected (buoh);
filename = g_build_filename (COMICS_DIR, "comics.xml", NULL);
@@ -276,7 +276,7 @@ buoh_comic_list_visible (GtkTreeModel *model,
static gboolean
save_comic_list (gpointer gdata)
{
- Buoh *buoh = BUOH_BUOH (gdata);
+ BuohApplication *buoh = BUOH_APPLICATION (gdata);
xmlTextWriterPtr writer;
gchar *filename;
GtkTreeModel *filter;
@@ -327,7 +327,7 @@ save_comic_list (gpointer gdata)
}
static void
-buoh_save_comic_list (GtkTreeModel *model,
+buoh_application_save_comic_list (GtkTreeModel *model,
GtkTreePath *arg1,
GtkTreeIter *arg2,
gpointer gdata)
@@ -336,13 +336,13 @@ buoh_save_comic_list (GtkTreeModel *model,
}
static gboolean
-buoh_create_comics_file (Buoh *buoh, const gchar *filename, const gchar *contents)
+buoh_application_create_comics_file (BuohApplication *buoh, const gchar *filename, const gchar *contents)
{
return g_file_set_contents (filename, contents, -1, NULL);
}
static void
-buoh_create_user_dir (Buoh *buoh)
+buoh_application_create_user_dir (BuohApplication *buoh)
{
gchar *filename;
gchar *cache_dir;
@@ -359,7 +359,7 @@ buoh_create_user_dir (Buoh *buoh)
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
buoh_debug ("User comics file doesn't exist, creating it ...");
- if (!buoh_create_comics_file (buoh, filename, contents)) {
+ if (!buoh_application_create_comics_file (buoh, filename, contents)) {
g_free (filename);
g_error ("Cannot create user's comics list file");
}
@@ -380,34 +380,34 @@ buoh_create_user_dir (Buoh *buoh)
}
static void
-buoh_init (Buoh *buoh)
+buoh_application_init (BuohApplication *buoh)
{
- buoh->priv = buoh_get_instance_private (buoh);
+ buoh->priv = buoh_application_get_instance_private (buoh);
buoh->priv->datadir = g_build_filename (g_get_home_dir (), ".buoh", NULL);
- buoh_create_user_dir (buoh);
+ buoh_application_create_user_dir (buoh);
- buoh->priv->comic_list = buoh_create_model_from_file (buoh);
+ buoh->priv->comic_list = buoh_application_create_model_from_file (buoh);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (buoh->priv->comic_list),
COMIC_LIST_TITLE, GTK_SORT_ASCENDING);
g_signal_connect (G_OBJECT (buoh->priv->comic_list), "row-changed",
- G_CALLBACK (buoh_save_comic_list),
+ G_CALLBACK (buoh_application_save_comic_list),
(gpointer) buoh);
}
static void
-buoh_class_init (BuohClass *klass)
+buoh_application_class_init (BuohApplicationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = buoh_finalize;
+ object_class->finalize = buoh_application_finalize;
}
static void
-buoh_finalize (GObject *object)
+buoh_application_finalize (GObject *object)
{
- Buoh *buoh = BUOH_BUOH (object);
+ BuohApplication *buoh = BUOH_APPLICATION (object);
buoh_debug ("buoh finalize");
@@ -421,33 +421,33 @@ buoh_finalize (GObject *object)
buoh->priv->comic_list = NULL;
}
- if (G_OBJECT_CLASS (buoh_parent_class)->finalize) {
- (* G_OBJECT_CLASS (buoh_parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (buoh_application_parent_class)->finalize) {
+ (* G_OBJECT_CLASS (buoh_application_parent_class)->finalize) (object);
}
}
-Buoh *
-buoh_get_instance (void)
+BuohApplication *
+buoh_application_get_instance (void)
{
- static Buoh *buoh = NULL;
+ static BuohApplication *buoh = NULL;
if (!buoh) {
- buoh = g_object_new (BUOH_TYPE_BUOH, NULL);
+ buoh = g_object_new (BUOH_TYPE_APPLICATION, NULL);
}
return buoh;
}
-Buoh *
-buoh_new (void)
+BuohApplication *
+buoh_application_new (void)
{
- return buoh_get_instance ();
+ return buoh_application_get_instance ();
}
void
-buoh_exit_app (Buoh *buoh)
+buoh_application_exit (BuohApplication *buoh)
{
- g_return_if_fail (BUOH_IS_BUOH (buoh));
+ g_return_if_fail (BUOH_IS_APPLICATION (buoh));
g_object_unref (buoh);
@@ -457,9 +457,9 @@ buoh_exit_app (Buoh *buoh)
}
void
-buoh_create_main_window (Buoh *buoh)
+buoh_application_create_main_window (BuohApplication *buoh)
{
- g_return_if_fail (BUOH_IS_BUOH (buoh));
+ g_return_if_fail (BUOH_IS_APPLICATION (buoh));
if (buoh->priv->window) {
gtk_window_present (GTK_WINDOW (buoh->priv->window));
@@ -469,17 +469,17 @@ buoh_create_main_window (Buoh *buoh)
}
GtkTreeModel *
-buoh_get_comics_model (Buoh *buoh)
+buoh_application_get_comics_model (BuohApplication *buoh)
{
- g_return_val_if_fail (BUOH_IS_BUOH (buoh), NULL);
+ g_return_val_if_fail (BUOH_IS_APPLICATION (buoh), NULL);
return buoh->priv->comic_list;
}
const gchar *
-buoh_get_datadir (Buoh *buoh)
+buoh_application_get_datadir (BuohApplication *buoh)
{
- g_return_val_if_fail (BUOH_IS_BUOH (buoh), NULL);
+ g_return_val_if_fail (BUOH_IS_APPLICATION (buoh), NULL);
return buoh->priv->datadir;
}
diff --git a/src/buoh-application.h b/src/buoh-application.h
new file mode 100644
index 0000000..658481a
--- /dev/null
+++ b/src/buoh-application.h
@@ -0,0 +1,72 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors: Carlos GarcĂa Campos <carlosgc gnome org>
+ */
+
+#ifndef BUOH_APPLICATION_H
+#define BUOH_APPLICATION_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+enum {
+ COMIC_LIST_VISIBLE,
+ COMIC_LIST_TITLE,
+ COMIC_LIST_AUTHOR,
+ COMIC_LIST_LANGUAGE,
+ COMIC_LIST_COMIC_MANAGER,
+ N_COLUMNS
+};
+
+typedef struct _BuohApplication BuohApplication;
+typedef struct _BuohApplicationClass BuohApplicationClass;
+typedef struct _BuohApplicationPrivate BuohApplicationPrivate;
+
+#define BUOH_TYPE_APPLICATION (buoh_application_get_type())
+#define BUOH_APPLICATION(object) (G_TYPE_CHECK_INSTANCE_CAST((object), BUOH_TYPE_APPLICATION,
BuohApplication))
+#define BUOH_APPLICATION_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), BUOH_TYPE_APPLICATION,
BuohApplicationClass))
+#define BUOH_IS_APPLICATION(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), BUOH_TYPE_APPLICATION))
+#define BUOH_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), BUOH_TYPE_APPLICATION))
+#define BUOH_APPLICATION_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), BUOH_TYPE_APPLICATION,
BuohApplicationClass))
+
+struct _BuohApplication {
+ GObject parent;
+ BuohApplicationPrivate *priv;
+};
+
+struct _BuohApplicationClass {
+ GObjectClass parent_class;
+};
+
+GType buoh_application_get_type (void) G_GNUC_CONST;
+BuohApplication *buoh_application_get_instance (void);
+BuohApplication *buoh_application_new (void);
+
+void buoh_application_exit (BuohApplication *buoh);
+
+void buoh_application_create_main_window (BuohApplication *buoh);
+GtkTreeModel *buoh_application_get_comics_model (BuohApplication *buoh);
+const gchar *buoh_application_get_datadir (BuohApplication *buoh);
+
+void buoh_debug (const gchar *format,
+ ...);
+
+
+G_END_DECLS
+
+#endif /* !BUOH_APPLICATION_H */
diff --git a/src/buoh-comic-cache.c b/src/buoh-comic-cache.c
index 41c0082..4121d22 100644
--- a/src/buoh-comic-cache.c
+++ b/src/buoh-comic-cache.c
@@ -23,7 +23,7 @@
#include <fcntl.h>
#include <unistd.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-cache.h"
struct _BuohComicCache {
@@ -52,7 +52,7 @@ static void
buoh_comic_cache_init (BuohComicCache *buoh_comic_cache)
{
buoh_comic_cache->cache_dir =
- g_build_filename (buoh_get_datadir (BUOH), "cache", NULL);
+ g_build_filename (buoh_application_get_datadir (buoh_application_get_instance ()), "cache",
NULL);
buoh_comic_cache->image_hash =
g_hash_table_new_full (g_str_hash,
diff --git a/src/buoh-comic-list.c b/src/buoh-comic-list.c
index 8160844..36c505f 100644
--- a/src/buoh-comic-list.c
+++ b/src/buoh-comic-list.c
@@ -22,7 +22,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-list.h"
struct _BuohComicList {
diff --git a/src/buoh-comic-loader.c b/src/buoh-comic-loader.c
index eae217a..50805fa 100644
--- a/src/buoh-comic-loader.c
+++ b/src/buoh-comic-loader.c
@@ -19,7 +19,7 @@
#include <libsoup/soup.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-loader.h"
/* BuohComicLoaderJob */
diff --git a/src/buoh-comic-manager-date.c b/src/buoh-comic-manager-date.c
index 32ba357..c9d1bb0 100644
--- a/src/buoh-comic-manager-date.c
+++ b/src/buoh-comic-manager-date.c
@@ -20,7 +20,7 @@
#include <glib/gi18n.h>
#include <time.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-manager-date.h"
#define URI_BUFFER 256
diff --git a/src/buoh-comic-manager.c b/src/buoh-comic-manager.c
index 850557e..c5b43f1 100644
--- a/src/buoh-comic-manager.c
+++ b/src/buoh-comic-manager.c
@@ -19,7 +19,7 @@
#include <glib.h>
#include <glib/gi18n.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-manager.h"
#include "buoh-comic-manager-date.h"
diff --git a/src/buoh-comic.c b/src/buoh-comic.c
index e84e759..e730e4c 100644
--- a/src/buoh-comic.c
+++ b/src/buoh-comic.c
@@ -25,7 +25,7 @@
#include <fcntl.h>
#include <unistd.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic.h"
#include "buoh-comic-cache.h"
diff --git a/src/buoh-properties-dialog.c b/src/buoh-properties-dialog.c
index 35b66e3..d45a714 100644
--- a/src/buoh-properties-dialog.c
+++ b/src/buoh-properties-dialog.c
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
#include "buoh-properties-dialog.h"
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-comic-manager-date.h"
#define DATE_BUFFER 256
diff --git a/src/buoh-view-comic.c b/src/buoh-view-comic.c
index 923552d..df99f27 100644
--- a/src/buoh-view-comic.c
+++ b/src/buoh-view-comic.c
@@ -26,7 +26,7 @@
#include <gdk/gdkkeysyms.h>
#include <string.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-view-comic.h"
#include "buoh-comic-loader.h"
diff --git a/src/buoh-view.c b/src/buoh-view.c
index 26c6a39..2dc1ddf 100644
--- a/src/buoh-view.c
+++ b/src/buoh-view.c
@@ -22,7 +22,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-view.h"
#include "buoh-view-comic.h"
#include "buoh-view-message.h"
diff --git a/src/buoh-window.c b/src/buoh-window.c
index 3500ba1..47651f2 100644
--- a/src/buoh-window.c
+++ b/src/buoh-window.c
@@ -28,7 +28,7 @@
#include <gdk/gdkkeysyms.h>
#include <string.h>
-#include "buoh.h"
+#include "buoh-application.h"
#include "buoh-window.h"
#include "buoh-properties-dialog.h"
#include "buoh-add-comic-dialog.h"
@@ -347,7 +347,7 @@ buoh_window_init (BuohWindow *buoh_window)
/* buoh comic list */
buoh_window->priv->comic_list = BUOH_COMIC_LIST (buoh_comic_list_new ());
- model = buoh_get_comics_model (BUOH);
+ model = buoh_application_get_comics_model (buoh_application_get_instance ());
buoh_comic_list_set_model (buoh_window->priv->comic_list, model);
buoh_comic_list_set_view (buoh_window->priv->comic_list, buoh_window->priv->view);
gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (buoh_window->priv->comic_list),
@@ -446,7 +446,7 @@ buoh_window_finalize (GObject *object)
(* G_OBJECT_CLASS (buoh_window_parent_class)->finalize) (object);
}
- buoh_exit_app (BUOH);
+ buoh_application_exit (buoh_application_get_instance ());
}
GtkWidget *
@@ -482,7 +482,7 @@ static void
buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
{
BuohWindow *window = BUOH_WINDOW (gdata);
- GtkTreeModel *model = buoh_get_comics_model (BUOH);
+ GtkTreeModel *model = buoh_application_get_comics_model (buoh_application_get_instance ());
GtkTreeIter iter;
BuohComicManager *cm;
BuohComicManager *current_cm;
diff --git a/src/main.c b/src/main.c
index 3658f35..7d1033e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,12 +27,12 @@
#include <gtk/gtk.h>
-#include "buoh.h"
+#include "buoh-application.h"
gint
main (gint argc, gchar **argv)
{
- Buoh *buoh;
+ BuohApplication *buoh;
/* Initialize the i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
@@ -44,8 +44,8 @@ main (gint argc, gchar **argv)
g_set_application_name (_("Buoh"));
gtk_window_set_default_icon_name ("buoh");
- buoh = buoh_new ();
- buoh_create_main_window (buoh);
+ buoh = buoh_application_new ();
+ buoh_application_create_main_window (buoh);
gtk_main ();
diff --git a/src/meson.build b/src/meson.build
index 81812a1..86f049f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -4,6 +4,7 @@ enum_headers = files(
sources = files(
'buoh-add-comic-dialog.c',
+ 'buoh-application.c',
'buoh-comic-cache.c',
'buoh-comic-list.c',
'buoh-comic-loader.c',
@@ -15,7 +16,6 @@ sources = files(
'buoh-view-message.c',
'buoh-view.c',
'buoh-window.c',
- 'buoh.c',
'main.c',
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]