[anjuta] Migrate anjuta plugin wizard from libglade to GtkBuilder (GnomeBug:530740)



commit d55021cacbb017815736b9b7c21e2aaf9a57c835
Author: Javier Jardón <javierjc1982 gmail com>
Date:   Sun Jul 12 19:46:35 2009 +0200

    Migrate anjuta plugin wizard from libglade to GtkBuilder (GnomeBug:530740)

 plugins/project-wizard/templates/anjuta-plugin.wiz |    6 +-
 .../templates/anjuta-plugin/src/Makefile.am        |    4 +-
 .../templates/anjuta-plugin/src/Makefile.am.tpl    |   12 ++--
 .../templates/anjuta-plugin/src/plugin.c           |   22 +++++--
 .../templates/anjuta-plugin/src/plugin.glade       |   66 --------------------
 .../templates/anjuta-plugin/src/plugin.ui          |   46 ++++++++++---
 .../templates/anjuta-plugin/src/plugin.xml         |   11 +++
 .../templates/translatable-strings.h               |    2 +
 8 files changed, 74 insertions(+), 95 deletions(-)
---
diff --git a/plugins/project-wizard/templates/anjuta-plugin.wiz b/plugins/project-wizard/templates/anjuta-plugin.wiz
index c9f9733..8e5c101 100644
--- a/plugins/project-wizard/templates/anjuta-plugin.wiz
+++ b/plugins/project-wizard/templates/anjuta-plugin.wiz
@@ -34,7 +34,7 @@
 	<property type="string" name="PluginClass" _label="Plugin Class Name:" _description="Plugin class name" default="AnjutaFoobarPlugin" summary="yes" mandatory="yes"/>
 	<property type="string" name="PluginDependencies" _label="Plugin Dependencies:" _description="Comma separated, other plugins that this plugin depends on. It could be either primary interface name or plugin location (library:class)" default="" summary="yes"/>
 	<property type="icon" name="Icon" _label="Icon File:" _description="Icon file for the plugin" summary="yes" mandatory="yes"/>
-	<property type="boolean" name="HasGladeFile" _label="Create glade interface file" _description="Create a template glade interface file" default="1"/>
+	<property type="boolean" name="HasGladeFile" _label="Create Gtk Builder interface file" _description="Create a template Gtk Builder interface file" default="1"/>
 	<property type="boolean" name="HasUI" _label="Plugin has menus or/and toolbars" _description="Whether the plugin has menus or toolbars" default="1"/>
 	<property type="hidden" name="HaveI18n" default="1"/>
 	<property type="hidden" name="HaveSharedlib" default="1"/>
@@ -94,10 +94,10 @@
 			<file source="[+Icon+]" destination="[+NameHLower+].png"/>
 			<file source="plugin.plugin.in" destination="[+NameHLower+].plugin.in"/>
 			[+IF (=(get "HasUI") "1")+]
-				<file source="plugin.ui" destination="[+NameHLower+].ui"/>
+				<file source="plugin.xml" destination="[+NameHLower+].xml"/>
 			[+ENDIF+]
 			[+IF (=(get "HasGladeFile") "1")+]
-				<file source="plugin.glade" destination="[+NameHLower+].glade"/>
+				<file source="plugin.ui" destination="[+NameHLower+].ui"/>
 			[+ENDIF+]
 		</directory>
 		[+IF (=(get "HaveI18n") "1")+]
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am b/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am
index bc94a30..11c662d 100644
--- a/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am
@@ -2,10 +2,10 @@ wizard_filesdir = $(anjuta_data_dir)/project/anjuta-plugin/src
 wizard_files_DATA = \
 	Makefile.am.tpl \
 	plugin.c \
-	plugin.glade \
+	plugin.ui \
 	plugin.h \
 	plugin.plugin.in \
-	plugin.ui
+	plugin.xml
 
 EXTRA_DIST = $(wizard_files_DATA)
 
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am.tpl b/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am.tpl
index 410d6a7..a30d76a 100644
--- a/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am.tpl
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/Makefile.am.tpl
@@ -2,13 +2,13 @@
 # Sample Makefile for a anjuta plugin.
 [+IF (=(get "HasUI") "1")+]
 # Plugin UI file
-[+NameCLower+]_uidir = $(anjuta_ui_dir)
-[+NameCLower+]_ui_DATA =  [+NameHLower+].ui
+[+NameCLower+]_xmldir = $(anjuta_ui_dir)
+[+NameCLower+]_xml_DATA =  [+NameHLower+].xml
 [+ENDIF+]
 [+IF (=(get "HasGladeFile") "1")+]
 # Plugin Glade file
-[+NameCLower+]_gladedir = $(anjuta_glade_dir)
-[+NameCLower+]_glade_DATA =  [+NameHLower+].glade
+[+NameCLower+]_uidir = $(anjuta_glade_dir)
+[+NameCLower+]_ui_DATA =  [+NameHLower+].ui
 [+ENDIF+]
 # Plugin Icon file
 [+NameCLower+]_pixmapsdir = $(anjuta_image_dir)
@@ -57,6 +57,6 @@ lib[+NameCLower+]_la_LIBADD = \
 EXTRA_DIST = \
 	$(plugin_in_files) \
 	$([+NameCLower+]_plugin_DATA) \
