different data types between clist and mysql.

2010-04-20 Thread Arthur 1989
Hello, I used *clist* to display data iI fetch from mysql server,but when
writing data back into the table of database, I got this question: the data
type of clist is always *gchar **, while there are quite a lot of other data
types in mysql. What can I do to get this question solved? Any tips will be
appreciated.

-- 
-
Best regards
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: different data types between clist and mysql.

2010-04-20 Thread Emmanuele Bassi
On Tue, 2010-04-20 at 21:15 +0800, Arthur 1989 wrote:
 Hello, I used *clist* to display data iI fetch from mysql server,but when
 writing data back into the table of database, I got this question: the data
 type of clist is always *gchar **, while there are quite a lot of other data
 types in mysql. What can I do to get this question solved? Any tips will be
 appreciated.

CList is *beyond* deprecation - you should not be using it.

look at GtkListStore and GtkTreeView; there's also a tutorial here:

  http://scentric.net/tutorial

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


RE: different data types between clist and mysql.

2010-04-20 Thread Shawn Bakhtiar

Ran into same problem.

I use a structure like 

_IsiField {

  int type,
  int pos,
  int 

}

Then create my own list with 

_IsiList {

  GList Fields;
  GList rows;

}


Every time retrieve a set of values, I have a routing which sets type to a 
G_TYPE, which corresponds to the MYSQL_TYPE


Here is what I do:

GList * 
 isi_database_fetch_fields(IsiDatabase *self)
{ 

MYSQL_FIELD *field;
IsiFields *l;
GList *gl = NULL;
guint column = 0;

 /* Sanity Check */
g_return_val_if_fail(self != NULL, NULL);
g_return_val_if_fail(self-priv != NULL, NULL);
g_return_val_if_fail(self-priv-dispose_has_run != TRUE, NULL);
g_return_val_if_fail(self-priv-res != NULL, NULL);

/* Rewind the feild set */
mysql_field_seek(self-priv-res,0L);


while((field = mysql_fetch_field(self-priv-res)))
{
/* Initialize a new IsiFields structure */
//l = (IsiFields*) g_new0(IsiFields, 1);
l = g_new0(IsiFields, 1);

/* Set the values */
l-alias = g_strdup(field-name);
l-name = g_strdup(field-org_name);
l-length = field-length;

/* always make fields visable */

l-hidden = FALSE;
l-sortable = FALSE;
l-pos = column++;


switch (field-type){

/* Integer types */
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_INT24:

/* Check for signage */
if (field-flags  UNSIGNED_FLAG)
l-type = G_TYPE_UINT;
else
l-type = G_TYPE_INT;

break;


/* Long types */
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_LONGLONG:

/* Check for signage */
if (field-flags  UNSIGNED_FLAG)
l-type = G_TYPE_ULONG;
else
l-type = G_TYPE_LONG;
break;


/* Decimal types */
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
l-type = G_TYPE_DOUBLE;
break;

/* Bit types */
case MYSQL_TYPE_BIT:
l-type = G_TYPE_BOOLEAN;
break;

/* ENUM types */
case MYSQL_TYPE_ENUM:
l-type = G_TYPE_ENUM;
break;

/* All other types */
default:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_NULL:

if(l-length = 1){
l-type = G_TYPE_CHAR;
}else{
l-type = G_TYPE_STRING;
}
break;
}


/*DEBUG*/
//g_print(%s %d %d \n, l-alias,l-type,l-length);

/* Save pointer to list */
gl = g_list_append(gl,(gpointer)l);

}

return gl;}



now convert the row data to a GList and you have two GLists in your one lists, 
one with the field header info, the other with the data. 


and create the liststore like this:

GtkTreeModel *
isi_display_liststore_create(IsiDisplay *self, GList *fields)
{
   guint num_fields, i;
   IsiFields *l;
   GtkTreeModel *model;
   GType *types;
   guint search_col_adj = 0;

 /* Sanity Check */
g_return_val_if_fail(self != NULL, NULL);
g_return_val_if_fail(self-priv != NULL, NULL);
g_return_val_if_fail(self-priv-dispose_has_run != TRUE, NULL);

   /* Get the number of fields */
   if(fields != NULL){

num_fields = g_list_length(fields);

/* Initialize values based on number of columns */
types = (GType*) g_new0( GType, num_fields);

for(i=0;inum_fields;i++){

l = (IsiFields*)g_list_nth_data(fields,i);
types[i] = l-type;


}


/* create the model store for data input */
model =  (GtkTreeModel*) gtk_list_store_newv(num_fields,types);

g_free(types);



for(i=0;inum_fields;i++){

l = (IsiFields*)g_list_nth_data(fields,i);

/* Setup sorting functions for the modle */
switch(l-type){
case G_TYPE_INT:
l-sortable=TRUE;
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), 
l-pos, sort_by_int,(gpointer) l-pos, NULL);
break;
case G_TYPE_UINT:
l-sortable=TRUE;
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), 
l-pos, sort_by_uint,(gpointer) l-pos, NULL);
break;
case G_TYPE_LONG:
l-sortable=TRUE;
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), 
l-pos, sort_by_long,(gpointer) l-pos, NULL);
break;
case G_TYPE_ULONG:
l-sortable=TRUE;

