[Goodies-commits] r5544 - in xfbib/branches/gobject: . src

Jesper Karlsson zarper at xfce.org
Thu Oct 9 17:23:15 CEST 2008


Author: zarper
Date: 2008-10-09 15:23:15 +0000 (Thu, 09 Oct 2008)
New Revision: 5544

Modified:
   xfbib/branches/gobject/Makefile.am
   xfbib/branches/gobject/configure.ac.in
   xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
   xfbib/branches/gobject/src/xfbib-multiple-input.c
Log:
Added buttons for editing compound string, still needs work.
Changed generate button icon.


Modified: xfbib/branches/gobject/Makefile.am
===================================================================
--- xfbib/branches/gobject/Makefile.am	2008-10-09 13:22:58 UTC (rev 5543)
+++ xfbib/branches/gobject/Makefile.am	2008-10-09 15:23:15 UTC (rev 5544)
@@ -2,7 +2,8 @@
 	po \
 	src \
 	tests \
-	icons
+	icons \
+	pixmaps
 
 AUTOMAKE_OPTIONS = \
 	1.8 \

Modified: xfbib/branches/gobject/configure.ac.in
===================================================================
--- xfbib/branches/gobject/configure.ac.in	2008-10-09 13:22:58 UTC (rev 5543)
+++ xfbib/branches/gobject/configure.ac.in	2008-10-09 15:23:15 UTC (rev 5544)
@@ -92,4 +92,5 @@
 icons/36x36/Makefile
 icons/48x48/Makefile
 icons/scalable/Makefile
+pixmaps/Makefile
 ])

Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-09 13:22:58 UTC (rev 5543)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c	2008-10-09 15:23:15 UTC (rev 5544)
@@ -90,8 +90,9 @@
 	GtkWidget *key_label;
 	GtkWidget *key_entry;
 	GtkWidget *key_button;
-	GtkWidget *labels[XFBIB_FIELD_N_FIELDS];	/* Label and NULL objects */
+	GtkWidget *inputs_label[XFBIB_FIELD_N_FIELDS];	/* Label and NULL objects */
 	GtkWidget *inputs[XFBIB_FIELD_N_FIELDS];	/* Entry and multiple inputs */
+	GtkWidget *inputs_button[XFBIB_FIELD_N_FIELDS];
 	GtkWidget *note_boxes[5];
 	GtkWidget *notebook;
 };
@@ -136,6 +137,37 @@
 	gtk_entry_set_text(GTK_ENTRY (XFBIB_ENTRY_EDIT_DIALOG (user_data)->key_entry), xfbib_strbuf_get_str(strbuf));
 }
 
+static void
+cb_edit_compound_string_clicked (GtkButton *button, GtkEntry *entry)
+{
+	g_printf("cb_compound_string_clicked\n");
+}
+
+static GtkWidget*
+xfbib_get_image (gchar *filename)
+{
+	GtkWidget *image;
+	XfbibStrbuf *path;
+	GdkPixbuf *pixbuf = NULL;
+
+	path = xfbib_strbuf_new();
+	xfbib_strbuf_append(path, DATADIR);
+	xfbib_strbuf_append(path, "/pixmaps/xfbib/");
+	xfbib_strbuf_append(path, filename);
+	
+	/* TODO: Fix the error handling */
+	pixbuf = gdk_pixbuf_new_from_file(xfbib_strbuf_get_str(path),NULL);
+
+	if(pixbuf == NULL){
+		g_warning("Button icon missing: %s", filename);
+		image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON);
+	}else{
+		image = gtk_image_new_from_pixbuf(pixbuf);
+	}
+
+	return image;
+}
+
 GType
 xfbib_entry_edit_dialog_get_type (void)
 {
@@ -183,48 +215,46 @@
 
 	instance->key_label = gtk_label_new("Key:");
 	instance->key_entry = gtk_entry_new();
-	/* TODO: Remove the text from button, try and find a magic wand icon or something similar instead */
-	instance->key_button = gtk_button_new_from_stock(GTK_STOCK_EXECUTE);
+	instance->key_button = gtk_button_new();
+	gtk_container_add(GTK_CONTAINER(instance->key_button), xfbib_get_image("xfbib-generate.png"));
 	g_signal_connect(G_OBJECT (instance->key_button), "clicked", G_CALLBACK (cb_generate_clicked), instance);
 
-	/* TODO: Should the type and key widgets be on two seperate rows instead to limit the width? */
 	top_box = gtk_hbox_new(FALSE, 12);
 
-	GtkWidget *leftalign, *rightalign;
-	leftalign = gtk_alignment_new(0, 0.5, 0, 0);
-	rightalign = gtk_alignment_new(0, 0.5, 0, 0);
-	gtk_alignment_set_padding(GTK_ALIGNMENT(leftalign), 0, 0, 6, 0);
-	gtk_alignment_set_padding(GTK_ALIGNMENT(rightalign), 0, 0, 0, 6);
+	gtk_container_set_border_width(GTK_CONTAINER (top_box), 6);
 
-	gtk_box_pack_start(GTK_BOX(top_box), leftalign, FALSE, FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(leftalign), instance->type_label);
+	gtk_box_pack_start(GTK_BOX(top_box), instance->type_label, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(top_box), instance->type_combo_box, FALSE, FALSE, 0);
 
-	gtk_box_pack_end(GTK_BOX(top_box), rightalign, FALSE, FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(rightalign), instance->key_button);
-	gtk_box_pack_end(GTK_BOX(top_box), instance->key_entry, FALSE, FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(top_box), instance->key_button, FALSE, FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(top_box), instance->key_entry, TRUE, TRUE, 0);
 	gtk_box_pack_end(GTK_BOX(top_box), instance->key_label, FALSE, FALSE, 0);
 	
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (instance)->vbox), top_box, FALSE, FALSE, 0);
 	
