[glade] Reverted changes that make Glade a GtkApplication because GtkApplication is not portable.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Reverted changes that make Glade a GtkApplication because GtkApplication is not portable.
- Date: Mon, 4 Apr 2011 18:33:20 +0000 (UTC)
commit 234e3a621c037ad02664a98a010e0c5bf7261619
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Mon Apr 4 15:29:04 2011 +0900
Reverted changes that make Glade a GtkApplication because GtkApplication
is not portable.
This reverts commit caf94be4e7f9d7c40cbe28c7eb65a8ca797747cb.
Conflicts:
src/main.c
ChangeLog | 5 -
data/icons/Makefile.am | 2 +-
src/glade-window.c | 5 +-
src/glade-window.h | 2 +-
src/main.c | 198 ++++++++++++++++-------------------------------
5 files changed, 72 insertions(+), 140 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 676d875..a49705f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -382,11 +382,6 @@
this out by just using the "parent" xml attribute and deriving GtkWindow and
disabling all the irrelevant GtkWindow properties.
- * src/main.c, src/glade-window.c: Make Glade use GtkApplication, now Glade is
- a single instance app.
-
- * data/icons/Makefile.am, data/desktop.in.in: Rename the 'glade-3' icon to 'glade'
-
2011-01-28 Tristan Van Berkom <tristanvb openismus com>
* gladeui/glade-xml-utils.h, gladeui/glade-widget-adaptor.[ch], gladeui/glade-widget.[ch]:
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index c660de3..8916049 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -24,4 +24,4 @@ pixmaps_DATA = selector.png devhelp.png \
deprecated-22x22.png
-EXTRA_DIST = $(pixmaps_DATA) glade.ico
+EXTRA_DIST = $(pixmaps_DATA) glade-3.ico
diff --git a/src/glade-window.c b/src/glade-window.c
index 7c130f9..ca5219c 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -148,7 +148,6 @@ static void check_reload_project (GladeWindow * window, GladeProject * project);
static void glade_window_config_save (GladeWindow * window);
-static void glade_window_check_devhelp (GladeWindow * window);
G_DEFINE_TYPE (GladeWindow, glade_window, GTK_TYPE_WINDOW)
@@ -3552,7 +3551,7 @@ glade_window_init (GladeWindow * window)
}
#endif
- glade_window_check_devhelp (window);
+
}
static void
@@ -3594,7 +3593,7 @@ glade_window_new (void)
return g_object_new (GLADE_TYPE_WINDOW, NULL);
}
-static void
+void
glade_window_check_devhelp (GladeWindow * window)
{
g_return_if_fail (GLADE_IS_WINDOW (window));
diff --git a/src/glade-window.h b/src/glade-window.h
index 88c4c57..d3fae18 100644
--- a/src/glade-window.h
+++ b/src/glade-window.h
@@ -56,7 +56,7 @@ void glade_window_new_project (GladeWindow *window);
gboolean glade_window_open_project (GladeWindow *window,
const gchar *path);
-
+void glade_window_check_devhelp (GladeWindow *window);
G_END_DECLS
diff --git a/src/main.c b/src/main.c
index b27d502..048ebc6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,144 +41,39 @@
#define APPLICATION_NAME (_("Glade"))
-#define TYPE_GLADE (glade_get_type())
-#define GLADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GLADE, Glade))
+/* Application arguments */
+static gboolean version = FALSE, without_devhelp = FALSE;
+static gchar **files = NULL;
-typedef struct _Glade Glade;
-typedef struct _GladeClass GladeClass;
+static GOptionEntry option_entries[] = {
+ {"version", '\0', 0, G_OPTION_ARG_NONE, &version,
+ N_("Output version information and exit"), NULL},
-struct _Glade {
- GtkApplication application;
+ {"without-devhelp", '\0', 0, G_OPTION_ARG_NONE, &without_devhelp,
+ N_("Disable Devhelp integration"), NULL},
- GladeWindow *window;
-};
+ {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
+ NULL, N_("[FILE...]")},
-struct _GladeClass {
- GtkApplicationClass application_class;
+ {NULL}
};
+/* Debugging arguments */
+static gboolean verbose = FALSE;
-static GType glade_get_type (void) G_GNUC_CONST;
-static void glade_finalize (GObject *object);
-static void glade_open (GApplication *application,
- GFile **files,
- gint n_files,
- const gchar *hint);
-static void glade_startup (GApplication *application);
-static void glade_activate (GApplication *application);
-
-G_DEFINE_TYPE (Glade, glade, GTK_TYPE_APPLICATION)
-
-static gboolean
-open_new_project (Glade *glade)
-{
- if (!glade_app_get_projects ())
- glade_window_new_project (glade->window);
-
- return FALSE;
-}
-
-static void
-glade_init (Glade *glade)
-{
-
-}
-
-static void
-glade_class_init (GladeClass *glade_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (glade_class);
- GApplicationClass *application_class = G_APPLICATION_CLASS (glade_class);
-
- object_class->finalize = glade_finalize;
-
- application_class->open = glade_open;
- application_class->startup = glade_startup;
- application_class->activate = glade_activate;
-}
-
-static void
-glade_finalize (GObject *object)
-{
- G_OBJECT_CLASS (glade_parent_class)->finalize (object);
-}
-
-static void
-glade_open (GApplication *application,
- GFile **files,
- gint n_files,
- const gchar *hint)
-{
- Glade *glade = GLADE (application);
- gint i;
- gchar *path;
-
- for (i = 0; i < n_files; i++)
- {
- if ((path = g_file_get_path (files[i])) != NULL)
- {
- glade_window_open_project (glade->window, path);
-
- g_free (path);
- }
- }
-}
-
-static void
-glade_startup (GApplication *application)
-{
- Glade *glade = GLADE (application);
-
- glade_setup_log_handlers ();
-
- glade->window = GLADE_WINDOW (glade_window_new ());
- gtk_window_set_application (GTK_WINDOW (glade->window), GTK_APPLICATION (application));
-
- gtk_widget_show (GTK_WIDGET (glade->window));
-
- g_idle_add ((GSourceFunc)open_new_project, glade);
-
- G_APPLICATION_CLASS (glade_parent_class)->startup (application);
-}
-
-static void
-glade_activate (GApplication *application)
-{
-}
-
-
-static Glade *
-glade_new (void)
-{
- Glade *glade =
- g_object_new (TYPE_GLADE,
- "application-id", "org.gnome.Glade",
- "flags", G_APPLICATION_HANDLES_OPEN,
- NULL);
-
- return glade;
-}
-
-/* Version argument parsing */
-static gboolean version = FALSE;
-
-static GOptionEntry option_entries[] = {
- {"version", '\0', 0, G_OPTION_ARG_NONE, &version,
- N_("Output version information and exit"), NULL},
-
+static GOptionEntry debug_option_entries[] = {
+ {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("be verbose"), NULL},
{NULL}
};
int
main (int argc, char *argv[])
{
+ GladeWindow *window;
GOptionContext *option_context;
GOptionGroup *option_group;
GError *error = NULL;
- Glade *glade;
- gint status;
-
- g_type_init ();
+ gboolean opened_project = FALSE;
if (!g_thread_supported ())
g_thread_init (NULL);
@@ -204,6 +99,17 @@ main (int argc, char *argv[])
g_option_context_set_main_group (option_context, option_group);
g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+ option_group = g_option_group_new ("debug",
+ N_("Glade debug options"),
+ N_("Show Glade debug options"),
+ NULL, NULL);
+ g_option_group_add_entries (option_group, debug_option_entries);
+ g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+ g_option_context_add_group (option_context, option_group);
+
+ /* Add Gtk option group */
+ g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
+
/* Parse command line */
if (!g_option_context_parse (option_context, &argc, &argv, &error))
{
@@ -230,6 +136,11 @@ main (int argc, char *argv[])
return 0;
}
+ /* Pass NULL here since we parsed the gtk+ args already...
+ * from this point on we need a DISPLAY variable to be set.
+ */
+ gtk_init (NULL, NULL);
+
/* Check for gmodule support */
if (!g_module_supported ())
{
@@ -238,17 +149,44 @@ main (int argc, char *argv[])
return -1;
}
- gtk_init (&argc, &argv);
-
g_set_application_name (APPLICATION_NAME);
- gtk_window_set_default_icon_name ("glade");
+ gtk_window_set_default_icon_name ("glade-3");
+
+ glade_setup_log_handlers ();
+
+
+ window = GLADE_WINDOW (glade_window_new ());
+
+ if (without_devhelp == FALSE)
+ glade_window_check_devhelp (window);
+
+ gtk_widget_show (GTK_WIDGET (window));
+
+ /* load files specified on commandline */
+ if (files != NULL)
+ {
+ guint i;
+
+ for (i = 0; files[i]; ++i)
+ {
+ if (g_file_test (files[i], G_FILE_TEST_EXISTS) != FALSE)
+ {
+ if (glade_window_open_project (window, files[i]))
+ opened_project = TRUE;
+ }
+ else
+ g_warning (_("Unable to open '%s', the file does not exist.\n"),
+ files[i]);
+ }
+ g_strfreev (files);
+ }
+
+ if (!opened_project)
+ glade_window_new_project (window);
- /* Fire it up */
- glade = glade_new ();
- status = g_application_run (G_APPLICATION (glade), argc, argv);
- g_object_unref (glade);
+ gtk_main ();
- return status;
+ return 0;
}
#ifdef G_OS_WIN32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]