-	[+IF (=(get "HasUI") "1")+]$([+NameCLower+]_ui_DATA)[+ENDIF+] \
-	[+IF (=(get "HasGladeFile") "1")+]$([+NameCLower+]_glade_DATA)[+ENDIF+] \
+	[+IF (=(get "HasUI") "1")+]$([+NameCLower+]_xml_DATA)[+ENDIF+] \
+	[+IF (=(get "HasGladeFile") "1")+]$([+NameCLower+]_ui_DATA)[+ENDIF+] \
 	$([+NameCLower+]_pixmaps_DATA)
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
index c749023..4b4ef98 100644
--- a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.c
@@ -18,10 +18,10 @@
 #include "plugin.h"
 
 [+IF (=(get "HasUI") "1") +]
-#define UI_FILE ANJUTA_DATA_DIR"/ui/[+NameHLower+].ui"
+#define XML_FILE ANJUTA_DATA_DIR"/ui/[+NameHLower+].xml"
 [+ENDIF+]
 [+IF (=(get "HasGladeFile") "1") +]
-#define GLADE_FILE ANJUTA_DATA_DIR"/glade/[+NameHLower+].glade"
+#define UI_FILE ANJUTA_DATA_DIR"/glade/[+NameHLower+].ui"
 [+ENDIF+]
 
 static gpointer parent_class;
@@ -67,7 +67,8 @@ static gboolean
 [+ENDIF+]
 [+IF (=(get "HasGladeFile") "1") +]
 	GtkWidget *wid;
-	GladeXML *gxml;
+	GtkBuilder *builder;
+	GError *error;
 [+ENDIF+]
 	[+PluginClass+] *[+NameCLower+];
 	
@@ -84,17 +85,24 @@ static gboolean
 											G_N_ELEMENTS (actions_file),
 											GETTEXT_PACKAGE, TRUE,
 											plugin);
-	[+NameCLower+]->uiid = anjuta_ui_merge (ui, UI_FILE);
+	[+NameCLower+]->uiid = anjuta_ui_merge (ui, XML_FILE);
 [+ENDIF+]
 [+IF (=(get "HasGladeFile") "1") +]
 	/* Add plugin widgets to Shell */
-	gxml = glade_xml_new (GLADE_FILE, "top_widget", NULL);
-	wid = glade_xml_get_widget (gxml, "top_widget");
+	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_error_free (error);
+		return FALSE;
+	}
+
+	wid = gtk_builder_get_object (builder, "top_widget");
 	[+NameCLower+]->widget = wid;
 	anjuta_shell_add_widget (plugin->shell, wid,
 							 "[+PluginClass+]Widget", _("[+PluginClass+] widget"), NULL,
 							 ANJUTA_SHELL_PLACEMENT_BOTTOM, NULL);
-	g_object_unref (gxml);
+	g_object_unref (builder);
 [+ENDIF+]
 	return TRUE;
 }
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.ui b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.ui
index a20e53e..d67da88 100644
--- a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.ui
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.ui
@@ -1,11 +1,35 @@
-[+ autogen5 template +]
-<!--*- xml -*-->
-<ui>
-	<menubar name="MenuMain">
-		<menu name="MenuFile" action="ActionMenuFile">
-			<placeholder name="PlaceholderFileMenus">
-				<menuitem name="SampleAction" action="ActionFileSample" />
-			</placeholder>
-		</menu>
-	</menubar>
-</ui>
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="window1">
+    <property name="title" translatable="yes">window1</property>
+    <child>
+      <object class="GtkHBox" id="top_widget">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTextView" id="textview1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="buffer">textbuffer1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkTextBuffer" id="textbuffer1">
+    <property name="text" translatable="yes">Anjuta Plugin User Interface</property>
+  </object>
+</interface>
diff --git a/plugins/project-wizard/templates/anjuta-plugin/src/plugin.xml b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.xml
new file mode 100644
index 0000000..a20e53e
--- /dev/null
+++ b/plugins/project-wizard/templates/anjuta-plugin/src/plugin.xml
@@ -0,0 +1,11 @@
+[+ autogen5 template +]
+<!--*- xml -*-->
+<ui>
+	<menubar name="MenuMain">
+		<menu name="MenuFile" action="ActionMenuFile">
+			<placeholder name="PlaceholderFileMenus">
+				<menuitem name="SampleAction" action="ActionFileSample" />
+			</placeholder>
+		</menu>
+	</menubar>
+</ui>
diff --git a/plugins/project-wizard/templates/translatable-strings.h b/plugins/project-wizard/templates/translatable-strings.h
index c11ef75..d5f8d17 100644
--- a/plugins/project-wizard/templates/translatable-strings.h
+++ b/plugins/project-wizard/templates/translatable-strings.h
@@ -27,6 +27,8 @@ char *s = N_("Berkeley Software Distribution License (BSD)");
 char *s = N_("Comma separated, other plugins that this plugin depends on. It could be either primary interface name or plugin location (library:class)");
 char *s = N_("Configure external packages");
 char *s = N_("Configure external packages:");
+char *s = N_("Create Gtk Builder interface file");
+char *s = N_("Create a template Gtk Builder interface file");
 char *s = N_("Create a template glade interface file");
 char *s = N_("Create glade interface file");
 char *s = N_("Description:");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]