LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-10-2009, 04:51 PM   #1
grumpybuffalo
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Rep: Reputation: 0
GtkCellRendererToggle toggles when clicking on other cell renderers in same column


I am working on a C++ GTK project. I have a GtkTreeView containing several columns. In the first column, I have packed in 3 cell renderers - the first, a GtkCellRendererToggle; the second, a GtkCellRendererPixbuf; the third, a GtkCellRendererText. Everything works fine, except that clicking on the text in the GtkCellRendererText causes the 'toggled' event to fire on the GtkCellRendererToggle. This is no good in this particular case. Is there any way, besides keeping track of where the mouse pointer is, to determine whether the user clicked on the checkbox itself or another cell renderer in the same column? Thanks in advance for any ideas.

Here is my code for adding the columns:

enum pkgPropDependencies_columns
{
PKG_PROP_DEPENDENCIES_COLUMN_CHECKMARK,
PKG_PROP_DEPENDENCIES_COLUMN_CHECKMARK_ENABLED,
PKG_PROP_DEPENDENCIES_COLUMN_ICON,
PKG_PROP_DEPENDENCIES_COLUMN_REQ,
PKG_PROP_DEPENDENCIES_COLUMN_PKG_INDEX,
PKG_PROP_DEPENDENCIES_COLUMN_DEP_ADDRESS,
PKG_PROP_DEPENDENCIES_COLUMN_TREE_POINT_INDEX,
PKG_PROP_DEPENDENCIES_COLUMN_DEP_LEVEL,
PKG_PROP_DEPENDENCIES_COLUMN_VERSION
};

...

void pkgPropDependencies_addColumns()
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;

/*first column - checkmark, icon & name of package + required version*/
column=gtk_tree_view_column_new();
gtk_tree_view_column_set_title(column, "Requirement");

renderer=gtk_cell_renderer_toggle_new();
g_signal_connect(renderer, "toggled", G_CALLBACK(on_pkgPropDependencies_column0_toggled), NULL);
gtk_tree_view_column_pack_start(column, renderer, false);
gtk_tree_view_column_add_attribute(column, renderer, "active", PKG_PROP_DEPENDENCIES_COLUMN_CHECKMARK);
gtk_tree_view_column_add_attribute(column, renderer, "activatable", PKG_PROP_DEPENDENCIES_COLUMN_CHECKMARK_ENABLED);

renderer=gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column, renderer, false);
gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", PKG_PROP_DEPENDENCIES_COLUMN_ICON);

renderer=gtk_cell_renderer_text_new();
g_object_set(renderer, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
gtk_tree_view_column_pack_start(column, renderer, true);
gtk_tree_view_column_add_attribute(column, renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_REQ);

gtk_tree_view_append_column(pkgPropDependencies, column);

/*second column - index of package (invisible)*/
column=gtk_tree_view_column_new();
gtk_tree_view_column_set_title(column, "Package Index");

renderer=gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, true);
gtk_tree_view_column_add_attribute(column, renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_PKG_INDEX);
column->visible=false;
gtk_tree_view_append_column(pkgPropDependencies, column);

/*third column - address of dependency (invisible)*/
column=gtk_tree_view_column_new();
gtk_tree_view_column_set_title(column, "Dependency Address");

renderer=gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, true);
gtk_tree_view_column_add_attribute(column, renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_DEP_ADDRESS);
column->visible=false;
gtk_tree_view_append_column(pkgPropDependencies, column);

/*fourth column - tree point index (invisible)*/
column=gtk_tree_view_column_new();
gtk_tree_view_column_set_title(column, "Tree Point Index");

renderer=gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, true);
gtk_tree_view_column_add_attribute(column, renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_TREE_POINT_INDEX);
column->visible=false;
gtk_tree_view_append_column(pkgPropDependencies, column);

/*fifth column - level of dependency*/
renderer=gtk_cell_renderer_text_new();
column=gtk_tree_view_column_new_with_attributes("Dependence Level", renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_DEP_LEVEL, NULL);
gtk_tree_view_append_column(pkgPropDependencies, column);

/*sixth column - name of package used to fulfill requirement, if one is needed*/
renderer=gtk_cell_renderer_combo_new();
pkgPropDependencies_depVersionComboModel=GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING));
g_object_set(GTK_CELL_RENDERER_COMBO(renderer),
"model", pkgPropDependencies_depVersionComboModel,
"has-entry", false,
"text-column", 0,
"editable", true, NULL);
g_signal_connect(renderer, "edited", G_CALLBACK(on_pkgPropDependencies_depVersionCombo_changed), NULL);
column=gtk_tree_view_column_new_with_attributes("Version to Be Installed", renderer, "text", PKG_PROP_DEPENDENCIES_COLUMN_VERSION, NULL);
gtk_tree_view_append_column(pkgPropDependencies, column);
}

Last edited by grumpybuffalo; 08-10-2009 at 04:52 PM. Reason: Forgot to say thanks.
 
Old 08-15-2009, 07:16 PM   #2
grumpybuffalo
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Original Poster
Rep: Reputation: 0
I came up with a solution.

I changed the GtkCellRendererText to a GtkCellRendererCombo. I didn't add any items to the combo or even set the model of the combo; the only property I set was the "editable" property to true. This created exactly the functionality I was looking for. The user can't even tell that the cell renderer is a combo box, because it has nothing in it. Clicking on the combo does not toggle the GtkCellRendererToggle. I suppose this is because GTK no longer considers the column one activatable entity.
 
  


Reply

Tags
c++, gtk


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read text file column by column RVF16 Programming 11 05-31-2009 07:16 AM
Concatenate column 1 and column 2 of related lines cgcamal Programming 4 11-20-2008 10:43 AM
A macro for solve insert/delete merged cell/column kstan Linux - General 0 11-02-2008 11:01 PM
Fluxbox and clicking... debnewb Debian 3 05-21-2005 11:21 AM
Clicking on a label in QT Blaktyger Programming 6 02-10-2004 12:25 AM


All times are GMT -5. The time now is 02:48 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration