/** * 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 void load_themes (DialogData *data) { GFile *style_dir; GFile *data_dir; char *default_theme; GtkTreeModel *model; GtkTreeIter iter; /* local themes */ style_dir = gth_user_dir_get_file_for_read (GTH_DIR_DATA, PIX_DIR, "albumthemes", NULL); add_themes_from_dir (data, style_dir); g_object_unref (style_dir); /* system themes */ data_dir = g_file_new_for_path (WEBALBUM_DATADIR); style_dir = _g_file_get_child (data_dir, "albumthemes", NULL); add_themes_from_dir (data, style_dir); g_object_unref (style_dir); g_object_unref (data_dir); /**/ gtk_widget_set_size_request (GET_WIDGET ("theme_iconview"), (150 * 3), 140); gtk_widget_realize (GET_WIDGET ("theme_iconview")); default_theme = g_settings_get_string (data->settings, PREF_WEBALBUMS_THEME); model = GTK_TREE_MODEL (GET_WIDGET ("theme_liststore")); if (gtk_tree_model_get_iter_first (model, &iter)) { do { char *name; gtk_tree_model_get(model, &iter, THEME_COLUMN_ID, &name, -1); if (g_strcmp0 (name, default_theme) == 0) { GtkTreePath *path; path = gtk_tree_model_get_path (model, &iter); gtk_icon_view_select_path (GTK_ICON_VIEW (GET_WIDGET ("theme_iconview")), path); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (GET_WIDGET ("theme_iconview")), path, TRUE, 0.5, 0.5); gtk_tree_path_free (path); g_free (name); break; } g_free (name); } while (gtk_tree_model_iter_next (model, &iter)); } g_free (default_theme); }
static VALUE iview_scroll_to_path(VALUE self, VALUE path, VALUE use_align, VALUE row_align, VALUE col_align) { gtk_icon_view_scroll_to_path(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2CBOOL(use_align), NUM2DBL(row_align), NUM2DBL(col_align)); return self; }
static void theme_select_iter (GtkIconView *icon_view, GtkTreeIter *iter) { GtkTreePath *path; path = gtk_tree_model_get_path (gtk_icon_view_get_model (icon_view), iter); gtk_icon_view_select_path (icon_view, path); gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.5, 0.0); gtk_tree_path_free (path); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkIconView_gtk_1icon_1view_1scroll_1to_1path ( JNIEnv* env, jclass cls, jlong _self, jlong _path, jboolean _useAlign, jfloat _rowAlign, jfloat _colAlign ) { GtkIconView* self; GtkTreePath* path; gboolean useAlign; gfloat rowAlign; gfloat colAlign; // convert parameter self self = (GtkIconView*) _self; // convert parameter path path = (GtkTreePath*) _path; // convert parameter useAlign useAlign = (gboolean) _useAlign; // convert parameter rowAlign rowAlign = (gfloat) _rowAlign; // convert parameter colAlign colAlign = (gfloat) _colAlign; // call function gtk_icon_view_scroll_to_path(self, path, useAlign, rowAlign, colAlign); // cleanup parameter self // cleanup parameter path // cleanup parameter useAlign // cleanup parameter rowAlign // cleanup parameter colAlign }
static void select_item(AppearanceData* data, MateWPItem* item, gboolean scroll) { GtkTreePath* path; g_return_if_fail(data != NULL); if (item == NULL) return; path = gtk_tree_row_reference_get_path(item->rowref); gtk_icon_view_select_path(data->wp_view, path); if (scroll) { gtk_icon_view_scroll_to_path(data->wp_view, path, FALSE, 0.5, 0.0); } gtk_tree_path_free(path); }
/** * callback pour traiter les changements dans le GtkComboBoxEntry * * \param le GtkComboBoxEntry appellant * * \return void * * */ void gsb_select_icon_entry_text_changed ( GtkComboBoxEntry *entry, gpointer user_data ) { GtkTreePath *path; const gchar *tmpstr; gchar *ptr; tmpstr = gtk_entry_get_text ( GTK_ENTRY (GTK_BIN (entry_text)->child ) ); devel_debug ( tmpstr ); ptr = g_strstr_len ( tmpstr, -1, path_icon ); if ( ptr == NULL ) { if ( g_file_test ( tmpstr, G_FILE_TEST_IS_DIR ) ) { path_icon = g_strdup ( tmpstr ); path = gsb_select_icon_fill_icon_view ( NULL ); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW ( icon_view ), path, TRUE, 0.5, 0 ); gtk_widget_set_sensitive (bouton_OK, FALSE ); } } }
/** * Crée le dialogue pour le choix du nouveau répertoire et entre le choix * dans le GtkComboBoxEntry * * \param bouton appelant * * \return void * * */ void gsb_select_icon_create_file_chooser ( GtkWidget * button, gpointer user_data ) { GtkWidget *chooser; GtkFileFilter *filter; chooser = gtk_file_chooser_dialog_new ( _("Select icon directory"), GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_window_set_position ( GTK_WINDOW (chooser), GTK_WIN_POS_CENTER_ON_PARENT ); gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (dialog)); gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE); gtk_widget_set_size_request ( chooser, 600, 750 ); filter = gtk_file_filter_new (); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter); gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER ( chooser ), path_icon ); if (gtk_dialog_run (GTK_DIALOG ( chooser ) ) == GTK_RESPONSE_ACCEPT ) { GtkTreePath *path; path_icon = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( chooser ) ); devel_debug ( path_icon ); path = gsb_select_icon_fill_icon_view ( NULL ); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW ( icon_view ), path, TRUE, 0.5, 0 ); gsb_select_icon_add_path ( ); gtk_entry_set_text ( GTK_ENTRY (GTK_BIN (entry_text)->child ), path_icon ); gtk_widget_set_sensitive (bouton_OK, FALSE ); } gtk_widget_destroy ( chooser ); }
static void cheese_thumb_view_append_item (CheeseThumbView *thumb_view, GFile *file) { CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view); GtkTreeIter iter; GtkIconTheme *icon_theme; GdkPixbuf *pixbuf = NULL; GtkTreePath *path; char *filename, *basename; GError *error = NULL; gboolean skip = FALSE; GFileInfo *info; goffset size; CheeseThumbViewIdleData *data; info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, NULL); if (!info) { /* This is normal since photos first get created with a tmpname, ie: * "2013-06-13-113155.jpg.DQRGYW" and then moved to their final name, * we will get another append_item call for the final name. */ return; } size = g_file_info_get_size (info); g_object_unref (info); /* Ignore 0-sized files, bug 677735. */ if (size == 0) return; filename = g_file_get_path (file); if (!(g_str_has_suffix (filename, CHEESE_PHOTO_NAME_SUFFIX)) && !(g_str_has_suffix (filename, CHEESE_VIDEO_NAME_SUFFIX)) && !(g_str_has_suffix (filename, CHEESE_OLD_VIDEO_NAME_SUFFIX))) { g_free (filename); return; } if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter)) { gchar *col_filename; /* check if the selected item is the first, else go through the store */ gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, THUMBNAIL_URL_COLUMN, &col_filename, -1); /* FIXME: col_filename is in GLib filename encoding, not ASCII. */ if (g_ascii_strcasecmp (col_filename, filename)) { while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter)) { g_free (col_filename); gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, THUMBNAIL_URL_COLUMN, &col_filename, -1); /* FIXME: col_filename is in GLib filename encoding, not ASCII. */ if (!g_ascii_strcasecmp (col_filename, filename)) { skip = TRUE; break; } } } else { skip = TRUE; } g_free (col_filename); g_free (filename); if (skip) return; } else { g_free (filename); } if (priv->multiplex_thumbnail_generator) { gchar *f; f = g_strdup_printf ("/org/gnome/Cheese/pixmaps/cheese-%i.svg", g_random_int_range (1, 4)); pixbuf = gdk_pixbuf_new_from_resource (f, NULL); g_free (f); } else { icon_theme = gtk_icon_theme_get_default (); pixbuf = gtk_icon_theme_load_icon (icon_theme, "image-loading", 96, GTK_ICON_LOOKUP_GENERIC_FALLBACK, &error); } if (!pixbuf) { g_warning ("Couldn't load icon: %s", error->message); g_error_free (error); error = NULL; } filename = g_file_get_path (file); basename = g_path_get_basename (filename); gtk_list_store_append (priv->store, &iter); gtk_list_store_set (priv->store, &iter, THUMBNAIL_PIXBUF_COLUMN, pixbuf, THUMBNAIL_URL_COLUMN, filename, THUMBNAIL_BASENAME_URL_COLUMN, basename, -1); g_free (filename); g_free (basename); path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter); gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (thumb_view), path, TRUE, 1.0, 0.5); gtk_tree_path_free (path); if (pixbuf) g_object_unref (pixbuf); if (!priv->multiplex_thumbnail_generator) { data = g_slice_new0 (CheeseThumbViewIdleData); data->thumb_view = g_object_ref (thumb_view); data->file = g_object_ref (file); data->iter = iter; g_queue_push_tail (priv->thumbnails, data); if (!priv->idle_id) g_idle_add (cheese_thumb_view_idle_append_item, priv->thumbnails); } }
static void theme_set_custom_from_theme (const MateThemeMetaInfo *info, AppearanceData *data) { MateThemeMetaInfo *custom = data->theme_custom; GtkIconView *icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list")); GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; if (info == custom) return; /* if info is not NULL, we'll copy those theme settings over */ if (info != NULL) { g_free (custom->gtk_theme_name); g_free (custom->icon_theme_name); g_free (custom->marco_theme_name); g_free (custom->gtk_color_scheme); g_free (custom->cursor_theme_name); g_free (custom->application_font); custom->gtk_color_scheme = NULL; custom->application_font = NULL; /* these settings are guaranteed to be non-NULL */ custom->gtk_theme_name = g_strdup (info->gtk_theme_name); custom->icon_theme_name = g_strdup (info->icon_theme_name); custom->marco_theme_name = g_strdup (info->marco_theme_name); custom->cursor_theme_name = g_strdup (info->cursor_theme_name); custom->cursor_size = info->cursor_size; /* these can be NULL */ if (info->gtk_color_scheme) custom->gtk_color_scheme = g_strdup (info->gtk_color_scheme); else custom->gtk_color_scheme = get_default_string_from_key (data->client, COLOR_SCHEME_KEY); if (info->application_font) custom->application_font = g_strdup (info->application_font); else custom->application_font = get_default_string_from_key (data->client, APPLICATION_FONT_KEY); } /* select the custom theme */ model = gtk_icon_view_get_model (icon_view); if (!theme_find_in_model (model, custom->name, &iter)) { GtkTreeIter child; gtk_list_store_insert_with_values (data->theme_store, &child, 0, COL_LABEL, custom->readable_name, COL_NAME, custom->name, COL_THUMBNAIL, data->theme_icon, -1); gtk_tree_model_sort_convert_child_iter_to_iter ( GTK_TREE_MODEL_SORT (model), &iter, &child); } path = gtk_tree_model_get_path (model, &iter); gtk_icon_view_select_path (icon_view, path); gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.5, 0.0); gtk_tree_path_free (path); /* update the theme thumbnail */ theme_thumbnail_generate (custom, data); }