Exemple #1
0
void _fcitx_main_window_selection_changed_cb(GtkIconView* iconview, gpointer data)
{
    GtkTreeModel *model = gtk_icon_view_get_model(iconview);
    GtkTreeIter iter;
    ConfigPage* page;
    FcitxMainWindow* self = data;

    GList* list = gtk_icon_view_get_selected_items(iconview);

    if (list) {
        gchar* title;
        gtk_tree_model_get_iter(GTK_TREE_MODEL(self->pagestore), &iter, (GtkTreePath*)(list->data));
        gtk_tree_model_get(model, &iter,
                           PAGE_LIST_NAME, &title,
                           PAGE_LIST_PAGE, &page,
                           -1);

        gchar* text = g_strdup_printf("<b>%s</b>", title);
        gtk_label_set_markup(GTK_LABEL(self->pagelabel), text);
        g_free(text);
        g_free(title);

        if (self->lastpage)
            gtk_container_remove(GTK_CONTAINER(self->vbox), self->lastpage->page);
        gtk_box_pack_end(GTK_BOX(self->vbox), page->page, TRUE, TRUE, 0);
        gtk_widget_show_all(GTK_WIDGET(self));

        self->lastpage = page;
    }

    g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
    g_list_free (list);
}
static void
iconview_item_activated_cb (GtkIconView     *icon_view,
                            GtkTreePath     *path,
                            CcShellItemView *cc_view)
{
  GtkTreeModel *model;
  GtkTreeIter iter;
  gchar *name, *id;

  model = gtk_icon_view_get_model (icon_view);

  gtk_icon_view_unselect_all (icon_view);

  /* get the iter and ensure it is valid */
  if (!gtk_tree_model_get_iter (model, &iter, path))
    return;

  gtk_tree_model_get (model, &iter,
                      COL_NAME, &name,
                      COL_ID, &id,
                      -1);

  g_signal_emit (cc_view, signals[DESKTOP_ITEM_ACTIVATED], 0,
                 name, id);

  g_free (name);
  g_free (id);
}
Exemple #3
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkIconView_gtk_1icon_1view_1get_1model
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	GtkTreeModel* result;
	jlong _result;
	GtkIconView* self;

	// convert parameter self
	self = (GtkIconView*) _self;

	// call function
	result = gtk_icon_view_get_model(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, FALSE);
	}

	// and finally
	return _result;
}
Exemple #4
0
static void
eog_thumb_view_dispose (GObject *object)
{
	EogThumbViewPrivate *priv = EOG_THUMB_VIEW (object)->priv;
	GtkTreeModel *model;

	if (priv->visible_range_changed_id != 0) {
		g_source_remove (priv->visible_range_changed_id);
		priv->visible_range_changed_id = 0;
	}

	model = gtk_icon_view_get_model (GTK_ICON_VIEW (object));

	if (model && priv->image_add_id != 0) {
		g_signal_handler_disconnect (model, priv->image_add_id);
		priv->image_add_id = 0;
	}

	if (model && priv->image_removed_id) {
		g_signal_handler_disconnect (model, priv->image_removed_id);
		priv->image_removed_id = 0;
	}

	G_OBJECT_CLASS (eog_thumb_view_parent_class)->dispose (object);
}
static HCPApp *
hcp_app_view_get_selected_app (GtkWidget *widget, GtkTreePath *path)
{
  GtkTreeModel *model;
  HCPApp *app = NULL;
  GtkTreeIter iter;
  gint item_pos;

  g_return_val_if_fail (widget, NULL);
  g_return_val_if_fail (GTK_IS_ICON_VIEW (widget), NULL);
  g_return_val_if_fail (path, NULL);

  model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget));

  if (path == NULL) return NULL;

  item_pos = gtk_tree_path_get_indices (path) [0];

  if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (model), 
                                     &iter, NULL, item_pos)) {
    gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 
                        HCP_STORE_APP, &app,
                        -1);
  }

  return app;
}
Exemple #6
0
/* Update selected project */
static void
on_druid_project_update_selected (GtkIconView* view, NPWDruid *druid)
{
	GList *selected;
	NPWHeader* header = NULL;

	/* No item can be selected when the view is mapped */
	selected = gtk_icon_view_get_selected_items (view);
	if (selected != NULL)
	{
		GtkTreeIter iter;
		GtkTreeModel *model;

		model = gtk_icon_view_get_model (view);
		if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)selected->data))
		{
			gtk_tree_model_get	(model, &iter, DATA_COLUMN, &header, -1);
		}
		gtk_tree_path_free ((GtkTreePath *)selected->data);
		g_list_free (selected);
	}

	druid->header = header;
	gtk_assistant_set_page_complete (GTK_ASSISTANT (druid->window), druid->project_page, header != NULL);
}
Exemple #7
0
/**
 * callback pour traiter les changements de sélection dans le GtkIconView
 *
 * \param le GtkIconView appellant
 *
 * \return
 *
 * */