-	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(instance)->vbox), 6);
+	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(instance)->vbox), 0);	// 0 due to top_box border width
 
 	for (i = 0; i < 5; i++) {
-		instance->note_boxes[i] = gtk_table_new(1, 2, FALSE);
+		instance->note_boxes[i] = gtk_table_new(1, 1, FALSE);
 		gtk_table_set_row_spacings(GTK_TABLE(instance->note_boxes[i]), 6);
 		gtk_table_set_col_spacings(GTK_TABLE(instance->note_boxes[i]), 12);
 		gtk_container_set_border_width(GTK_CONTAINER (instance->note_boxes[i]), 6);
 	}
-	
+
 	for (i = 0; i < XFBIB_FIELD_N_FIELDS; i++) {
 		/* Create the Input object */
 		if (i == XFBIB_FIELD_AUTHOR || i == XFBIB_FIELD_EDITOR) {
 			instance->inputs[i] = xfbib_multiple_input_new(xfbib_input_constants[i].label, xfbib_input_constants[i].tooltip);
 		} else {
-			instance->labels[i] = gtk_label_new(xfbib_input_constants[i].label);
-			gtk_misc_set_alignment(GTK_MISC(instance->labels[i]), 0, 0.5);
+			instance->inputs_label[i] = gtk_label_new(xfbib_input_constants[i].label);
+			gtk_misc_set_alignment(GTK_MISC(instance->inputs_label[i]), 0, 0.5);
+
 			instance->inputs[i] = gtk_entry_new();
 			gtk_widget_set_tooltip_text(instance->inputs[i], xfbib_input_constants[i].tooltip);
+
+			instance->inputs_button[i] = gtk_button_new();
+			gtk_container_add(GTK_CONTAINER(instance->inputs_button[i]), xfbib_get_image("xfbib-compound-string.png"));
+			g_signal_connect(G_OBJECT (instance->inputs_button[i]), "clicked", G_CALLBACK (cb_edit_compound_string_clicked), instance->inputs[i]);
 		}
 
 		/* Add the input object to the correct box */
@@ -274,8 +304,9 @@
 		if (i == XFBIB_FIELD_AUTHOR || i == XFBIB_FIELD_EDITOR) {
 			gtk_table_attach_defaults(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i], row[box], row[box]+1, 0, 1);
 		} else {
-			gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->labels[i], 0, 1, row[box], row[box]+1, GTK_FILL, GTK_FILL, 0, 0);
+			gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs_label[i], 0, 1, row[box], row[box]+1, GTK_FILL, GTK_FILL, 0, 0);
 			gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs[i], 1, 2, row[box], row[box]+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+			gtk_table_attach(GTK_TABLE(instance->note_boxes[box]), instance->inputs_button[i], 2, 3, row[box], row[box]+1, GTK_FILL, GTK_FILL, 0, 0);
 		}
 		row[box]++;
 	}

Modified: xfbib/branches/gobject/src/xfbib-multiple-input.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-09 13:22:58 UTC (rev 5543)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.c	2008-10-09 15:23:15 UTC (rev 5544)
@@ -161,7 +161,7 @@
 	gtk_tree_view_column_set_min_width(GTK_TREE_VIEW_COLUMN(column), 100);
    	gtk_tree_view_append_column(GTK_TREE_VIEW(instance->tree_view), column);
 
-	list = gtk_list_store_new (1, G_TYPE_STRING);
+	list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
 
 	gtk_tree_view_set_model(GTK_TREE_VIEW(instance->tree_view), GTK_TREE_MODEL(list));
 	g_object_unref(list);
@@ -175,18 +175,12 @@
 	g_signal_connect_swapped(G_OBJECT(instance->add_button), "clicked",
 			G_CALLBACK(cb_add_button_clicked_event), instance->tree_view);
 
-
 	instance->remove_button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
 	g_signal_connect_swapped(G_OBJECT(instance->remove_button), "clicked",
 			G_CALLBACK(cb_remove_button_clicked_event), instance->tree_view);
 
-	//instance->toggle_button = gtk_toggle_button_new_with_label("aA");
-	//gtk_widget_set_tooltip_text (instance->toggle_button, "Toggle case sensitivity.");
-
-	
 	gtk_box_pack_start(GTK_BOX(button_box), instance->add_button, TRUE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(button_box), instance->remove_button, TRUE, FALSE, 0);
-	//gtk_box_pack_start(GTK_BOX(button_box), instance->toggle_button, TRUE, FALSE, 1);
 	
 	gtk_container_add (GTK_CONTAINER (scrolled_window), instance->tree_view);
 




More information about the Goodies-commits mailing list