GTK+ 2: Hide ComboBox item

2013-09-24 Thread Alessandro Francesconi
Hello, I’m using a GTK+ 2.16 ComboBox and I wondering if there is a way to set 
the visibility of a given element programmatically.



For example, having a ComboBox with 10 elements I want to hide (so more than 
setting it to inactive) the 3rd element, so I need a function like 


gtk_combo_box_set_visible (mycombo, 2, false)


Does it exist? Thank you

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

Re: GTK+ 2: Hide ComboBox item

2013-09-24 Thread Colomban Wendling
Le 24/09/2013 10:17, Alessandro Francesconi a écrit :
> Hello, I’m using a GTK+ 2.16 ComboBox and I wondering if there is a
> way to set the visibility of a given element programmatically.
> 
> For example, having a ComboBox with 10 elements I want to hide (so
> more than setting it to inactive) the 3rd element, so I need a
> function like
> 
> gtk_combo_box_set_visible (mycombo, 2, false)
> 
> Does it exist?

Not like this, I'm afraid.  The only way I know to do that is to use a
GtkTreeModelFilter to filter out the elements you want to hide, e.g. by
adding a "visible" column to your model and using
gtk_tree_model_filter_set_visible_column() -- or set_visible_func() with
your function handling the logic whether or not to show a row.

Of course GtkCellRenderer has a "visible" property, but it doesn't
remove the row, it only hides the renderer itself.

Hope it helps.

Regards,
Colomban



/* Little example */

#include 

enum {
  COL_TEXT,
  COL_VISIBLE,
  N_COLS
};

int
main (int argc,
  char  **argv)
{
  GtkWidget*window;
  GtkWidget*combo;
  GtkListStore *store;
  GtkTreeModel *filter;
  GtkCellRenderer  *renderer;

  gtk_init (&argc, &argv);

  /* data */
  store = gtk_list_store_new (N_COLS, G_TYPE_STRING, G_TYPE_BOOLEAN);
  gtk_list_store_insert_with_values (store, NULL, -1,
 COL_TEXT, "First row",
 COL_VISIBLE, TRUE,
 -1);
  gtk_list_store_insert_with_values (store, NULL, -1,
 COL_TEXT, "Second row",
 COL_VISIBLE, FALSE,
 -1);
  gtk_list_store_insert_with_values (store, NULL, -1,
 COL_TEXT, "Third row",
 COL_VISIBLE, TRUE,
 -1);

  /* filter */
  filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (store), NULL);
  gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (filter),
COL_VISIBLE);

  /* combo */
  combo = gtk_combo_box_new_with_model (filter);
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
  "text", COL_TEXT,
  NULL);

  /* window */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  gtk_container_add (GTK_CONTAINER (window), combo);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK+ 3.10 released

2013-09-24 Thread Allin Cottrell

On Mon, 23 Sep 2013, Matthias Clasen wrote:


GTK+ 3.10.0 is now available for download at:

http://download.gnome.org/sources/gtk+/3.10/


Thanks!  Just a few observations on the 3.10.0 package.

* I'm used to GTK defaulting to the X11 backend on my system, which 
makes sense since it has everything to support X11 and nothing to 
support any other backend. But when I ./configure the new package it 
errors out on lack of broadway support. OK, so I explicitly 
--disable-broadway-backend. Then it errors out on no backend 
selected, and I have to explicitly --enable-x11-backend. Not a big 
deal, but is this really intended?


* The build halts with an error if gobject-introspection is version 
1.34.N. Maybe this should have a configure check? Updating to 1.38.0 
fixed to the problem; not sure about 1.36.


* When running my program after updating to GTK+ 3.10 I notice that 
all icons in menus have disappeared. I updated to 
gnome-themes-standard 3.10 at the same time so I'm not sure which 
update is responsible for that. Is showing icons in menus in GTK 
possible any more? (IMO well-chosen icons for common actions can 
help the user to home in on the item they want better than 
all-text.)


Allin Cottrell




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