static VALUE iview_set_cursor(VALUE self, VALUE path, VALUE cell, VALUE start_editing) { gtk_icon_view_set_cursor(_SELF(self), RVAL2GTKTREEPATH(path), NIL_P(cell) ? NULL : RVAL2GOBJ(cell), RVAL2CBOOL(start_editing)); return self; }
/** * Crée le GtkIconView * * \param nom de l'icône * * \return le GtkIconView rempli avec l'icône sélectionnée au premier plan * * */ GtkWidget * gsb_select_icon_create_icon_view ( gchar * name_icon ) { GtkTreePath * tree_path; /* construct the GtkIconView */ icon_view = gtk_icon_view_new (); gtk_icon_view_set_margin ( GTK_ICON_VIEW ( icon_view ), 0 ); gtk_icon_view_set_spacing (GTK_ICON_VIEW ( icon_view ), 0 ); gtk_icon_view_set_selection_mode (GTK_ICON_VIEW ( icon_view ), GTK_SELECTION_SINGLE ); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW ( icon_view ), PIXBUF_COLUMN); gtk_icon_view_set_text_column (GTK_ICON_VIEW ( icon_view ), TEXT_COLUMN); /* remplissage et positionnement initial du curseur dans le GtkIconView */ tree_path = gsb_select_icon_fill_icon_view ( name_icon ); gtk_icon_view_select_path ( GTK_ICON_VIEW ( icon_view ), tree_path ); gtk_icon_view_set_cursor (GTK_ICON_VIEW ( icon_view ), tree_path, NULL, TRUE); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW ( icon_view ), tree_path, TRUE, 0.5, 0 ); return icon_view; }
static gboolean focus_in (GtkWidget *view, GdkEventFocus *event, gpointer data) { GtkTreePath *path; if (!gtk_icon_view_get_cursor (GTK_ICON_VIEW (view), &path, NULL)) { path = gtk_tree_path_new_from_indices (0, -1); gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE); } gtk_icon_view_select_path (GTK_ICON_VIEW (view), path); gtk_tree_path_free (path); return FALSE; }
static gboolean category_focus_in (GtkWidget *view, GdkEventFocus *event, CinnamonControlCenter *shell) { GtkTreePath *path; if (!gtk_icon_view_get_cursor (GTK_ICON_VIEW (view), &path, NULL)) { path = gtk_tree_path_new_from_indices (0, -1); gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE); } gtk_icon_view_select_path (GTK_ICON_VIEW (view), path); gtk_tree_path_free (path); return FALSE; }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkIconView_gtk_1icon_1view_1set_1cursor ( JNIEnv* env, jclass cls, jlong _self, jlong _path, jlong _cell, jboolean _startEditing ) { GtkIconView* self; GtkTreePath* path; GtkCellRenderer* cell; gboolean startEditing; // convert parameter self self = (GtkIconView*) _self; // convert parameter path path = (GtkTreePath*) _path; // convert parameter cell cell = (GtkCellRenderer*) _cell; // convert parameter startEditing startEditing = (gboolean) _startEditing; // call function gtk_icon_view_set_cursor(self, path, cell, startEditing); // cleanup parameter self // cleanup parameter path // cleanup parameter cell // cleanup parameter startEditing }
static void wp_remove_wallpaper (GtkWidget *widget, AppearanceData *data) { MateWPItem *item; GtkTreeIter iter; GtkTreePath *path; item = get_selected_item (data, &iter); if (item) { item->deleted = TRUE; if (gtk_list_store_remove (GTK_LIST_STORE (data->wp_model), &iter)) path = gtk_tree_model_get_path (data->wp_model, &iter); else path = gtk_tree_path_new_first (); gtk_icon_view_select_path (data->wp_view, path); gtk_icon_view_set_cursor (data->wp_view, path, NULL, FALSE); gtk_tree_path_free (path); } }
static gboolean keynav_failed (GtkWidget *view, GtkDirectionType direction, Views *views) { GtkTreePath *path; GtkTreeModel *model; GtkTreeIter iter; gint col; GtkTreePath *sel; if (view == views->view1 && direction == GTK_DIR_DOWN) { if (gtk_icon_view_get_cursor (GTK_ICON_VIEW (views->view1), &path, NULL)) { col = gtk_icon_view_get_item_column (GTK_ICON_VIEW (views->view1), path); gtk_tree_path_free (path); sel = NULL; model = gtk_icon_view_get_model (GTK_ICON_VIEW (views->view2)); gtk_tree_model_get_iter_first (model, &iter); do { path = gtk_tree_model_get_path (model, &iter); if (gtk_icon_view_get_item_column (GTK_ICON_VIEW (views->view2), path) == col) { sel = path; break; } } while (gtk_tree_model_iter_next (model, &iter)); gtk_icon_view_set_cursor (GTK_ICON_VIEW (views->view2), sel, NULL, FALSE); gtk_tree_path_free (sel); } gtk_widget_grab_focus (views->view2); return TRUE; } if (view == views->view2 && direction == GTK_DIR_UP) { if (gtk_icon_view_get_cursor (GTK_ICON_VIEW (views->view2), &path, NULL)) { col = gtk_icon_view_get_item_column (GTK_ICON_VIEW (views->view2), path); gtk_tree_path_free (path); sel = NULL; model = gtk_icon_view_get_model (GTK_ICON_VIEW (views->view1)); gtk_tree_model_get_iter_first (model, &iter); do { path = gtk_tree_model_get_path (model, &iter); if (gtk_icon_view_get_item_column (GTK_ICON_VIEW (views->view1), path) == col) { if (sel) gtk_tree_path_free (sel); sel = path; } else gtk_tree_path_free (path); } while (gtk_tree_model_iter_next (model, &iter)); gtk_icon_view_set_cursor (GTK_ICON_VIEW (views->view1), sel, NULL, FALSE); gtk_tree_path_free (sel); } gtk_widget_grab_focus (views->view1); return TRUE; } return FALSE; }
static gboolean keynav_failed (GtkIconView *current_view, GtkDirectionType direction, GnomeControlCenter *shell) { GList *views, *v; GtkIconView *new_view; GtkTreePath *path; GtkTreeModel *model; GtkTreeIter iter; gint col, c, dist, d; GtkTreePath *sel; gboolean res; res = FALSE; views = get_item_views (shell); for (v = views; v; v = v->next) { if (v->data == current_view) break; } if (direction == GTK_DIR_DOWN && v != NULL && v->next != NULL) { new_view = v->next->data; if (gtk_icon_view_get_cursor (current_view, &path, NULL)) { col = gtk_icon_view_get_item_column (current_view, path); gtk_tree_path_free (path); sel = NULL; dist = 1000; model = gtk_icon_view_get_model (new_view); gtk_tree_model_get_iter_first (model, &iter); do { path = gtk_tree_model_get_path (model, &iter); c = gtk_icon_view_get_item_column (new_view, path); d = ABS (c - col); if (d < dist) { if (sel) gtk_tree_path_free (sel); sel = path; dist = d; } else gtk_tree_path_free (path); } while (gtk_tree_model_iter_next (model, &iter)); gtk_icon_view_set_cursor (new_view, sel, NULL, FALSE); gtk_tree_path_free (sel); } gtk_widget_grab_focus (GTK_WIDGET (new_view)); res = TRUE; } if (direction == GTK_DIR_UP && v != NULL && v->prev != NULL) { new_view = v->prev->data; if (gtk_icon_view_get_cursor (current_view, &path, NULL)) { col = gtk_icon_view_get_item_column (current_view, path); gtk_tree_path_free (path); sel = NULL; dist = 1000; model = gtk_icon_view_get_model (new_view); gtk_tree_model_get_iter_first (model, &iter); do { path = gtk_tree_model_get_path (model, &iter); c = gtk_icon_view_get_item_column (new_view, path); d = ABS (c - col); if (d <= dist) { if (sel) gtk_tree_path_free (sel); sel = path; dist = d; } else gtk_tree_path_free (path); } while (gtk_tree_model_iter_next (model, &iter)); gtk_icon_view_set_cursor (new_view, sel, NULL, FALSE); gtk_tree_path_free (sel); } gtk_widget_grab_focus (GTK_WIDGET (new_view)); res = TRUE; } g_list_free (views); return res; }