Re: renderer_text == editable



Markus Lausser wrote:

Hello.

I have few problems with a GtkTreeView (file browser). I'd like it to
have to following functionality: - double left click opens the file.
- one column should be editable for renaming the file.
- right click should popup a menu.

Selection mode is GTK_SELECTION_MULTIPLE.
Now several questions:
- Is there a way to let gtk handle all the selection stuff before
 my button-press callback is called? g_signal_connect_after() seems
 to skip my function, so i do all the selection stuff in the callback
 manually before creating the popup menu.

I see you already get the GtkTreeSelection.
You can connect callback to the "changed" signal for the selection.

- What is the standard way of selecting when right clicking a row?
 Should this row be selected and all others deselected before creating
 the menu? Or should the selection be modified according to the key
 modifiers? What is a good GUI expected to do?

Sorry ...  don't know about the "standard way"

- If i double click a row then i call the open_file() function, but
 unfortunately also the cell is edited by gtk, how to prevent this?
My be you need  GtkTreeSelectionFunc () set to the selection.

Here's some of my button_press callback code (C++ style):

gboolean on_button_pressed(GtkTreeView *tv, GdkEventButton *event) {
 node_t* node;

 /* dont handle key mods */
 if (event->state) return FALSE;

 if (!gtk_tree_view_get_path_at_pos(tv, event->x, event->y,
&path, NULL, NULL, NULL)) return FALSE;

 GtkTreeModel* model = gtk_tree_view_get_model(tv);
 GtkTreeSelection* select = gtk_tree_view_get_selection (tv);

 // is current row selected? Is there a gtk function to check this?
 gboolean selected = path_selected(select, path);
gtk_tree_selection_path_is_selected (select, path)


 gtk_tree_model_get_iter(model, &iter, path);
 gtk_tree_path_free(path);

 // get the data pointer for this row
 gtk_tree_model_get (model, &iter, 0, &node, -1);

 if (event->button == 1) {
   // double left click
   if (event->type == GDK_2BUTTON_PRESS) {
     open_file(node->file->longname);
     return TRUE;
   }
   return FALSE;
 } else if (event->button == 3) {
   /* unselected selection if current node is not selected
      otherwise simply keep the current selection
   if (!selected) {
     gtk_tree_selection_unselect_all(select);
     gtk_tree_selection_select_iter(select, &iter);
   }
   pop = gui_create_popup_menu(...);
   if (pop) {
     gtk_menu_popup(GTK_MENU(pop), NULL, NULL, NULL, NULL,
                     event->button, event->time);
   }
   return TRUE;
 }
 return FALSE
}

Markus.


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]