SF.net SVN: geany: [1702] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Jul 13 15:54:19 UTC 2007
Revision: 1702
http://svn.sourceforge.net/geany/?rev=1702&view=rev
Author: ntrel
Date: 2007-07-13 08:54:16 -0700 (Fri, 13 Jul 2007)
Log Message:
-----------
Add ui_table_add_row() for easily adding widgets to a GtkTable, and
use it in project_new().
Group 'generic' functions related to GTK+ together at the top of
ui_utils.h.
Make sure G_GNUC_NULL_TERMINATED is defined in geany.h.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/geany.h
trunk/src/project.c
trunk/src/ui_utils.c
trunk/src/ui_utils.h
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/ChangeLog 2007-07-13 15:54:16 UTC (rev 1702)
@@ -13,6 +13,13 @@
remove some unnecessary border width.
Add ui->dialog_vbox_new() and ui->frame_new_with_alignment()
functions to the plugin API.
+ * src/ui_utils.h, src/utils.h, src/project.c, src/geany.h,
+ src/ui_utils.c:
+ Add ui_table_add_row() for easily adding widgets to a GtkTable, and
+ use it in project_new().
+ Group 'generic' functions related to GTK+ together at the top of
+ ui_utils.h.
+ Make sure G_GNUC_NULL_TERMINATED is defined in geany.h.
2007-07-12 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/src/geany.h 2007-07-13 15:54:16 UTC (rev 1702)
@@ -210,7 +210,12 @@
};
+/* Useful for some variable argument list functions, e.g. in utils.h */
+#if ! GLIB_CHECK_VERSION(2, 8, 0)
+#define G_GNUC_NULL_TERMINATED
+#endif
+
// implementation in main.c; prototype is here so that all files can use it.
void geany_debug(gchar const *format, ...) G_GNUC_PRINTF (1, 2);
Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/src/project.c 2007-07-13 15:54:16 UTC (rev 1702)
@@ -124,21 +124,14 @@
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
label = gtk_label_new(_("Name:"));
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
e->name = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);
- gtk_table_attach(GTK_TABLE(table), e->name, 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
+ ui_table_add_row(GTK_TABLE(table), 0, label, e->name, NULL);
+
label = gtk_label_new(_("Filename:"));
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
e->file_name = gtk_entry_new();
@@ -151,14 +144,10 @@
bbox = gtk_hbox_new(FALSE, 6);
gtk_box_pack_start_defaults(GTK_BOX(bbox), e->file_name);
gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
- gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 1, 2,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
+ ui_table_add_row(GTK_TABLE(table), 1, label, bbox, NULL);
+
label = gtk_label_new(_("Base path:"));
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
e->base_path = gtk_entry_new();
@@ -167,10 +156,9 @@
"This can be a new path, or an existing directory tree."), NULL);
bbox = ui_path_box_new(_("Choose Project Base Path"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
- gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 2, 3,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
+ ui_table_add_row(GTK_TABLE(table), 2, label, bbox, NULL);
+
gtk_container_add(GTK_CONTAINER(vbox), table);
// signals
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/src/ui_utils.c 2007-07-13 15:54:16 UTC (rev 1702)
@@ -1266,3 +1266,26 @@
else
gtk_widget_hide(app->statusbar);
}
+
+
+/* Pack all GtkWidgets passed after the row argument into a table, using
+ * one widget per cell. The first widget is not expanded, as this is usually
+ * a label. */
+void ui_table_add_row(GtkTable *table, gint row, ...)
+{
+ va_list args;
+ gint i;
+ GtkWidget *widget;
+
+ va_start(args, row);
+ for (i = 0; (widget = va_arg(args, GtkWidget*), widget != NULL); i++)
+ {
+ gint options = (i == 0) ? GTK_FILL : GTK_EXPAND | GTK_FILL;
+
+ gtk_table_attach(GTK_TABLE(table), widget, i, i + 1, row, row + 1,
+ options, 0, 0, 0);
+ }
+ va_end(args);
+}
+
+
Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/src/ui_utils.h 2007-07-13 15:54:16 UTC (rev 1702)
@@ -24,6 +24,33 @@
#ifndef GEANY_UI_UTILS_H
#define GEANY_UI_UTILS_H 1
+/* The following block of functions are more generic functions and closely related to
+ * certain GTK+ widgets. */
+
+void ui_widget_show_hide(GtkWidget *widget, gboolean show);
+
+void ui_widget_modify_font_from_string(GtkWidget *wid, const gchar *str);
+
+GtkWidget *ui_frame_new_with_alignment(const gchar *label_text, GtkWidget **alignment);
+
+GtkWidget *ui_dialog_vbox_new(GtkDialog *dialog);
+
+GtkWidget *ui_button_new_with_image(const gchar *stock_id, const gchar *text);
+
+void ui_hbutton_box_copy_layout(GtkButtonBox *master, GtkButtonBox *copy);
+
+void ui_combo_box_add_to_history(GtkComboBox *combo, const gchar *text);
+
+GtkWidget *ui_path_box_new(const gchar *title, GtkFileChooserAction action, GtkEntry *entry);
+
+void ui_setup_open_button_callback(GtkWidget *open_btn, const gchar *title,
+ GtkFileChooserAction action, GtkEntry *entry);
+
+void ui_table_add_row(GtkTable *table, gint row, ...) G_GNUC_NULL_TERMINATED;
+
+/* End of 'generic' functions */
+
+
// Display text on the statusbar without logging it to the Status window.
void ui_set_statusbar(const gchar *format, ...) G_GNUC_PRINTF (1, 2);
@@ -62,8 +89,6 @@
void ui_close_buttons_toggle();
-void ui_widget_show_hide(GtkWidget *widget, gboolean show);
-
void ui_treeviews_show_hide(gboolean force);
void ui_document_show_hide(gint idx);
@@ -89,22 +114,6 @@
void ui_show_linenumber_margin();
-GtkWidget *ui_frame_new_with_alignment(const gchar *label_text, GtkWidget **alignment);
-
-GtkWidget *ui_dialog_vbox_new(GtkDialog *dialog);
-
-GtkWidget *ui_button_new_with_image(const gchar *stock_id, const gchar *text);
-
-void ui_hbutton_box_copy_layout(GtkButtonBox *master, GtkButtonBox *copy);
-
-void ui_combo_box_add_to_history(GtkComboBox *combo, const gchar *text);
-
-GtkWidget *ui_path_box_new(const gchar *title, GtkFileChooserAction action, GtkEntry *entry);
-
-void ui_setup_open_button_callback(GtkWidget *open_btn, const gchar *title,
- GtkFileChooserAction action, GtkEntry *entry);
-
-
void ui_update_tab_status(gint idx);
@@ -113,8 +122,6 @@
gboolean ui_tree_view_find_next(GtkTreeView *treeview, TVMatchCallback cb);
-void ui_widget_modify_font_from_string(GtkWidget *wid, const gchar *str);
-
void ui_statusbar_showhide(gboolean state);
#endif
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2007-07-13 14:54:11 UTC (rev 1701)
+++ trunk/src/utils.h 2007-07-13 15:54:16 UTC (rev 1702)
@@ -25,10 +25,6 @@
#ifndef GEANY_UTILS_H
#define GEANY_UTILS_H 1
-#if ! GLIB_CHECK_VERSION(2, 8, 0)
-#define G_GNUC_NULL_TERMINATED
-#endif
-
// Returns: TRUE if ptr points to a non-zero value.
#define NZV(ptr) \
((ptr) && (ptr)[0])
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