Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7189037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:12:56+00:00 2026-05-28T19:12:56+00:00

I need to know which gtktreeview was passed to a function from the handler

  • 0

I need to know which gtktreeview was passed to a function from the handler (An identical function used for several button/treeview combinations so this is much more efficient than making a ton of different functions)

The problem is that once the function gets the treeview and has to work with it there doesn’t seem to be a way to identify it (Even based on something as simple as the amount of columns)

void
add_button_clicked(GtkTreeView * treeview,GtkButton * widget){
    GtkTreeIter iter;
    GtkListStore * store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
    gtk_list_store_append (store, &iter);

    if(items)
        gtk_list_store_set (store, &iter,
                            ITEM_COL_ENABLED, 1,
                            -1);
    else if(locations)
        gtk_list_store_set (store, &iter,
                            LOCATION_COL_NAME, "Broken Shores",
                            LOCATION_COL_ENABLED, 1,
                            -1);
}

How can I distinguish between the two?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:12:57+00:00Added an answer on May 28, 2026 at 7:12 pm

    You can attach arbitrary data to any GObject; this is often overlooked, but it’s perfect for identifying the tree views in your case. When creating the treeview, do:

    g_object_set_data(treeview, "id", GINT_TO_POINTER(1));
    

    Then in your callback:

    if(GPOINTER_TO_INT(g_object_get_data(treeview, "id")) == 1) {
        /* This is tree view #1 */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two buttons . view and viewdaywise. i need to know which button
I need to know which are the APIs/library used for multithreading by MSVC .
I need to know which Firefox version is installed on my system from command
I need to know which users are online on the website and for this
I need to know which image file type was used in the file i
im working on a student project where I need to know which button in
I need to know which stored procedures are running. It's not an option to
I need to know which views does a user have which privileges on. I'm
I need to know which physical column is associated to a persistent's attribute. e.g.
I'm writing code on the master page, and I need to know which child

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.