void gsb_select_icon_selection_changed ( GtkIconView *icon_view,
                                         gpointer user_data )
{
    GList * liste;
    GtkTreePath *path;
    GtkTreeModel *model;
    GtkTreeIter iter;
    gchar *name_icon = NULL;

    liste = gtk_icon_view_get_selected_items ( GTK_ICON_VIEW ( icon_view ) );

    /* Could happen if selection is unset, exiting then. */
    if ( ! liste )
	return;

    path = liste -> data;

    model = gtk_icon_view_get_model ( GTK_ICON_VIEW ( icon_view ) );
    if (gtk_tree_model_get_iter ( GTK_TREE_MODEL (model), &iter, path ))
        gtk_tree_model_get (model, &iter, TEXT_COLUMN, &name_icon, -1);
    name_icon = my_strdelimit ( name_icon, "\n", "" );
    devel_debug ( name_icon );
    if ( name_icon && strlen ( name_icon ) > 0 )
    {
        new_icon = g_strconcat ( path_icon, G_DIR_SEPARATOR_S,
                                 name_icon, NULL );
        gtk_entry_set_text ( GTK_ENTRY (GTK_BIN (entry_text)->child ),
                                 new_icon );
        gtk_widget_set_sensitive (bouton_OK, TRUE );
    }
}
Exemple #8
0
static void
ok_button_clicked_cb (GtkWidget  *widget,
		      DialogData *data)
{
	GList *list;

	list = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (data->icon_view));
	if (list != NULL) {
		GtkTreePath  *path;
		GtkTreeModel *model;
		GtkTreeIter   iter;

		path = list->data;
		model = gtk_icon_view_get_model (GTK_ICON_VIEW (data->icon_view));
		if (gtk_tree_model_get_iter (model, &iter, path)) {
			GdkPixbuf *image;

			gtk_tree_model_get (model, &iter, IMAGE_COLUMN, &image, -1);
			goo_window_set_cover_image_from_pixbuf (data->window, image);

			g_object_unref (image);
		}

		g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
		g_list_free (list);
	}
}
Exemple #9
0
static void
add_n_items (GtkIconView *icon_list, gint n)
{
  static gint count = NUMBER_OF_ITEMS;

  GtkTreeIter iter;
  GtkListStore *store;
  GdkPixbuf *pixbuf;
  gchar *str, *str2;
  gint i;

  store = GTK_LIST_STORE (gtk_icon_view_get_model (icon_list));
  pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);


  for (i = 0; i < n; i++)
    {
      str = g_strdup_printf ("Icon %d", count);
      str2 = g_strdup_printf ("Icon <b>%d</b>", count);	
      gtk_list_store_prepend (store, &iter);
      gtk_list_store_set (store, &iter,
			  0, pixbuf,
			  1, str,
			  2, i,
			  3, str2,
			  -1);
      g_free (str);
      g_free (str2);
      count++;
    }
}
static CcBackgroundItem *
get_selected_item (CcBackgroundPanel *panel)
{
  CcBackgroundPanelPrivate *priv = panel->priv;
  GtkIconView *icon_view;
  GtkTreeIter iter;
  GtkTreeModel *model;
  GList *list;
  CcBackgroundItem *item;

  icon_view = GTK_ICON_VIEW (WID ("backgrounds-iconview"));
  item = NULL;
  list = gtk_icon_view_get_selected_items (icon_view);

  if (!list)
    return NULL;

  model = gtk_icon_view_get_model (icon_view);

  if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath*) list->data) == FALSE)
    goto bail;

  gtk_tree_model_get (model, &iter, 1, &item, -1);

bail:
  g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
  g_list_free (list);

  return item;
}
static void
hcp_app_view_add_app (HCPApp *app, HCPGrid *grid)
{
  GtkTreeModel *store;
  GtkTreePath *path;
  GtkTreeIter iter;
  gchar *name = NULL;
  gchar *text_domain = NULL;

  store = gtk_icon_view_get_model (GTK_ICON_VIEW (grid));

  g_object_get (G_OBJECT (app),
                "name", &name,
                "text-domain", &text_domain,
                NULL); 

  gtk_list_store_append (GTK_LIST_STORE (store), &iter);

  gtk_list_store_set (GTK_LIST_STORE (store), &iter, 
                      HCP_STORE_LABEL, ((text_domain && *text_domain) ? 
			                dgettext(text_domain, name) : _(name)),
                      HCP_STORE_APP, app,
                      -1);

  path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);

  g_object_set (G_OBJECT (app),
                "grid", grid,
                "item-pos", gtk_tree_path_get_indices (path) [0],
                NULL);

  gtk_tree_path_free (path);

  g_free (name);
}
Exemple #12
0
/*
 * Get the file URI for the tree path in the icon view.
 *
 * RETURN: a string with the URI in it. It must be free()'d.
 */
char *
tree_path_file_uri(GtkIconView *icon_view, GtkTreePath *path)
{
	gchar		*directory, *fileuri, *name;
	GError		*error;
	GtkTreeModel	*model;
	GtkTreeIter	 iter;

	error = NULL;

	if ((model = gtk_icon_view_get_model(icon_view)) == NULL)
		errx(66, "could not find the model for the icon view");

	gtk_tree_model_get_iter(model, &iter, path);

	gtk_tree_model_get(model, &iter,
	    FILE_NAME, &name,
	    FILE_PARENT, &directory,
	    -1);

	fileuri = g_strdup_printf("file://%s/%s", directory, name);

	g_free(name);
	g_free(directory);

	return fileuri;
}
Exemple #13
0
static void
eom_thumb_view_dispose (GObject *object)
{
	EomThumbViewPrivate *priv = EOM_THUMB_VIEW (object)->priv;
#if GTK_CHECK_VERSION (3, 4, 3)
	GtkTreeModel *model;
#endif

	if (priv->visible_range_changed_id != 0) {
		g_source_remove (priv->visible_range_changed_id);
		priv->visible_range_changed_id = 0;
	}

#if GTK_CHECK_VERSION (3, 4, 3)
	model = gtk_icon_view_get_model (GTK_ICON_VIEW (object));

	if (model && priv->image_add_id != 0) {
		g_signal_handler_disconnect (model, priv->image_add_id);
		priv->image_add_id = 0;
	}

	if (model && priv->image_removed_id) {
		g_signal_handler_disconnect (model, priv->image_removed_id);
		priv->image_removed_id = 0;
	}
#endif

	G_OBJECT_CLASS (eom_thumb_view_parent_class)->dispose (object);
}
Exemple #14
0
/* settings_get_model */
static GtkTreeModel * _settings_get_model(Settings * settings)
{
	GtkTreeModel * model;

	model = gtk_icon_view_get_model(GTK_ICON_VIEW(settings->view));
	model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(model));
	return gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
}
Exemple #15
0
static void
start_loading_files (DialogData *data)
{
	gtk_list_store_clear (GTK_LIST_STORE (gtk_icon_view_get_model (GTK_ICON_VIEW (data->icon_view))));
	data->total_files = g_list_length (data->file_list);
	data->current_file = data->file_list;
	data->loaded_files = 0;
	load_current_file (data);
}
static void
theme_select_name (GtkIconView *icon_view, const gchar *theme)
{
  GtkTreeIter iter;
  GtkTreeModel *model = gtk_icon_view_get_model (icon_view);

  if (theme_find_in_model (model, theme, &iter))
    theme_select_iter (icon_view, &iter);
}
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);
}
static void
gwy_app_file_chooser_update_preview(GwyAppFileChooser *chooser)
{
    GtkFileChooser *fchooser;
    GtkTreeModel *model;
    GdkPixbuf *pixbuf;
    GtkTreeIter iter;
    gchar *filename_sys;

    gwy_app_file_chooser_free_preview(chooser);

    model = gtk_icon_view_get_model(GTK_ICON_VIEW(chooser->preview));
    gtk_list_store_clear(GTK_LIST_STORE(model));

    fchooser = GTK_FILE_CHOOSER(chooser);
    filename_sys = gtk_file_chooser_get_preview_filename(fchooser);
    /* It should be UTF-8, but don't convert it just for gwy_debug() */
    gwy_debug("%s", filename_sys);

    /* Make directories fail gracefully */
    if (filename_sys && g_file_test(filename_sys, G_FILE_TEST_IS_DIR)) {
        g_free(filename_sys);
        filename_sys = NULL;
    }
    /* Never set the preview inactive.  Gtk+ can do all kinds of silly things
     * if you do. */
    if (!filename_sys)
        return;

    pixbuf = _gwy_app_recent_file_try_thumbnail(filename_sys);
    g_free(filename_sys);

    if (!pixbuf) {
        pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
        gdk_pixbuf_fill(pixbuf, 0x00000000);
        chooser->make_thumbnail = TRUE;
    }
    else
        chooser->make_thumbnail = FALSE;

    g_object_set(chooser->renderer_fileinfo,
                 "ellipsize", PANGO_ELLIPSIZE_NONE,
                 "wrap-width", TMS_NORMAL_THUMB_SIZE,
                 NULL);
    gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter, -1,
                                      COLUMN_PIXBUF, pixbuf,
                                      COLUMN_FILEINFO, _("…"),
                                      -1);
    g_object_unref(pixbuf);

    chooser->full_preview_id
        = g_timeout_add_full(G_PRIORITY_LOW, 250,
                             gwy_app_file_chooser_do_full_preview, chooser,
                             NULL);
}
static EAttachmentStore *
attachment_icon_view_get_store (EAttachmentView *view)
{
	GtkIconView *icon_view;
	GtkTreeModel *model;

	icon_view = GTK_ICON_VIEW (view);
	model = gtk_icon_view_get_model (icon_view);

	return E_ATTACHMENT_STORE (model);
}
Exemple #20
0
static void icon_view_select__(GtkIconView *view, const char* code3 = NULL, void* shangji = NULL, void* ce = NULL) {
	GtkTreeModel *model = gtk_icon_view_get_model (view);

	GList *list = gtk_icon_view_get_selected_items (view);
	if (list == NULL) return;

	for (GList *cur = g_list_first(list); cur != NULL; cur = g_list_next(cur)) {
		call_item__(get_id__(model, (GtkTreePath *)cur->data), code3 ? 2 : 0, code3, shangji, ce);
	}

	g_list_free (list);
}
Exemple #21
0
static GtkTreeModel *
gtk_cell_layout_get_model (GtkCellLayout *layout)
{
  if (GTK_IS_TREE_VIEW_COLUMN (layout))
    return gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view (GTK_TREE_VIEW_COLUMN (layout))));
  else if (GTK_IS_ICON_VIEW (layout))
    return gtk_icon_view_get_model (GTK_ICON_VIEW (layout));
  else if (GTK_IS_COMBO_BOX (layout)) 
    return gtk_combo_box_get_model (GTK_COMBO_BOX (layout));
  else
    return NULL;
}
Exemple #22
0
static void cb_item_activated(GtkIconView *iconview, GtkTreePath *treepath, gpointer user_data)
{
  GtkListStore *store;
  GtkTreeIter iter;
  gchar *name;

  store = GTK_LIST_STORE(gtk_icon_view_get_model(iconview));
  //クリックされたアイテムに対するGtkTreeIterの値を取得
  gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath);
  gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, COLUMN_NAME, &name, -1);
  g_print( "item '%s' is clicked.\n", name);
  g_free(name);
}
Exemple #23
0
static void
swap_rows (GtkWidget *button, GtkIconView *icon_list)
{
  GtkTreeIter iter, iter2;
  GtkTreeModel *model;

  model = gtk_icon_view_get_model (icon_list);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), -2, GTK_SORT_ASCENDING);

  gtk_tree_model_get_iter_first (model, &iter);
  iter2 = iter;
  gtk_tree_model_iter_next (model, &iter2);
  gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter2);
}
Exemple #24
0
static char *
cheese_thumb_view_get_url_from_path (CheeseThumbView *thumb_view, GtkTreePath *path)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;
  char         *file;

  model = gtk_icon_view_get_model (GTK_ICON_VIEW (thumb_view));
  gtk_tree_model_get_iter (model, &iter, path);

  gtk_tree_model_get (model, &iter, THUMBNAIL_URL_COLUMN, &file, -1);

  return file;
}
Exemple #25
0
static void
cell_edited (GtkCellRendererToggle *cell_renderer,
	     const gchar           *path,
	     const gchar           *new_text,
	     GtkIconView      *iconview)
{
  GtkTreeModel *model = gtk_icon_view_get_model (iconview);
  GtkTreeIter   iter;

  g_print ("Cell edited with new text '%s' !\n", new_text);

  if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
    return;

  gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_NAME, new_text, -1);
}
Exemple #26
0
static void
item_activated (GtkIconView *icon_view,
		GtkTreePath *path)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  gchar *text;

  model = gtk_icon_view_get_model (icon_view);
  gtk_tree_model_get_iter (model, &iter, path);

  gtk_tree_model_get (model, &iter, 1, &text, -1);
  g_print ("Item activated, text is %s\n", text);
  g_free (text);
  
}
Exemple #27
0
/* settings_get_iter */
static gboolean _settings_get_iter(Settings * settings, GtkTreeIter * iter,
		GtkTreePath * path)
{
	GtkTreeModel * model;
	GtkTreeIter p;

	model = gtk_icon_view_get_model(GTK_ICON_VIEW(settings->view));
	if(gtk_tree_model_get_iter(model, iter, path) == FALSE)
		return FALSE;
	gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(
				model), &p, iter);
	model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(model));
	gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(
				model), iter, &p);
	return TRUE;
}
Exemple #28
0
static void
cheese_thumb_view_on_drag_data_get_cb (GtkIconView      *thumb_view,
                                       GdkDragContext   *drag_context,
                                       GtkSelectionData *data,
                                       guint             info,
                                       guint             time,
                                       gpointer          user_data)
{
  GList        *list, *l;
  GtkTreeIter   iter;
  GtkTreeModel *model;
  char         *str;
  char         *uris = NULL;
  char         *tmp_str;

  list  = gtk_icon_view_get_selected_items (thumb_view);
  model = gtk_icon_view_get_model (thumb_view);

  for (l = list; l != NULL; l = l->next)
  {
    gtk_tree_model_get_iter (model, &iter, l->data);
    gtk_tree_model_get (model, &iter, 1, &str, -1);
    gtk_tree_path_free (l->data);

    /* we always store local paths in the model, but DnD
     * needs URIs, so we must add file:// to the path.
     */

    /* build the "text/uri-list" string */
    if (uris)
    {
      tmp_str = g_strconcat (uris, "file://", str, "\r\n", NULL);
      g_free (uris);
    }
    else
    {
      tmp_str = g_strconcat ("file://", str, "\r\n", NULL);
    }
    uris = tmp_str;

    g_free (str);
  }
  gtk_selection_data_set (data, gtk_selection_data_get_target (data),
                          8, (guchar *) uris, strlen (uris));
  g_free (uris);
  g_list_free (list);
}
Exemple #29
0
Fichier : main.c Projet : S010/misc
void
populate_icon_view(GtkWidget *widget, fsnode_t *node) {
    GtkListStore *list_store;
    GtkTreeIter iter;
    size_t i;
    fsnode_t *child;

    assert(widget && node);

    list_store = (GtkListStore *) gtk_icon_view_get_model(GTK_ICON_VIEW(widget));
    gtk_list_store_clear(list_store);
    for (i = 0; i < node->nchildren; ++i) {
        child = node->children + i;
        gtk_list_store_append(list_store, &iter);
        gtk_list_store_set(list_store, &iter, COL_NAME, child->name, COL_ICON, get_icon(child), -1);
    }
}
Exemple #30
0
static void
cell_toggled (GtkCellRendererToggle *cell_renderer,
	      const gchar           *path,
	      GtkIconView      *iconview)
{
  GtkTreeModel *model = gtk_icon_view_get_model (iconview);
  GtkTreeIter   iter;
  gboolean      active;

  g_print ("Cell toggled !\n");

  if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
    return;

  gtk_tree_model_get (model, &iter, FOCUS_COLUMN_CHECK, &active, -1);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter, FOCUS_COLUMN_CHECK, !active, -1);
}