Revision: 5795 http://geany.svn.sourceforge.net/geany/?rev=5795&view=rev Author: colombanw Date: 2011-05-10 23:51:01 +0000 (Tue, 10 May 2011)
Log Message: ----------- Cleanup GeanyWrapLabel a bit
* Do all mandatory initializations in _init() rather than _new(); * Drop geany_wrap_label_set_text() in favor of plain gtk_label_set_text(), making the widget a little simpler and more transparent to the caller.
Modified Paths: -------------- trunk/ChangeLog trunk/src/geanywraplabel.c trunk/src/geanywraplabel.h trunk/src/keybindings.c trunk/src/plugins.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-05-10 23:50:21 UTC (rev 5794) +++ trunk/ChangeLog 2011-05-10 23:51:01 UTC (rev 5795) @@ -2,6 +2,9 @@
* src/plugins.c: Improve the plugin manager dialog a little. + * src/geanywraplabel.c, src/geanywraplabel.h, src/keybindings.c, + src/plugins.c: + Cleanup GeanyWrapLabel a bit.
2011-05-09 Colomban Wendling <colomban(at)geany(dot)org>
Modified: trunk/src/geanywraplabel.c =================================================================== --- trunk/src/geanywraplabel.c 2011-05-10 23:50:21 UTC (rev 5794) +++ trunk/src/geanywraplabel.c 2011-05-10 23:51:01 UTC (rev 5795) @@ -56,6 +56,7 @@ static void geany_wrap_label_size_request (GtkWidget *widget, GtkRequisition *req); static void geany_wrap_label_size_allocate (GtkWidget *widget, GtkAllocation *alloc); static void geany_wrap_label_set_wrap_width (GtkWidget *widget, gsize width); +static void geany_wrap_label_label_notify (GObject *object, GParamSpec *pspec, gpointer data);
G_DEFINE_TYPE(GeanyWrapLabel, geany_wrap_label, GTK_TYPE_LABEL)
@@ -80,6 +81,10 @@
priv = self->priv; priv->wrap_width = 0; + + g_signal_connect(self, "notify::label", G_CALLBACK(geany_wrap_label_label_notify), NULL); + pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(self)), PANGO_WRAP_WORD_CHAR); + gtk_misc_set_alignment(GTK_MISC(self), 0.0, 0.0); }
@@ -106,6 +111,15 @@ }
+/* updates the wrap width when the label text changes */ +static void geany_wrap_label_label_notify(GObject *object, GParamSpec *pspec, gpointer data) +{ + GeanyWrapLabelPrivate *priv = GEANY_WRAP_LABEL_GET_PRIVATE(object); + + geany_wrap_label_set_wrap_width(GTK_WIDGET(object), priv->wrap_width); +} + + /* Forces the height to be the size necessary for the Pango layout, while allowing the * width to be flexible. */ static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req) @@ -128,24 +142,7 @@ }
-void geany_wrap_label_set_text(GtkLabel *label, const gchar *text) -{ - GeanyWrapLabelPrivate *priv = GEANY_WRAP_LABEL_GET_PRIVATE(label); - - gtk_label_set_text(label, text); - geany_wrap_label_set_wrap_width(GTK_WIDGET(label), priv->wrap_width); -} - - GtkWidget *geany_wrap_label_new(const gchar *text) { - GtkWidget *l = g_object_new(GEANY_WRAP_LABEL_TYPE, NULL); - - if (NZV(text)) - gtk_label_set_text(GTK_LABEL(l), text); - - pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(l)), PANGO_WRAP_WORD_CHAR); - gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.0); - - return l; + return g_object_new(GEANY_WRAP_LABEL_TYPE, "label", text, NULL); }
Modified: trunk/src/geanywraplabel.h =================================================================== --- trunk/src/geanywraplabel.h 2011-05-10 23:50:21 UTC (rev 5794) +++ trunk/src/geanywraplabel.h 2011-05-10 23:51:01 UTC (rev 5795) @@ -43,7 +43,6 @@
GType geany_wrap_label_get_type (void); GtkWidget* geany_wrap_label_new (const gchar *text); -void geany_wrap_label_set_text (GtkLabel *label, const gchar *text);
G_END_DECLS
Modified: trunk/src/keybindings.c =================================================================== --- trunk/src/keybindings.c 2011-05-10 23:50:21 UTC (rev 5794) +++ trunk/src/keybindings.c 2011-05-10 23:51:01 UTC (rev 5795) @@ -1788,8 +1788,7 @@ gtk_widget_show_all(switch_dialog); }
- geany_wrap_label_set_text(GTK_LABEL(switch_dialog_label), - DOC_FILENAME(document_get_current())); + gtk_label_set_text(GTK_LABEL(switch_dialog_label), DOC_FILENAME(document_get_current())); }
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2011-05-10 23:50:21 UTC (rev 5794) +++ trunk/src/plugins.c 2011-05-10 23:51:01 UTC (rev 5795) @@ -1129,9 +1129,9 @@ pi = &p->info; /* Translators: <plugin name> <plugin version> */ text = g_strdup_printf(_("%s %s"), pi->name, pi->version); - geany_wrap_label_set_text(GTK_LABEL(pm_widgets.plugin_label), text); - geany_wrap_label_set_text(GTK_LABEL(pm_widgets.description_label), pi->description); - geany_wrap_label_set_text(GTK_LABEL(pm_widgets.author_label), pi->author); + gtk_label_set_text(GTK_LABEL(pm_widgets.plugin_label), text); + gtk_label_set_text(GTK_LABEL(pm_widgets.description_label), pi->description); + gtk_label_set_text(GTK_LABEL(pm_widgets.author_label), pi->author); g_free(text);
pm_update_buttons(p);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.