SF.net SVN: geany: [1701] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Jul 13 14:54:12 UTC 2007


Revision: 1701
          http://svn.sourceforge.net/geany/?rev=1701&view=rev
Author:   ntrel
Date:     2007-07-13 07:54:11 -0700 (Fri, 13 Jul 2007)

Log Message:
-----------
Make Class Builder 'Create Class' dialog use Glade-style frames and
remove some unnecessary border width.
Add ui->dialog_vbox_new() and ui->frame_new_with_alignment()
functions to the plugin API.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/plugins/classbuilder.c
    trunk/src/plugindata.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-13 11:22:47 UTC (rev 1700)
+++ trunk/ChangeLog	2007-07-13 14:54:11 UTC (rev 1701)
@@ -8,6 +8,11 @@
    session files.
  * src/plugins.c:
    Remove init_function_pointers(), use static initializers.
+ * plugins/classbuilder.c, src/plugindata.h, src/plugins.c:
+   Make Class Builder 'Create Class' dialog use Glade-style frames and
+   remove some unnecessary border width.
+   Add ui->dialog_vbox_new() and ui->frame_new_with_alignment()
+   functions to the plugin API.
 
 
 2007-07-12  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c	2007-07-13 11:22:47 UTC (rev 1700)
+++ trunk/plugins/classbuilder.c	2007-07-13 14:54:11 UTC (rev 1701)
@@ -85,6 +85,7 @@
 #define scintilla	plugin_data->sci
 #define templates	plugin_data->templates
 #define utils		plugin_data->utils
+#define ui			plugin_data->ui
 
 
 static struct
@@ -223,7 +224,7 @@
 static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg);
 
 
-VERSION_CHECK(3)
+VERSION_CHECK(4)
 
 PLUGIN_INFO(_("Class Builder"), _("Creates source files for new class types."))
 
@@ -359,6 +360,7 @@
 	CreateClassDialog *cc_dlg;
 	GtkWidget *main_box;
 	GtkWidget *frame;
+	GtkWidget *align;
 	GtkWidget *vbox;
 	GtkWidget *hbox;
 	GtkWidget *label;
@@ -366,165 +368,131 @@
 	cc_dlg = g_new0(CreateClassDialog, 1);
 	cc_dlg->class_type = type;
 
-	cc_dlg->dialog = gtk_dialog_new_with_buttons(_("Create class"),
+	cc_dlg->dialog = gtk_dialog_new_with_buttons(_("Create Class"),
 			GTK_WINDOW(plugin_data->app->window),
 			GTK_DIALOG_MODAL,
 			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 			GTK_STOCK_OK, GTK_RESPONSE_OK,
 			NULL);
-	gtk_container_set_border_width(GTK_CONTAINER(cc_dlg->dialog), 5);
 	g_signal_connect_swapped(G_OBJECT(cc_dlg->dialog), "destroy",
 			G_CALLBACK(g_free), (gpointer)cc_dlg);
 
-	main_box = GTK_DIALOG(cc_dlg->dialog)->vbox;
-	gtk_box_set_spacing(GTK_BOX(main_box), 10);
+	main_box = ui->dialog_vbox_new(GTK_DIALOG(cc_dlg->dialog));
 
-	frame = gtk_frame_new(_("Class"));
+	frame = ui->frame_new_with_alignment(_("Class"), &align);
 	gtk_container_add(GTK_CONTAINER(main_box), frame);
-	gtk_widget_show(frame);
 
 	vbox = gtk_vbox_new(FALSE, 10);
-	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-	gtk_widget_show(vbox);
+	gtk_container_add(GTK_CONTAINER(align), vbox);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	label = gtk_label_new(_("Class name:"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
 
 	cc_dlg->class_name_entry = gtk_entry_new();
 	gtk_box_pack_start(GTK_BOX(hbox), cc_dlg->class_name_entry, TRUE, TRUE, 0);
-	gtk_widget_show(cc_dlg->class_name_entry);
 	g_signal_connect(G_OBJECT(cc_dlg->class_name_entry), "changed",
 			G_CALLBACK(cc_dlg_on_class_name_entry_changed), cc_dlg);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	label = gtk_label_new(_("Header file:"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
 
 	cc_dlg->header_entry = gtk_entry_new();
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->header_entry);
-	gtk_widget_show(cc_dlg->header_entry);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	label = gtk_label_new(_("Source file:"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
 
 	cc_dlg->source_entry = gtk_entry_new();
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->source_entry);
-	gtk_widget_show(cc_dlg->source_entry);
 
-	frame = gtk_frame_new(_("Inheritance"));
+	frame = ui->frame_new_with_alignment(_("Inheritance"), &align);
 	gtk_container_add(GTK_CONTAINER(main_box), frame);
-	gtk_widget_show(frame);
 
 	vbox = gtk_vbox_new(FALSE, 10);
-	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-	gtk_widget_show(vbox);
+	gtk_container_add(GTK_CONTAINER(align), vbox);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	label = gtk_label_new(_("Base class:"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
 
 	cc_dlg->base_name_entry = gtk_entry_new();
 	if (type == GEANY_CLASS_TYPE_GTK)
 		gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_name_entry), "GObject");
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_name_entry);
-	gtk_widget_show(cc_dlg->base_name_entry);
 	g_signal_connect(G_OBJECT(cc_dlg->base_name_entry), "changed",
 			G_CALLBACK(cc_dlg_on_base_name_entry_changed), (gpointer)cc_dlg);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	label = gtk_label_new(_("Base header:"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
 
 	cc_dlg->base_header_entry = gtk_entry_new();
 	if (type == GEANY_CLASS_TYPE_GTK)
 		gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_header_entry), "glib-object.h");
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_header_entry);
-	gtk_widget_show(cc_dlg->base_header_entry);
 
 	cc_dlg->base_header_global_box = gtk_check_button_new_with_label(_("Global"));
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cc_dlg->base_header_global_box), TRUE);
 	gtk_box_pack_end(GTK_BOX(hbox), cc_dlg->base_header_global_box, FALSE, FALSE, 0);
-	gtk_widget_show(cc_dlg->base_header_global_box);
 
 	if (type == GEANY_CLASS_TYPE_GTK)
 	{
 		hbox = gtk_hbox_new(FALSE, 10);
 		gtk_container_add(GTK_CONTAINER(vbox), hbox);
-		gtk_widget_show(hbox);
 
 		label = gtk_label_new(_("Base GType:"));
 		gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-		gtk_widget_show(label);
 
 		cc_dlg->base_gtype_entry = gtk_entry_new();
 		gtk_entry_set_text(GTK_ENTRY(cc_dlg->base_gtype_entry), "GTK_TYPE_OBJECT");
 		gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->base_gtype_entry);
-		gtk_widget_show(cc_dlg->base_gtype_entry);
 	}
 
-	frame = gtk_frame_new(_("Options"));
+	frame = ui->frame_new_with_alignment(_("Options"), &align);
 	gtk_container_add(GTK_CONTAINER(main_box), frame);
-	gtk_widget_show(frame);
 
 	vbox = gtk_vbox_new(FALSE, 10);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-	gtk_widget_show(vbox);
+	gtk_container_add(GTK_CONTAINER(align), vbox);
 
 	hbox = gtk_hbox_new(FALSE, 10);
 	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	gtk_widget_show(hbox);
 
 	cc_dlg->create_constructor_box = gtk_check_button_new_with_label(_("Create constructor"));
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cc_dlg->create_constructor_box), TRUE);
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->create_constructor_box);
-	gtk_widget_show(cc_dlg->create_constructor_box);
 
 	cc_dlg->create_destructor_box = gtk_check_button_new_with_label(_("Create destructor"));
 	gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->create_destructor_box);
-	gtk_widget_show(cc_dlg->create_destructor_box);
 
 	if (type == GEANY_CLASS_TYPE_GTK)
 	{
 		hbox = gtk_hbox_new(FALSE, 10);
 		gtk_container_add(GTK_CONTAINER(vbox), hbox);
-		gtk_widget_show(hbox);
 		g_signal_connect(G_OBJECT(cc_dlg->create_constructor_box), "toggled",
 				G_CALLBACK(cc_dlg_on_set_sensitive_toggled), (gpointer)hbox);
 
 		label = gtk_label_new(_("GTK+ constructor type"));
 		gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-		gtk_widget_show(label);
 
 		cc_dlg->gtk_constructor_type_entry = gtk_entry_new();
 		gtk_entry_set_text(GTK_ENTRY(cc_dlg->gtk_constructor_type_entry), "GObject");
 		gtk_container_add(GTK_CONTAINER(hbox), cc_dlg->gtk_constructor_type_entry);
-		gtk_widget_show(cc_dlg->gtk_constructor_type_entry);
 	}
 
