GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Dec 21, 2014 11:58 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: list_boxes and headers
PostPosted: Sun Nov 17, 2013 4:46 am 
Offline
Familiar Face

Joined: Sat Nov 16, 2013 4:04 am
Posts: 5
Hello everyone. I want to start by saying I'm no where near an accomplished programmer.(newbie!) I just started C a couple months back on my own and now I'm digging into creating my own app with gtk+3 so I'm learning the libs as I go.

Here's the question. I've got a container GtkListBox to show inside of the action section of a GtkDialog window but what I can't figure out is how to add headers to it. I'm not completely understanding how to add/update a header for specific row. Does anyone have experience with this container that can help explain a little clearer how adding headers work?


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Tue Nov 19, 2013 9:03 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 799
Location: UK
Hello,

Your question is very confused. You state that you have a GtkListBox, but that widget not does exist in GTK.

If you can explain what you really have I can then help you. Even a section of code to show what you are doing so far can help.

_________________
E.


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Tue Nov 19, 2013 1:16 pm 
Offline
Familiar Face

Joined: Sat Nov 16, 2013 4:04 am
Posts: 5
errol wrote:
Hello,

Your question is very confused. You state that you have a GtkListBox, but that widget not does exist in GTK.

If you can explain what you really have I can then help you. Even a section of code to show what you are doing so far can help.



Sorry about that. Actually the GtkListBox is packed inside a scrolled window which is packed inside a dialog box. In the gtk+-3.10.4 reference manual under the section GtkContainers there is a GtkListBox container. That's the GtkWidget I'm referring to. I think it's a recent addition to libs. I will post some code when I get to the laptop later today.


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Tue Nov 19, 2013 1:56 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 799
Location: UK
I just spotted it. It is a new widget introduced in v3.10. So probably not going to be available in many people's distros yet.

I am using Debian testing and even that has only got to Gtk v3.8.4

_________________
E.


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Tue Nov 19, 2013 5:03 pm 
Offline
Familiar Face

Joined: Sat Nov 16, 2013 4:04 am
Posts: 5
Yea I'm using Arch so it comes with the latest gtk+-3.x libs. Didn't even know it was recently added until I needed something like the GtkListBox container and saw it was added in the reference manual when I updated Arch.


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Tue Nov 19, 2013 6:50 pm 
Offline
Familiar Face

Joined: Sat Nov 16, 2013 4:04 am
Posts: 5
It seems to use a pointer to a function.
To change/update headers:
Code:
gtk_list_box_row_set_header(GtkListBoxRow *row, GtkWidget *header);

which can only be called from:
Code:
void (*GtkLIstBoxUpdateHeaderFunc) (GtkListBoxRow *row,  GtkListBoxRow *before,  gpointer user_data);


I'm a lttle confused on how to use this.


Top
 Profile  
 
 Post subject: Re: list_boxes and headers
PostPosted: Wed Nov 20, 2013 6:10 pm 
Offline
Familiar Face

Joined: Sat Nov 16, 2013 4:04 am
Posts: 5
Here is the section of code I'm using so far for the GtkListBox:

Code:
GtkWidget *listBox, *row, *header;
GtkWidget *dialog;
GtkWidget *window;

static void insertChord(GtkWidget *widget, gpointer data)
{   
   GtkTextMark *cursor;
   GtkWidget *scrolledWindow;
   GtkWidget *frame, *dialog, *topHalf, *bottomHalf, *label;
   /* GtkWidget *treeView; */
   /* GtkTreeViewColumn *column;
   GtkCellRenderer *cell; */
   GtkTextIter iter;
   /* GtkTreeIter listIter; */
                                 
   /* cell = gtk_cell_renderer_text_new();
   listStore = gtk_list_store_new(1, G_TYPE_STRING);
   treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(listStore));   */
   cursor = gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(buffer));   /* Assigns cursor variable to the actual cursor within buffer */
   scrolledWindow = gtk_scrolled_window_new(NULL, NULL);   
   /* column = gtk_tree_view_column_new_with_attributes(NULL, cell, "text", 0, NULL); */
   frame = gtk_frame_new("Chord");      
   dialog = gtk_dialog_new();
   topHalf = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
   bottomHalf = gtk_dialog_get_action_area(GTK_DIALOG(dialog));   
   label = gtk_label_new("Choose Chord");
   listBox = gtk_list_box_new();
   row = gtk_list_box_row_new();
         
   /* gtk_list_store_append(GTK_LIST_STORE(listStore), &listIter);
   gtk_list_store_set(GTK_LIST_STORE(listStore), &listIter, 0, "A", -1);   
   gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), column);
   
   gtk_cell_renderer_activate(GTK_CELL_RENDERER(cell), button, GTK_WIDGET(treeView), ); */   
   
   gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
   
   /* Sets cursor to visible. I think it's set by default but adding it to make sure */
   gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textView), TRUE);
   
   /* Inserts string inside "..." at cursor location */
   gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(buffer), "[]", 2);
   
   /* Initializes variable 'iter' */   
   gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(buffer), &iter, cursor);
   
   /* Moves cursor back one space */
   gtk_text_iter_backward_chars(&iter, 1);   
   gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(buffer), &iter);
   
   /* Sets properties of frame & dialog widgets */   
   gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
   gtk_widget_set_size_request(dialog, 200, 200);   
   gtk_widget_set_size_request(frame, 190, 190);
   
   gtk_list_box_prepend(GTK_LIST_BOX(listBox), row);
   gtk_list_box_row_set_header(GTK_LIST_BOX_ROW(row), header);
   
   /* Pack widgets */
   gtk_container_add(GTK_CONTAINER(scrolledWindow), listBox);
   gtk_container_add(GTK_CONTAINER(frame), scrolledWindow);
   gtk_container_add(GTK_CONTAINER(topHalf), label);
   gtk_container_add(GTK_CONTAINER(bottomHalf), frame);
         
   gtk_widget_show_all(dialog);
}


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

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 4 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