RE: different data types between clist and mysql.

2010-04-20 Thread Murray Cumming
I strongly advise you to try libgda rather than reimplementing it
yourself.


-- 
murr...@murrayc.com
www.murrayc.com
www.openismus.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Zoom/magnification of images in GDK

2010-04-20 Thread lindleyf
I have a GUI which shows 640x480 video frames from a firewire camera. I've 
gotten a request to allow the user to zoom in on a particular part of the image 
if they choose; the camera doesn't have a zoom feature, so this wouldn't give 
any better resolution, but might make things easier to see anyway.

Right now, the image is being written to a GtkDrawingArea using 
gdk_draw_grey_image().

Now, I know how I could do this if I used gtkglext to get OpenGL in the 
picture, so I could throw the image into a texture and then render it at an 
arbitrary size. But I was wondering if there were any options built into 
GTK/GDK which would allow me to avoid the extra dependency?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


[Pango] Underline attribute does not work with scaled cairo context.

2010-04-20 Thread Magicloud Magiclouds
Hi, I set the attributes for the layout with Underline, Size, Letter
Spacing, Font Description. All others worked fine except the
Underline, worked as there was no scale at all. So when the string
displayed in correct size, the underline on the other hand, displayed
as huge black blocks.

Following is my code, sorry it is in haskell.

  layout - liftIO $ do
ctxt - cairoCreateContext Nothing
layout - layoutText ctxt $ show $ day e
fd - fontDescriptionFromString WenQuanYi Micro Hei Mono Bold
layoutSetAttributes layout ((if odd $ ceiling x
   then case y of
 3 - AttrUnderline 0 2 UnderlineSingle
 4 - AttrUnderline 0 2 UnderlineSingle
 5 - AttrUnderline 0 2 UnderlineSingle
 6 - AttrUnderline 0 2 UnderlineSingle
 7 - AttrUnderline 0 2 UnderlineSingle
 8 - AttrUnderline 0 2 UnderlineDouble
 9 - AttrUnderline 0 2 UnderlineDouble
 10 - AttrUnderline 0 2 UnderlineSingle
 11 - AttrUnderline 0 2 UnderlineSingle
 12 - AttrUnderline 0 2 UnderlineSingle
 13 - AttrUnderline 0 2 UnderlineSingle
 14 - AttrUnderline 0 2 UnderlineSingle
 15 - AttrUnderline 0 2 UnderlineDouble
 16 - AttrUnderline 0 2 UnderlineDouble
   else case y of
 3 - AttrUnderline 0 2 UnderlineDouble
 4 - AttrUnderline 0 2 UnderlineDouble
 5 - AttrUnderline 0 2 UnderlineSingle
 6 - AttrUnderline 0 2 UnderlineSingle
 7 - AttrUnderline 0 2 UnderlineSingle
 8 - AttrUnderline 0 2 UnderlineSingle
 9 - AttrUnderline 0 2 UnderlineSingle
 10 - AttrUnderline 0 2 UnderlineDouble
 11 - AttrUnderline 0 2 UnderlineDouble
 12 - AttrUnderline 0 2 UnderlineSingle
 13 - AttrUnderline 0 2 UnderlineSingle
 14 - AttrUnderline 0 2 UnderlineSingle
 15 - AttrUnderline 0 2 UnderlineSingle
 16 - AttrUnderline 0 2 UnderlineSingle) :
[ AttrSize 0 2 0.4
, AttrLetterSpacing 0 2 (-0.3)
, AttrFontDescription 0 2 fd ])
  return layout
  setSourceRGB 0 0 0
  (_, PangoRectangle _ _ w h) - liftIO $ layoutGetExtents layout
  moveTo (x - 0.5 - w / 2 + 0.05 + 0.1) (y + 0.2)
  showLayout layout

-- 
竹密岂妨流水过
山高哪阻野云飞
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list