Revision: 915 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=915&view=rev Author: dmaphy Date: 2009-09-02 21:23:27 +0000 (Wed, 02 Sep 2009)
Log Message: ----------- write make_btn() a bit cleaner
Modified Paths: -------------- trunk/geany-plugins/geanygdb/src/gdb-ui-main.c
Modified: trunk/geany-plugins/geanygdb/src/gdb-ui-main.c =================================================================== --- trunk/geany-plugins/geanygdb/src/gdb-ui-main.c 2009-09-02 20:41:09 UTC (rev 914) +++ trunk/geany-plugins/geanygdb/src/gdb-ui-main.c 2009-09-02 21:23:27 UTC (rev 915) @@ -366,37 +366,52 @@ static const gboolean disable_mnemonics = TRUE;
static GtkWidget * -make_btn(gchar * text, GtkCallback cb, gchar * img, gchar * tip) +make_btn(const gchar *text, GtkCallback cb, gchar *img, gchar *tip) { - GtkWidget *btn; - if (text && disable_mnemonics) + GtkWidget *button; + + if (disable_mnemonics) { gchar *p; - gchar *buf = g_strdup(text); - for (p = buf; *p; p++) + gchar *buffer = g_strdup(text); + + for (p = buffer; *p; p++) { if (*p == '_') { memmove(p, p + 1, strlen(p)); } } - text = buf; - g_free(buf); + + button = gtk_button_new_with_label(buffer); + g_free(buffer); } - btn = text ? gtk_button_new_with_mnemonic(text) : gtk_button_new(); + + else + { + gtk_button_new_with_mnemonic(text); + } + + if (cb) { g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(cb), NULL); } + + if (tip) { gdbui_set_tip(btn, tip); } + + if (img && gdbui_setup.options.show_icons) { gtk_button_set_image(GTK_BUTTON(btn), gtk_image_new_from_stock(img, GTK_ICON_SIZE_BUTTON)); } + + return btn; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.