respect https prefix
[k8lowj.git] / src / groupedbox.c
blobc0a7e738c850f3949b27750657c836626586dec1
1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Evan Martin <evan@livejournal.com>
3 */
4 #include "gtk-all.h"
6 #include "groupedbox.h"
9 /* http://developer.gnome.org/projects/gup/hig/1.0/layout.html#window-layout-spacing */
12 static void groupedbox_init (GroupedBox *gb) {
13 GtkWidget *margin;
14 GtkWidget *hbox;
15 gtk_box_set_spacing(GTK_BOX(gb), 6);
16 hbox = gtk_hbox_new(FALSE, 5);
17 gb->vbox = gtk_vbox_new(FALSE, 6);
18 margin = gtk_label_new(" ");
19 gtk_box_pack_start(GTK_BOX(hbox), margin, FALSE, FALSE, 0);
20 gtk_box_pack_start(GTK_BOX(hbox), gb->vbox, TRUE, TRUE, 0);
21 gtk_box_pack_end(GTK_BOX(gb), hbox, TRUE, TRUE, 0);
22 gb->body = hbox;
26 GtkWidget *groupedbox_new (void) {
27 GroupedBox *gb = GROUPEDBOX(g_object_new(groupedbox_get_type(), NULL));
28 return GTK_WIDGET(gb);
32 GtkWidget *groupedbox_new_with_text (const char *text) {
33 GroupedBox *gb = GROUPEDBOX(g_object_new(groupedbox_get_type(), NULL));
34 groupedbox_set_header(gb, text, TRUE);
35 return GTK_WIDGET(gb);
39 void groupedbox_set_header_widget (GroupedBox *b, GtkWidget *w) {
40 if (b->header) gtk_container_remove(GTK_CONTAINER(b), b->header);
41 if (w) gtk_box_pack_start(GTK_BOX(b), w, FALSE, FALSE, 0);
42 b->header = w;
46 void groupedbox_set_header (GroupedBox *b, const char *title, gboolean bold) {
47 GtkWidget *label = gtk_label_new(bold ? NULL : title);
48 if (bold) {
49 gchar *markup = g_strdup_printf("<b>%s</b>", title);
50 gtk_label_set_markup(GTK_LABEL(label), markup);
51 g_free(markup);
53 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
54 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
55 groupedbox_set_header_widget(b, label);
59 void groupedbox_pack (GroupedBox *b, GtkWidget *w, gboolean expand) {
60 gtk_box_pack_start(GTK_BOX(b->vbox), w, expand, expand, 0);
64 GType groupedbox_get_type (void) {
65 static GType gb_type = 0;
66 if (!gb_type) {
67 const GTypeInfo gb_info = {
68 sizeof(GtkVBoxClass),
69 NULL,
70 NULL,
71 NULL,
72 NULL,
73 NULL,
74 sizeof(GroupedBox),
76 (GInstanceInitFunc) groupedbox_init,
78 gb_type = g_type_register_static(GTK_TYPE_VBOX, "GroupedBox", &gb_info, 0);
80 return gb_type;