tree_view_set_cursor outlier case

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

 



My name is Kevin and I work in IT support. I am new to the mailing list and development in general. I have found gtk both rewarding and difficult to learn. I have especially been having a rough time with figuring out how to deactivate a cell I have set to editing with a call to gtk_tree_view_set_cursor(). Once I've set the path via this function to enable editing I am worried about a user selecting another option in the treeview with a left click and notcing that the old path still has a text field in it and can be editited. Below is the function I wrote that gets called when someone selects rename on a popup menu which is one of the choices. I use this function to set the path to the cell to enable editing, I am also controlling editing in my tree model with a boolean property which I switch on just before calling this function. I need to know how to caputure the case that the user clicks on a different tree view path mid edit before actually submitting the editing cell with the "enter" key. Here is how I enable it, how do I disable it if they click somewhere else?

void tree_select_menu_rename(GtkWidget *menuitem, gpointer userdata)
{
  GtkTreeView *view;
  GtkTreeModel *sortModel, *baseModel;
  GtkTreePath *path = NULL;
  GtkTreePath *sortPath = NULL;
  GtkTreeIter sortIter, baseIter;
  GtkTreeSelection *selection;

  view = GTK_TREE_VIEW(userdata);
  selection = gtk_tree_view_get_selection(view);
 
  if(!gtk_tree_selection_get_selected(selection, &sortModel, &sortIter)){ return;}
  gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(sortModel), &baseIter, &sortIter);
  baseModel = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(sortModel));
  gtk_tree_store_set(GTK_TREE_STORE(baseModel), &baseIter, EDITCELL, TRUE, -1);
  path = gtk_tree_model_get_path(baseModel, &baseIter);
  sortPath = gtk_tree_model_sort_convert_child_path_to_path(GTK_TREE_MODEL_SORT(sortModel), path);
  GtkTreeViewColumn *col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0);
  gtk_tree_view_set_cursor(view, sortPath, col, TRUE);



  /*FREE RESOURCES USED */
  gtk_tree_path_free(path);
  gtk_tree_path_free(sortPath);
}


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux