GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 5:23 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Using gtk_cell_renderer_progress
PostPosted: Tue Feb 24, 2009 9:49 am 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Hello,

i try to use a gtkcellrenderer progress bar but i have some warnings when i execute my program.

Quote:
GLib-GObject-WARNING **: invalid cast from `GtkTreeView' to `GtkProgress'

Gtk-CRITICAL **: gtk_progress_get_current_percentage: assertion `GTK_IS_PROGRESS (progress)' failed


I create my gtkliststore like that :

Code:
pListStore = gtk_list_store_new(4,G_TYPE_STRING,GTK_TYPE_INT,G_TYPE_STRING,G_TYPE_POINTER);


The third argument is for the gtk_cell_renderer_progress, i have chosen a GTK_TYPE_INT and for property a "value" type.

Code:
pCellRenderer = gtk_cell_renderer_progress_new ();
pColumn = gtk_tree_view_column_new_with_attributes ("progress",pCellRenderer,"value", 1,NULL);


And for update my progress bar i use this function :

Code:
gtk_list_store_set(pListStore, &pIter,1,10,-1);


All work but i have some warnings during the execution.

When i try a
Code:
gtk_list_store_set(pListStore, &pIter,1,1,-1);
ou
gtk_list_store_set(pListStore, &pIter,1,0,-1);


No problems, no warnings, but for values greater than 1 i have warnings.

Sorry for my english and thanks for your help
(I use GTK 2.10)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 8:39 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
Welcome to the GTK+ forums :)
Can you post your code please? Because the only thing that I can see that's wrong is that you're using GTK_TYPE_INT instead of G_TYPE_INT, but that's it.
Thank you...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 9:39 am 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Hello

for example, this code :

Code:
#include <gtk/gtk.h>
#include <stdio.h>

void start_gtk(int argc,char **argv)
{   
       GtkWidget *vbox;
   GtkWidget *win;

   GtkListStore *pListStore;
   GtkWidget *pListView;

       gtk_init (&argc, &argv); 

       win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_container_set_border_width (GTK_CONTAINER (win), 0);
       gtk_window_set_title (GTK_WINDOW (win), "title");
       gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
       gtk_window_set_default_size(GTK_WINDOW(win), 600, 400);
       gtk_widget_realize (win);
       g_signal_connect (win, "destroy", gtk_main_quit, NULL);

       vbox = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (win), vbox);

   
   /* **** Gtkliststore *************** */
   pListStore = gtk_list_store_new(1,G_TYPE_INT);
   pListView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pListStore));

      GtkCellRenderer *pCellRenderer;
       pCellRenderer = gtk_cell_renderer_progress_new ();
   
     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pListView),0, "Progress", pCellRenderer,"value", NULL);
   gtk_box_pack_start(GTK_BOX(vbox), pListView, TRUE, TRUE, 0);
   /* ********************************** */


   /* **** Test : progress bar : 30% ** */
   GtkTreeIter pIter;

        gtk_list_store_append(pListStore, &pIter);
   gtk_list_store_set(pListStore, &pIter,0,30,-1);
   /* ********************************** */   

       gtk_widget_show_all (win);
       gtk_main ();   
}


int main( int argc, char ** argv )
{
         start_gtk(argc,argv);

   return 1;
}


Produce a good renderer but also this warnings :

Quote:
Gtk-CRITICAL **: gtk_progress_get_current_percentage: assertion `GTK_IS_PROGRESS (progress)' failed

GLib-GObject-WARNING **: invalid cast from `GtkTreeView' to `GtkProgress'



Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 5:16 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
I get a different error, but I'm guessing that they have the same cause.
Here is your code slightly modified. All of my changes/notes are marked with XXX comments:
Code:
#include <gtk/gtk.h>
#include <stdio.h>

void start_gtk(int argc, char **argv)
{
    GtkWidget *vbox;
    GtkWidget *win;

    GtkListStore *pListStore;
    GtkWidget *pListView;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(win), 0);
    gtk_window_set_title(GTK_WINDOW(win), "title");
    gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(win), 600, 400);
    gtk_widget_realize(win);
    g_signal_connect(win, "destroy", gtk_main_quit, NULL);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(win), vbox);


    /* **** Gtkliststore *************** */
    pListStore = gtk_list_store_new(1, G_TYPE_INT);
    pListView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pListStore));
    // XXX - Most likely you should unref pListStore now
    g_object_unref(pListStore);
    // /XXX

    GtkCellRenderer *pCellRenderer;
    pCellRenderer = gtk_cell_renderer_progress_new();

   // XXX - Here's your problem: After "value", which is an attribute, you need to provide
   //       the column number to map the attribute to, 0 in this case. Then you can end
   //       the function call with NULL.
   gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(pListView), 0, "Progress", pCellRenderer, "value", 0, NULL);
    /* gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(pListView), 0, "Progress", pCellRenderer, "value", NULL); */
    // /XXX
    gtk_box_pack_start(GTK_BOX(vbox), pListView, TRUE, TRUE, 0);
    /* ********************************** */


    /* **** Test : progress bar : 30% ** */
    GtkTreeIter pIter;

    gtk_list_store_append(pListStore, &pIter);
    gtk_list_store_set(pListStore, &pIter, 0, 30, -1);
    /* ********************************** */

    gtk_widget_show_all(win);
    gtk_main();
}


int main(int argc, char ** argv)
{
    start_gtk(argc, argv);

   // XXX - If you're #including stdio.h already then you may as well
   //       #include <stdlib.h> too and use EXIT_SUCCESS and EXIT_FAILURE
    return 1;
    // /XXX
}

See here for more information on my explanation of the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 6:23 pm 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Thank you very much

i don't understand the warnings
i have do the same thing like here :

http://archives.neohapsis.com/archives/ ... r_dialog.c
or
https://gnunet.org/svn/gnunet-gtk/src/plugins/fs/fs.c

And no examples in the DOC for help me


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 8:54 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
flokk wrote:
i don't understand the warnings

Which warnings would those be?

flokk wrote:
i have do the same thing like here :

It would be helpful if you can be more specific than two rather large file links.
Thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 9:46 pm 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Ok sorry

When i execute your code, i have always the same warnings, you too ?

Code:

Gtk-CRITICAL **: gtk_progress_get_current_percentage: assertion `GTK_IS_PROGRESS (progress)' failed

GLib-GObject-WARNING **: invalid cast from `GtkTreeView' to `GtkProgress'


http://archives.neohapsis.com/archives/ ... r_dialog.c

Code:
  store = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF,
    G_TYPE_STRING, GTK_TYPE_INT, GTK_TYPE_INT);
...
...
renderer = gtk_cell_renderer_progress_new();
  column = gtk_tree_view_column_new_with_attributes (_("Portscan"),
    renderer, "value", COL_PORTSCAN, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
...
...
...
gtk_list_store_set(store, &iter, COL_PORTSCAN, f, -1);


It's the same as me

So i think it's a problem with version of gtk maybe.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 10:50 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
I don't have those warnings with GTK+ 2.14.4. What version are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 7:51 pm 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Now i have installed gtk+ 2.14.4

My gtk+-2.0.pc :

Quote:
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
target=x11

gtk_binary_version=2.10.0
gtk_host=i686-pc-linux-gnu

Name: GTK+
Description: GTK+ Graphical UI Library (${target} target)
Version: 2.14.4
Requires: gdk-${target}-2.0 atk cairo gio-2.0 pangoft2
Libs: -L${libdir} -lgtk-${target}-2.0
Cflags: -I${includedir}/gtk-2.0


I have compiled the source code and always the same warnings.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 3:58 am 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
Are you sure that your program is using your new libraries?
You can check this by putting something like this in your program:
Code:
g_print("Linked GTK+ version is: %d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);

(See here for more information on version checking)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 7:43 pm 
Offline
Familiar Face

Joined: Tue Feb 24, 2009 9:37 am
Posts: 6
Quote:
Linked GTK+ version is: 2.14.4


Maybe it's pango or atk version ?

I continue to search

thank you for all


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group