mirror of https://github.com/GNOME/gimp.git
added a hack that allows to get the label_spacing but no label. Useful
2004-05-03 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpframe.c (gimp_frame_new): added a hack that allows to get the label_spacing but no label. Useful when the frame is packed into a GtkExpander. * app/widgets/gimptemplateeditor.c: pack the "Image Comment" frame into a GtkExpander to reduce clutter and dialog size.
This commit is contained in:
parent
6e35e2333f
commit
885609f61f
|
@ -1,3 +1,12 @@
|
|||
2004-05-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpframe.c (gimp_frame_new): added a hack that
|
||||
allows to get the label_spacing but no label. Useful when the frame
|
||||
is packed into a GtkExpander.
|
||||
|
||||
* app/widgets/gimptemplateeditor.c: pack the "Image Comment" frame
|
||||
into a GtkExpander to reduce clutter and dialog size.
|
||||
|
||||
2004-05-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimphelpui.[ch]: added gimp_help_id_quark()
|
||||
|
|
|
@ -198,9 +198,11 @@ gimp_template_editor_constructor (GType type,
|
|||
GtkWidget *xres;
|
||||
GtkWidget *yres;
|
||||
GtkWidget *chainbutton;
|
||||
GtkWidget *expander;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *text_view;
|
||||
GtkTextBuffer *text_buffer;
|
||||
gchar *text;
|
||||
GList *focus_chain = NULL;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
@ -466,8 +468,18 @@ gimp_template_editor_constructor (GType type,
|
|||
gtk_widget_show (frame);
|
||||
|
||||
/* frame for Comment */
|
||||
frame = gimp_frame_new (_("Image Comment"));
|
||||
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
|
||||
text = g_strdup_printf ("<b>%s</b>", _("Image _Comment"));
|
||||
expander = g_object_new (GTK_TYPE_EXPANDER,
|
||||
"label", text,
|
||||
"use_markup", TRUE,
|
||||
NULL);
|
||||
g_free (text);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (editor), expander, TRUE, TRUE, 0);
|
||||
gtk_widget_show (expander);
|
||||
|
||||
frame = gimp_frame_new ("<expander>");
|
||||
gtk_container_add (GTK_CONTAINER (expander), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
@ -29,8 +31,9 @@
|
|||
#include "gimpframe.h"
|
||||
|
||||
|
||||
#define DEFAULT_LABEL_SPACING 6
|
||||
#define GIMP_FRAME_INDENT_KEY "gimp-frame-indent"
|
||||
#define DEFAULT_LABEL_SPACING 6
|
||||
#define GIMP_FRAME_INDENT_KEY "gimp-frame-indent"
|
||||
#define GIMP_FRAME_EXPANDER_KEY "gimp-frame-in-expander"
|
||||
|
||||
|
||||
static void gimp_frame_class_init (GimpFrameClass *klass);
|
||||
|
@ -48,6 +51,7 @@ static gboolean gimp_frame_expose_event (GtkWidget *widget,
|
|||
GdkEventExpose *event);
|
||||
static void gimp_frame_label_widget_notify (GtkFrame *frame);
|
||||
static gint gimp_frame_get_indent (GtkWidget *widget);
|
||||
static gint gimp_frame_get_label_spacing (GtkFrame *frame);
|
||||
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
|
@ -127,15 +131,7 @@ gimp_frame_size_request (GtkWidget *widget,
|
|||
|
||||
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
|
||||
{
|
||||
gint spacing;
|
||||
|
||||
gtk_widget_size_request (frame->label_widget, requisition);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"label_spacing", &spacing,
|
||||
NULL);
|
||||
|
||||
requisition->height += spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -143,6 +139,8 @@ gimp_frame_size_request (GtkWidget *widget,
|
|||
requisition->height = 0;
|
||||
}
|
||||
|
||||
requisition->height += gimp_frame_get_label_spacing (frame);
|
||||
|
||||
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
||||
{
|
||||
gint indent = gimp_frame_get_indent (widget);
|
||||
|
@ -208,20 +206,17 @@ gimp_frame_child_allocate (GtkFrame *frame,
|
|||
gint spacing = 0;
|
||||
gint indent = gimp_frame_get_indent (widget);
|
||||
|
||||
if (frame->label_widget)
|
||||
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
|
||||
{
|
||||
GtkRequisition child_requisition;
|
||||
|
||||
gtk_widget_get_child_requisition (frame->label_widget,
|
||||
&child_requisition);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"label_spacing", &spacing,
|
||||
NULL);
|
||||
|
||||
spacing += child_requisition.height;
|
||||
}
|
||||
|
||||
spacing += gimp_frame_get_label_spacing (frame);
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||
child_allocation->x = border_width + indent;
|
||||
else
|
||||
|
@ -320,6 +315,22 @@ gimp_frame_get_indent (GtkWidget *widget)
|
|||
return width;
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_frame_get_label_spacing (GtkFrame *frame)
|
||||
{
|
||||
gint spacing = 0;
|
||||
|
||||
if ((frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget)) ||
|
||||
(g_object_get_data (G_OBJECT (frame), GIMP_FRAME_EXPANDER_KEY)))
|
||||
{
|
||||
gtk_widget_style_get (GTK_WIDGET (frame),
|
||||
"label_spacing", &spacing,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return spacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_frame_new:
|
||||
* @label: text to set as the frame's title label (or %NULL for no title)
|
||||
|
@ -337,7 +348,23 @@ gimp_frame_get_indent (GtkWidget *widget)
|
|||
GtkWidget *
|
||||
gimp_frame_new (const gchar *label)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_FRAME,
|
||||
"label", label,
|
||||
NULL);
|
||||
GtkWidget *frame;
|
||||
gboolean expander = FALSE;
|
||||
|
||||
/* somewhat hackish, should perhaps be an object property of GimpFrame */
|
||||
if (label && strcmp (label, "<expander>") == 0)
|
||||
{
|
||||
expander = TRUE;
|
||||
label = NULL;
|
||||
}
|
||||
|
||||
frame = g_object_new (GIMP_TYPE_FRAME,
|
||||
"label", label,
|
||||
NULL);
|
||||
|
||||
if (expander)
|
||||
g_object_set_data (G_OBJECT (frame),
|
||||
GIMP_FRAME_EXPANDER_KEY, (gpointer) TRUE);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue