[Glade-devel] Custom Widgets in Glade 2.6
- From: avtar69 at gmail.com (Avtar Singh)
- Subject: [Glade-devel] Custom Widgets in Glade 2.6
- Date: Thu, 29 Mar 2007 16:23:53 +0530
Dear Damon,
Thanks for you reply .
create_color_combo is the creation function of the custom widget. The
parameters that I am passing in the Custom widget are as follows:
Name : cust_combo
Class : Custom
Creation function: create_color_combo
String1: red
Int1: 0
Int2: 0
Below is the creation function code
============================================================
extern "C" GtkWidget*
create_color_combo (gchar *widget_name, gchar *string1, gchar *string2,
gint int1, gint int2)
{
GtkWidget *pixmap;
GtkWidget *color_combo;
gchar *remapped_colors[64];
const char * color;
int i;
GdkColor gcolors[64];
if (string1 != NULL && *string1 != '\0') {
color = string1;
} else if (int1 < 64) {
color = colors[int1];
} else {
color = "black";
}
pixmap = create_color_block_pixmap_new(color);
for (i=0 ; i < 64; i++) {
int x = i % 8;
int y = int (i/8);
int flipped_i = x * 8 + y;
remapped_colors[i] = (gchar *) colors[remap[flipped_i]];
gdk_color_parse(remapped_colors[i], &gcolors[i]);
}
gdk_color_parse(color,gcolors);
color_combo = gtk_color_combo_new_with_values(8, 8, gcolors);
gtk_container_add(GTK_CONTAINER(GTK_COMBO_BUTTON(color_combo)->button),
pixmap);
gtk_widget_show(pixmap);
gtk_signal_connect(GTK_OBJECT(color_combo),
"changed", (GtkSignalFunc) xptui_color_combo_changed,
NULL);
gtk_object_set_data(GTK_OBJECT(color_combo), "selected-color",
(gpointer) color);
gtk_widget_show(color_combo);
gtk_widget_set_name(color_combo,widget_name);
return color_combo;
}
static GtkWidget
*create_color_block_pixmap_new (const char * color) {
GdkBitmap *mask;
GdkPixmap *pixmap;
GdkColormap *colormap = gdk_colormap_get_system();
char buffer[20];
snprintf(buffer,20, "Xc %s", color);
block[6] = buffer;
pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &mask, NULL,
block);
return gtk_pixmap_new(pixmap, mask);
}
============================================================
Please do let me know I you want any more infomation.
Thanks
Avtar Singh
On 3/29/07, Damon Chaplin <damon at karuna.eclipse.co.uk> wrote:
On Thu, 2007-03-29 at 10:26 +0530, Avtar Singh wrote:
Dear All,
I am working on glade 2.6 and using Custom Widgets for creating a
color combo box pallete. My Custom Widgets creation function calls a
function which creates a color combo and returns the color combo
widget. This same function is used to create about 40 color combo
widgets which are placed at different tabs in my application.
The problem is that some of the custom widgets work fine but some of
these widgets gives me "glibc corrupted double link list error" on
return from this function.
I have tried running the application using Valgrind and it works fine
without giving me glibc erorr. The strange thing that I find is that
when I change the positions of custom widgets in my Application (Glade
file) some of the widgets come up but it gives me error at some
different Custom Widget.
Please let me know if somebody has any idea on this issue.
That's a pretty odd bug.
If you can write a small test app that shows the problem I'll take a
look at it.
I'd guess that the problem is in your code, since noone else has
reported a bug like this, and the Glade code is pretty simple. But I may
be wrong. (Also, recent versions of GTK+ are causing loads of crashes,
which could possibly be related.)
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]