[anjuta] project-wizard: bgo #658758 - 'main' window name is hardwired in Anjuta, not in Glade
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-wizard: bgo #658758 - 'main' window name is hardwired in Anjuta, not in Glade
- Date: Tue, 13 Sep 2011 20:01:04 +0000 (UTC)
commit e538afe80e8f28b980c9f5d3454063f02736e421
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Tue Sep 13 21:57:12 2011 +0200
project-wizard: bgo #658758 - 'main' window name is hardwired in Anjuta, not in Glade
.../templates/anjuta-plugin/src/plugin.c | 13 +++++++++++--
plugins/project-wizard/templates/gtk/src/main.c | 11 +++++++++--
.../templates/gtkapplication/src/application.c | 11 +++++++++--
3 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
index b04fbce..66c0cf6 100644
--- a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
@@ -22,6 +22,7 @@
[+ENDIF+]
[+IF (=(get "HasGladeFile") "1") +]
#define UI_FILE ANJUTA_DATA_DIR"/glade/[+NameHLower+].ui"
+#define TOP_WIDGET "top_widget"
[+ENDIF+]
static gpointer parent_class;
@@ -92,12 +93,20 @@ static gboolean
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
{
- g_warning ("Couldn't load builder file: %s", error->message);
+ g_critical ("Couldn't load builder file: %s", error->message);
g_error_free (error);
return FALSE;
}
- wid = gtk_builder_get_object (builder, "top_widget");
+ wid = gtk_builder_get_object (builder, TOP_WIDGET);
+ if (!wid)
+ {
+ g_critical ("Widget \"%s\" is missing in file %s.",
+ TOP_WIDGET,
+ UI_FILE);
+ return FALSE;
+ }
+
[+NameCLower+]->widget = wid;
anjuta_shell_add_widget (plugin->shell, wid,
"[+PluginClass+]Widget", _("[+PluginClass+] widget"), NULL,
diff --git a/plugins/project-wizard/templates/gtk/src/main.c b/plugins/project-wizard/templates/gtk/src/main.c
index fe7e3c8..4abb953 100644
--- a/plugins/project-wizard/templates/gtk/src/main.c
+++ b/plugins/project-wizard/templates/gtk/src/main.c
@@ -21,6 +21,7 @@
/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/[+NameHLower+]/ui/[+NameHLower+].ui" */
#define UI_FILE "src/[+NameHLower+].ui"
+#define TOP_WINDOW "window"
/* Signal handlers */
/* Note: These may not be declared static because signal autoconnection
@@ -45,7 +46,7 @@ create_window (void)
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
{
- g_warning ("Couldn't load builder file: %s", error->message);
+ g_critical ("Couldn't load builder file: %s", error->message);
g_error_free (error);
}
@@ -53,7 +54,13 @@ create_window (void)
gtk_builder_connect_signals (builder, NULL);
/* Get the window object from the ui file */
- window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+ window = GTK_WIDGET (gtk_builder_get_object (builder, TOP_WINDOW));
+ if (!window)
+ {
+ g_critical ("Widget \"%s\" is missing in file %s.",
+ TOP_WINDOW,
+ UI_FILE);
+ }
g_object_unref (builder);
return window;
diff --git a/plugins/project-wizard/templates/gtkapplication/src/application.c b/plugins/project-wizard/templates/gtkapplication/src/application.c
index 59935c4..a8e99f2 100644
--- a/plugins/project-wizard/templates/gtkapplication/src/application.c
+++ b/plugins/project-wizard/templates/gtkapplication/src/application.c
@@ -18,6 +18,7 @@
/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/[+NameHLower+]/ui/[+NameHLower+].ui" */
#define UI_FILE "src/[+NameHLower+].ui"
+#define TOP_WINDOW "window"
[+ENDIF+]
G_DEFINE_TYPE ([+NameCClass+], [+NameCLower+], GTK_TYPE_APPLICATION);
@@ -36,7 +37,7 @@ static void
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
{
- g_warning ("Couldn't load builder file: %s", error->message);
+ g_critical ("Couldn't load builder file: %s", error->message);
g_error_free (error);
}
@@ -44,7 +45,13 @@ static void
gtk_builder_connect_signals (builder, NULL);
/* Get the window object from the ui file */
- window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+ window = GTK_WIDGET (gtk_builder_get_object (builder, TOP_WINDOW));
+ if (!window)
+ {
+ g_critical ("Widget \"%s\" is missing in file %s.",
+ TOP_WINDOW,
+ UI_FILE);
+ }
g_object_unref (builder);
[+ELSE+]
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]