Revision: 1329 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1329&view=re... Author: colombanw Date: 2010-05-01 17:49:41 +0000 (Sat, 01 May 2010)
Log Message: ----------- GeanyGenDoc: Implement and use Glade-style frames
This makes the UI quite nicer and more consistent with both Geany and GNOME.
Modified Paths: -------------- trunk/geanygendoc/src/Makefile.am trunk/geanygendoc/src/ggd-plugin.c
Added Paths: ----------- trunk/geanygendoc/src/ggd-widget-frame.c trunk/geanygendoc/src/ggd-widget-frame.h
Modified: trunk/geanygendoc/src/Makefile.am =================================================================== --- trunk/geanygendoc/src/Makefile.am 2010-05-01 17:49:07 UTC (rev 1328) +++ trunk/geanygendoc/src/Makefile.am 2010-05-01 17:49:41 UTC (rev 1329) @@ -9,7 +9,8 @@ ggd-tag-utils.c \ ggd-options.c \ ggd-plugin.c \ - ggd-utils.c + ggd-utils.c \ + ggd-widget-frame.c noinst_HEADERS = ggd.h \ ggd-doc-setting.h \ ggd-doc-type.h \ @@ -20,7 +21,8 @@ ggd-macros.h \ ggd-options.h \ ggd-plugin.h \ - ggd-utils.h + ggd-utils.h \ + ggd-widget-frame.h geanygendoc_la_LDFLAGS = -module -avoid-version geanygendoc_la_LIBADD = @GEANY_LIBS@ \ @GLIB_LIBS@ \
Modified: trunk/geanygendoc/src/ggd-plugin.c =================================================================== --- trunk/geanygendoc/src/ggd-plugin.c 2010-05-01 17:49:07 UTC (rev 1328) +++ trunk/geanygendoc/src/ggd-plugin.c 2010-05-01 17:49:41 UTC (rev 1329) @@ -424,6 +424,8 @@
/* --- Configuration dialog --- */
+#include "ggd-widget-frame.h" + static void conf_dialog_response_handler (GtkDialog *dialog, gint response_id, @@ -483,7 +485,7 @@ widget); gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); /* environ editor */ - widget = gtk_frame_new (_("Global environment")); + widget = ggd_frame_new (_("Global environment")); ui_widget_set_tooltip_text (widget, _("Global environment overrides and " "additions. This environment will be " "merged with the filetype-specific "
Added: trunk/geanygendoc/src/ggd-widget-frame.c =================================================================== --- trunk/geanygendoc/src/ggd-widget-frame.c (rev 0) +++ trunk/geanygendoc/src/ggd-widget-frame.c 2010-05-01 17:49:41 UTC (rev 1329) @@ -0,0 +1,119 @@ +/* + * + * GeanyGenDoc, a Geany plugin to ease generation of source code documentation + * Copyright (C) 2010 Colomban Wendling ban@herbesfolles.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +/* + * A GtkFrame subclass that reproduce Glade's frames. + */ + +#include <gtk/gtk.h> + +#include "ggd-widget-frame.h" + + +struct _GgdFramePrivate +{ + PangoAttrList *label_attr_list; + GtkWidget *alignment; +}; + + +G_DEFINE_TYPE (GgdFrame, ggd_frame, GTK_TYPE_FRAME) + + +static void +ggd_frame_add (GtkContainer *container, + GtkWidget *child) +{ + GgdFrame *self = GGD_FRAME (container); + + /* chain additions to the alignment if we aren't adding it */ + if (child == self->priv->alignment) { + GTK_CONTAINER_CLASS (ggd_frame_parent_class)->add (container, child); + } else { + container = GTK_CONTAINER (self->priv->alignment); + GTK_CONTAINER_GET_CLASS (container)->add (container, child); + } +} + +static void +ggd_frame_finalize (GObject *object) +{ + GgdFrame *self = GGD_FRAME (object); + + pango_attr_list_unref (self->priv->label_attr_list); + + G_OBJECT_CLASS (ggd_frame_parent_class)->finalize (object); +} + +static void +ggd_frame_class_init (GgdFrameClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); + + object_class->finalize = ggd_frame_finalize; + container_class->add = ggd_frame_add; + + g_type_class_add_private (klass, sizeof (GgdFramePrivate)); +} + +static void +ggd_frame_label_notify (GObject *object, + GParamSpec *pspec, + gpointer data) +{ + GgdFrame *self = GGD_FRAME (object); + GtkWidget *label; + + label = gtk_frame_get_label_widget (GTK_FRAME (self)); + if (label) { + gtk_label_set_attributes (GTK_LABEL (label), self->priv->label_attr_list); + } +} + +static void +ggd_frame_init (GgdFrame *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GGD_FRAME_TYPE, + GgdFramePrivate); + + /* set-up the frame attributes */ + gtk_frame_set_shadow_type (GTK_FRAME (self), GTK_SHADOW_NONE); + /* set-up fake child */ + self->priv->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); + gtk_alignment_set_padding (GTK_ALIGNMENT(self->priv->alignment), 0, 0, 12, 0); + gtk_container_add (GTK_CONTAINER (self), self->priv->alignment); + gtk_widget_show (self->priv->alignment); + /* set-up the label's attributes */ + self->priv->label_attr_list = pango_attr_list_new (); + pango_attr_list_insert (self->priv->label_attr_list, + pango_attr_weight_new (PANGO_WEIGHT_BOLD)); + + g_signal_connect (self, "notify::label", + G_CALLBACK (ggd_frame_label_notify), NULL); +} + + +GtkWidget * +ggd_frame_new (const gchar *label) +{ + return g_object_new (GGD_FRAME_TYPE, "label", label, NULL); +}
Added: trunk/geanygendoc/src/ggd-widget-frame.h =================================================================== --- trunk/geanygendoc/src/ggd-widget-frame.h (rev 0) +++ trunk/geanygendoc/src/ggd-widget-frame.h 2010-05-01 17:49:41 UTC (rev 1329) @@ -0,0 +1,63 @@ +/* + * + * GeanyGenDoc, a Geany plugin to ease generation of source code documentation + * Copyright (C) 2010 Colomban Wendling ban@herbesfolles.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +#ifndef H_GGD_WIDGET_FRAME +#define H_GGD_WIDGET_FRAME + +#include <gtk/gtk.h> + +#include "ggd-macros.h" + +G_BEGIN_DECLS +GGD_BEGIN_PLUGIN_API + + +#define GGD_FRAME_TYPE (ggd_frame_get_type ()) +#define GGD_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGD_FRAME_TYPE, GgdFrame)) +#define GGD_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GGD_FRAME_TYPE, GgdFrameClass)) +#define GGD_IS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGD_FRAME_TYPE)) +#define GGD_IS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGD_FRAME_TYPE)) + + +typedef struct _GgdFrame GgdFrame; +typedef struct _GgdFrameClass GgdFrameClass; +typedef struct _GgdFramePrivate GgdFramePrivate; + +struct _GgdFrame +{ + GtkFrame parent; + + GgdFramePrivate *priv; +}; + +struct _GgdFrameClass +{ + GtkFrameClass parent_class; +}; + + +GType ggd_frame_get_type (void); +GtkWidget *ggd_frame_new (const gchar *label); + + +GGD_END_PLUGIN_API +G_END_DECLS + +#endif /* guard */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org