summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Pepple <bpepple@fedoraproject.org>2009-10-22 19:35:55 -0400
committerBrian Pepple <bpepple@fedoraproject.org>2009-10-22 19:35:55 -0400
commitacf6aabb5d8e14b3ba7f7f02cbd33ff31ff16047 (patch)
tree44d6808ede16640d91eb51dad1d723ebd20250b7 /src
downloadsonancy-acf6aabb5d8e14b3ba7f7f02cbd33ff31ff16047.tar.gz
sonancy-acf6aabb5d8e14b3ba7f7f02cbd33ff31ff16047.tar.xz
sonancy-acf6aabb5d8e14b3ba7f7f02cbd33ff31ff16047.zip
Initial commit.
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore2
-rw-r--r--src/Makefile.am20
-rw-r--r--src/sonancy-app.c93
-rw-r--r--src/sonancy-app.h62
-rw-r--r--src/sonancy-main.c57
-rw-r--r--src/sonancy-xml.c92
-rw-r--r--src/sonancy-xml.h32
7 files changed, 358 insertions, 0 deletions
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..4584a3f
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,2 @@
+sonancy
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..31ea7a8
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,20 @@
+AM_CPPFLAGS = \
+ -DG_LOG_DOMAIN=\"Sonacy\" \
+ -DPREFIX="\"$(prefix)"\" \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ -DDATADIR=\""$(datadir)"\" \
+ -DLIBDIR=\""$(libdir)"\" \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(SONANCY_CFLAGS)
+
+bin_PROGRAMS = sonancy
+
+sonancy_SOURCES = \
+ sonancy-app.c sonancy-app.h \
+ sonancy-main.c \
+ sonancy-xml.c sonancy-xml.h
+
+sonancy_LDADD= \
+ $(SONANCY_LIBS)
diff --git a/src/sonancy-app.c b/src/sonancy-app.c
new file mode 100644
index 0000000..895b472
--- /dev/null
+++ b/src/sonancy-app.c
@@ -0,0 +1,93 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Brian Pepple
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "sonancy-app.h"
+
+static SonancyApp *default_app = NULL;
+
+G_DEFINE_TYPE (SonancyApp, sonancy_app, G_TYPE_OBJECT);
+
+static void
+on_window_destroy (GtkWidget *widget,
+ SonancyApp *app)
+{
+ app->main_window = NULL;
+
+ gtk_main_quit ();
+}
+
+static void
+sonancy_app_class_init (SonancyAppClass *klass)
+{
+}
+
+static void
+sonancy_app_init (SonancyApp *app)
+{
+
+}
+
+SonancyApp *
+sonancy_app_get_default (int *argc,
+ char ***argv,
+ GError **error)
+{
+ if (!default_app) {
+ gtk_init (argc, argv);
+
+ default_app = g_object_new (SONANCY_TYPE_APP, NULL);
+ }
+
+ return default_app;
+}
+
+gboolean
+sonancy_app_is_running (SonancyApp *app)
+{
+ g_return_val_if_fail (SONANCY_IS_APP (app), FALSE);
+
+ return app->is_running;
+}
+
+gint
+sonancy_app_run (SonancyApp *app)
+{
+ g_return_val_if_fail (SONANCY_IS_APP (app), EXIT_FAILURE);
+ g_return_val_if_fail (!sonancy_app_is_running (app), EXIT_SUCCESS);
+/*
+ app->main_window = sonancy_window_new ();
+ g_signal_connect (app->main_window,
+ "destroy", G_CALLBACK (on_window_destroy),
+ app);
+*/
+ gtk_main ();
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/sonancy-app.h b/src/sonancy-app.h
new file mode 100644
index 0000000..be32a68
--- /dev/null
+++ b/src/sonancy-app.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Brian Pepple
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#ifndef __SONANCY_APP_H__
+#define __SONANCY_APP_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define SONANCY_TYPE_APP (sonancy_app_get_type ())
+#define SONANCY_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SONANCY_TYPE_APP, SonancyApp))
+#define SONANCY_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SONANCY_TYPE_APP))
+#define SONANCY_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SONANCY_TYPE_APP, SonancyAppClass))
+#define SONANCY_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SONANCY_TYPE_APP))
+#define SONANCY_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SONANCY_TYPE_APP, SonancyAppClass))
+
+typedef struct _SonancyApp SonancyApp;
+typedef struct _SonancyAppClass SonancyAppClass;
+
+struct _SonancyApp {
+ GObject parent_instance;
+
+ GtkWidget *main_window;
+
+ guint is_running : 1;
+};
+
+struct _SonancyAppClass {
+ GObjectClass parent_class;
+};
+
+GType sonancy_app_get_type (void) G_GNUC_CONST;
+
+SonancyApp *sonancy_app_get_default (int *argc,
+ char ***argv,
+ GError **error);
+gboolean sonancy_app_is_running (SonancyApp *app);
+gint sonancy_app_run (SonancyApp *app);
+
+G_END_DECLS
+
+#endif /* __SONANCY_APP_H__ */
diff --git a/src/sonancy-main.c b/src/sonancy-main.c
new file mode 100644
index 0000000..778c023
--- /dev/null
+++ b/src/sonancy-main.c
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Brian Pepple
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "sonancy-app.h"
+
+int
+main (int argc,
+ char *argv[])
+{
+ SonancyApp *app;
+ GError *error;
+ int res = EXIT_FAILURE;
+
+ error = NULL;
+ app = sonancy_app_get_default (&argc, &argv, &error);
+ if (error) {
+ g_warning ("Unable to launch %s: %s", PACKAGE, error->message);
+ g_error_free (error);
+ return res;
+ }
+
+ if (sonancy_app_is_running (app))
+ res = EXIT_SUCCESS;
+ else
+ res = sonancy_app_run (app);
+
+ g_object_unref (app);
+
+ return res;
+}
diff --git a/src/sonancy-xml.c b/src/sonancy-xml.c
new file mode 100644
index 0000000..9f55a04
--- /dev/null
+++ b/src/sonancy-xml.c
@@ -0,0 +1,92 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2002-2007 Imendio AB
+ * Copyright (C) 2008 Brian Pepple
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtkbuilder.h>
+
+#include "sonancy-xml.h"
+
+static GtkBuilder *
+xml_get_file (const gchar *filename,
+ const gchar *first_widget,
+ va_list args)
+{
+ GObject **pointer;
+ GtkBuilder *ui = NULL;
+ const char *name;
+ gchar *path;
+ GError *err = NULL;
+
+ /* Create the gtkbuilder */
+ ui = gtk_builder_new ();
+ gtk_builder_set_translation_domain (ui, GETTEXT_PACKAGE);
+ path = g_build_filename (DATADIR, PACKAGE, filename, NULL);
+
+ /* Load the xml file */
+ if (gtk_builder_add_from_file (ui, path, &err) == 0) {
+ g_warning ("XML file error: %s", err->message);
+ g_error_free (err);
+ g_free (path);
+ return NULL;
+ }
+ g_free (path);
+
+ /* Grab the widgets */
+ for (name = first_widget; name; name = va_arg (args, char *)) {
+ pointer = va_arg (args, void *);
+
+ *pointer = gtk_builder_get_object (ui, name);
+
+ if (!*pointer) {
+ g_warning ("Widget '%s' at '%s' is missing.",
+ name, filename);
+ continue;
+ }
+ }
+ return ui;
+}
+
+gboolean
+sonancy_xml_get_file (const gchar *filename,
+ const gchar *first_widget,
+ ...)
+{
+ GtkBuilder *ui;
+ va_list args;
+
+ va_start (args, first_widget);
+
+ ui = xml_get_file (filename, first_widget, args);
+
+ va_end (args);
+
+ if (!ui) {
+ return FALSE;
+ }
+
+ g_object_unref (ui);
+
+ return TRUE;
+}
diff --git a/src/sonancy-xml.h b/src/sonancy-xml.h
new file mode 100644
index 0000000..cc646fd
--- /dev/null
+++ b/src/sonancy-xml.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2002-2007 Imendio AB
+ * Copyright (C) 2008 Brian Pepple
+ *
+ * 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
+ * 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.
+ */
+
+#ifndef __SONANCY_XML_H__
+#define __SONANCY_XML_H__
+
+#include <glib/gtypes.h>
+
+gboolean sonancy_xml_get_file (const gchar *filename,
+ const gchar *first_widget,
+ ...);
+
+#endif /* __SONANCY_XML_H__ */
+