Skip to content

Commit

Permalink
buttons now use images, remove titles from headerbar and CSD are working
Browse files Browse the repository at this point in the history
  • Loading branch information
Unia committed Oct 22, 2013
1 parent 210b250 commit 489c59c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,30 @@ void on_list_selection_changed (void) {

void on_stack_page_change (void) {
const gchar *page;
GtkWidget *image_delete, *image_save;

page = gtk_stack_get_visible_child_name (GTK_STACK (stack));
if (g_strcmp0 (page, "scroll") == 0) {
gtk_button_set_label (GTK_BUTTON (button_save), _("Delete"));
image_delete = gtk_image_new_from_icon_name ("stock_delete", GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button_save), image_delete);
if (gtk_tree_selection_get_selected (selection, NULL, &selection_iter))
gtk_widget_set_sensitive (button_save, TRUE);
else
gtk_widget_set_sensitive (button_save, FALSE);
} else {
gtk_button_set_label (GTK_BUTTON (button_save), _("Save"));
image_save = gtk_image_new_from_icon_name ("stock_save", GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button_save), image_save);
gtk_widget_set_sensitive (button_save, TRUE);
}
}

void on_sd_button_clicked (void) {
const gchar *type;
const gchar *type = NULL;
GtkWidget *image;

type = gtk_button_get_label (GTK_BUTTON (button_save));
if (g_strcmp0 (type, _("Save")) == 0)
image = gtk_button_get_image (GTK_BUTTON (button_save));
gtk_image_get_icon_name (GTK_IMAGE (image), &type, NULL);
if (g_strcmp0 (type, "stock_save") == 0)
open_save_dialog ();
else {
gchar *color_value;
Expand Down
1 change: 0 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int main (void) {
colorvalue.red = colorvalue.green = colorvalue.blue = 65535;

window = create_window ();
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_widget_show_all (window);

user_filename = g_build_filename (g_getenv ("HOME"), ".rgb.txt", NULL);
Expand Down
11 changes: 6 additions & 5 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ GtkWidget *save_dialog_open (void) {
}

GtkWidget *create_window (void) {
GtkWidget *box_all, *header_bar, *stackswitcher, *box_color_chooser, *scroll, *button_about;
GtkWidget *box_all, *header_bar, *stackswitcher, *box_color_chooser, *scroll, *button_about, *image_about;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;

Expand All @@ -139,8 +139,6 @@ GtkWidget *create_window (void) {
gtk_container_set_border_width (GTK_CONTAINER (box_all), 5);

header_bar = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header_bar), "Gcolor3");
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header_bar), _("A simple color selection dialog in GTK3"));
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), TRUE);

stack = gtk_stack_new ();
Expand All @@ -155,8 +153,10 @@ GtkWidget *create_window (void) {
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);

button_save = gtk_button_new_with_label (_("Save"));
button_about = gtk_button_new_with_label (_("About"));
button_save = gtk_button_new ();
button_about = gtk_button_new ();
image_about = gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (button_about), image_about);

liststore = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (liststore));
Expand All @@ -180,6 +180,7 @@ GtkWidget *create_window (void) {
gtk_tree_view_column_set_sort_column_id (column, COLOR_NAME);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
gtk_box_pack_start (GTK_BOX (box_all), header_bar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box_color_chooser), color_chooser, FALSE, FALSE, 0);
gtk_stack_add_titled (GTK_STACK (stack), box_color_chooser, "color chooser", _("Color chooser"));
Expand Down

0 comments on commit 489c59c

Please sign in to comment.