Package: gperiodic Version: 2.0.10-4 Followup-For: Bug #214493 Tags: patch How about starting with decorating the buttons with multi-line text? In this patch, the buttons are decorated with small atomic numbers and weights. Symbols are now bold and big, and colored according to the state at room temperature.
Screenshot: http://linux.thai.net/~thep/shots/20080629-gperiodic-decorated.png Regards, -- Theppitak Karoonboonyanan http://linux.thai.net/~thep/
#! /bin/sh /usr/share/dpatch/dpatch-run ## 20_decorated_button.dpatch by Theppitak Karoonboonyanan <[EMAIL PROTECTED]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Decorate buttons with element information @DPATCH@ diff -urNad gperiodic-2.0.10~/gperiodic.c gperiodic-2.0.10/gperiodic.c --- gperiodic-2.0.10~/gperiodic.c 2008-06-29 22:00:30.000000000 +0700 +++ gperiodic-2.0.10/gperiodic.c 2008-06-29 22:01:43.000000000 +0700 @@ -250,6 +250,63 @@ gtk_widget_set_style( table[i].button, table[i].style ); } +GtkWidget *create_element_button(char *info[]) +{ + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *button; + char *markup; + char *state_color; + + vbox = gtk_vbox_new(FALSE, 0); + + /* atomic number */ + label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span size=\"xx-small\">%s</span>", + info[NUMBER]); + gtk_label_set_markup(GTK_LABEL(label), markup); + g_free(markup); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + + /* atomic weight */ + label = gtk_label_new(NULL); + markup = g_markup_printf_escaped("<span size=\"xx-small\">%s</span>", + info[WEIGHT]); + gtk_label_set_markup(GTK_LABEL(label), markup); + g_free(markup); + gtk_box_pack_end(GTK_BOX(vbox), label, FALSE, FALSE, 0); + + /* symbol */ + label = gtk_label_new(NULL); + /* what state is it? */ + if (strcmp(info[MELTING], _("n/a")) == 0 + || strcmp(info[BOILING], _("n/a")) == 0) + { + /* n/a */ + state_color = "#7F7F7F"; + } else if (ambientTemperature < strtod(info[MELTING], NULL)) { + /* solid */ + state_color = "black"; + } else if (ambientTemperature < strtod(info[BOILING], NULL)) { + /* liquid */ + state_color = "blue"; + } else { + /* gas */ + state_color = "#CF0000"; + } + markup = g_markup_printf_escaped("<span size=\"large\" weight=\"bold\" foreground=\"%s\">%s</span>", + state_color, info[SYMBOL]); + gtk_label_set_markup(GTK_LABEL(label), markup); + g_free(markup); + gtk_box_pack_end(GTK_BOX(vbox), label, TRUE, TRUE, 0); + + /* the button */ + button = gtk_button_new(); + gtk_container_add(GTK_CONTAINER(button), vbox); + + return button; +} + void main_prog(void) { GtkWidget *vbox; @@ -335,7 +392,7 @@ } /* create the button */ - table[i].button = gtk_button_new_with_label(_(table[i].info[SYMBOL])); + table[i].button = create_element_button(table[i].info); if( !table[i].button ) { g_warning("%s(%d) %s", __FILE__, __LINE__, _("Error button was null?")); break; @@ -396,7 +453,7 @@ /* attach the button to the table */ gtk_table_attach(GTK_TABLE(periodic_table), table[i].button, table[i].x - 1, table[i].x, table[i].y - 1, table[i].y, - GTK_FILL, GTK_FILL, 2, 2); + GTK_FILL, GTK_FILL, 0, 0); }