+	gtk_widget_show_all(cc_dlg->dialog);
 	if (gtk_dialog_run(GTK_DIALOG(cc_dlg->dialog)) == GTK_RESPONSE_OK)
 		cc_dlg_on_create_class(cc_dlg);
 

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2007-07-13 11:22:47 UTC (rev 1700)
+++ trunk/src/plugindata.h	2007-07-13 14:54:11 UTC (rev 1701)
@@ -27,7 +27,7 @@
 
 /* The API version should be incremented whenever any plugin data types below are
  * modified. */
-static const gint api_version = 3;
+static const gint api_version = 4;
 
 /* The ABI version should be incremented whenever existing fields in the plugin
  * data types below have to be changed or reordered. It should stay the same if fields
@@ -72,6 +72,7 @@
 typedef struct ScintillaFuncs	ScintillaFuncs;
 typedef struct TemplateFuncs	TemplateFuncs;
 typedef struct UtilsFuncs		UtilsFuncs;
+typedef struct UIUtilsFuncs		UIUtilsFuncs;
 
 /* These are fields and functions owned by Geany.
  * Fields will be appended when needed by plugin authors.
@@ -89,10 +90,14 @@
 	ScintillaFuncs	*sci;
 	TemplateFuncs	*templates;
 	UtilsFuncs		*utils;
+	UIUtilsFuncs	*ui;
 }
 PluginData;
 
 
+/* For more info about these functions, see the main source code.
+ * E.g. for PluginData::document->new_file(), see document_new_file() in document.[hc]. */
+
 struct filetype;
 
 struct DocumentFuncs
@@ -104,18 +109,24 @@
 
 struct ScintillaFuncs
 {
-	void (*set_text) (struct _ScintillaObject *sci, const gchar *text);
+	void	(*set_text) (struct _ScintillaObject *sci, const gchar *text);
 };
 
 struct TemplateFuncs
 {
-	gchar* (*get_template_fileheader) (gint filetype_idx, const gchar *fname);
+	gchar*	(*get_template_fileheader) (gint filetype_idx, const gchar *fname);
 };
 
 struct UtilsFuncs
 {
-	gboolean (*str_equal) (const gchar *a, const gchar *b);
-	gchar* (*str_replace) (gchar *haystack, const gchar *needle, const gchar *replacement);
+	gboolean	(*str_equal) (const gchar *a, const gchar *b);
+	gchar*		(*str_replace) (gchar *haystack, const gchar *needle, const gchar *replacement);
 };
 
+struct UIUtilsFuncs
+{
+	GtkWidget*	(*dialog_vbox_new) (GtkDialog *dialog);
+	GtkWidget*	(*frame_new_with_alignment) (const gchar *label_text, GtkWidget **alignment);
+};
+
 #endif

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2007-07-13 11:22:47 UTC (rev 1700)
+++ trunk/src/plugins.c	2007-07-13 14:54:11 UTC (rev 1701)
@@ -35,6 +35,7 @@
 #include "document.h"
 #include "templates.h"
 #include "sciwrappers.h"
+#include "ui_utils.h"
 
 
 typedef struct Plugin
@@ -54,22 +55,27 @@
 
 static DocumentFuncs doc_funcs = {
 	&document_new_file
-	};
+};
 
 static ScintillaFuncs sci_funcs = {
 	&sci_set_text
-	};
+};
 
 static TemplateFuncs template_funcs = {
 	&templates_get_template_fileheader
-	};
+};
 
 static UtilsFuncs utils_funcs = {
 	&utils_str_equal,
 	&utils_str_replace
-	};
+};
 
+static UIUtilsFuncs uiutils_funcs = {
+	&ui_dialog_vbox_new,
+	&ui_frame_new_with_alignment
+};
 
+
 static void
 init_plugin_data(PluginData *data)
 {
@@ -81,6 +87,7 @@
 	data->sci = &sci_funcs;
 	data->templates = &template_funcs;
 	data->utils = &utils_funcs;
+	data->ui = &uiutils_funcs;
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list