示例#1
0
int
clip_GTK_ICONTHEMELISTICONS(ClipMachine * cm)
{
        C_object *cicon   = _fetch_co_arg(cm);
        gchar     *name   = _clip_parc(cm, 2);
        ClipVar     *cv   = RETPTR(cm);
        GList     *list   ;
        long          n   ;

	CHECKCOBJ(cicon, GTK_IS_ICON_THEME(cicon->object));
        CHECKARG(2, CHARACTER_t);

	list = gtk_icon_theme_list_icons(GTK_ICON_THEME(cicon->object),
			name);
	n = g_list_length(list);
        _clip_array(cm, cv, 1, &n);
        for (n=0; list; list = g_list_next(list), n++)
        {
        	ClipVar c;
                gchar *str;

		str = (gchar *)(list->data);
                _clip_var_str(str, strlen(str), &c);
        	_clip_aset(cm, cv, &c, 1, &n);
                _clip_destroy(cm, &c);
                g_free(str);
        }
        g_list_free(list);
	return 0;
err:
	return 1;
}
示例#2
0
文件: toolpalette.c 项目: 3v1n0/gtk
static void
load_icon_items (GtkToolPalette *palette)
{
  GList *contexts;
  GList *l;
  GtkIconTheme *icon_theme;

  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (palette)));

  contexts = gtk_icon_theme_list_contexts (icon_theme);
  for (l = contexts; l; l = g_list_next (l))
    {
      gchar *context = l->data;
      GList *icon_names;
      GList *ll;
      const guint max_icons = 10;
      guint icons_count = 0;

      GtkWidget *group = gtk_tool_item_group_new (context);
      gtk_container_add (GTK_CONTAINER (palette), group);

      if (g_strcmp0 (context, "Animations") == 0)
        continue;

      g_message ("Got context '%s'", context);
      icon_names = gtk_icon_theme_list_icons (icon_theme, context);
      icon_names = g_list_sort (icon_names, (GCompareFunc) strcmp);

      for (ll = icon_names; ll; ll = g_list_next (ll))
        {
          GtkToolItem *item;
          gchar *id = ll->data;

          if (g_str_equal (id, "emblem-desktop"))
            continue;

          if (g_str_has_suffix (id, "-symbolic"))
            continue;

          g_message ("Got id '%s'", id);

          item = gtk_tool_button_new (NULL, NULL);
          gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), id);
          gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), id);
          gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);

          /* Prevent us having an insane number of icons: */
          ++icons_count;
          if(icons_count >= max_icons)
            break;
        }

      g_list_free_full (icon_names, g_free);
    }

  g_list_free_full (contexts, g_free);
}
示例#3
0
static VALUE
it_list_icons(int argc, VALUE *argv, VALUE self)
{
    VALUE context;
    GList *icons;

    rb_scan_args(argc, argv, "01", &context);

    icons = gtk_icon_theme_list_icons(_SELF(self),
				      RVAL2CSTR_ACCEPT_NIL(context));
    return GLIST2ARY_STR_FREE(icons);
}
示例#4
0
static void
print_icon_list()
{
	GList* icon_list = gtk_icon_theme_list_icons(icon_theme, "MimeTypes");
	if(icon_list){
		dbg(0, "%s----------------------------------", theme_name);
		for(;icon_list;icon_list=icon_list->next){
			char* icon = icon_list->data;
			printf("%s\n", icon);
			g_free(icon);
		}
		g_list_free(icon_list);
		printf("-------------------------------------------------\n");
	}
	else warnprintf("icon_theme has no mimetype icons?\n");

}
示例#5
0
文件: browser.c 项目: kba/yad-dialog
static GtkListStore *
load_icon_cat (IconBrowserData * data, gchar * cat)
{
  GtkListStore *store;
  GList *i, *icons;
  gint size, w, h;

  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
  size = MIN (w, h);

  store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);

  icons = gtk_icon_theme_list_icons (data->theme, cat);
  for (i = icons; i; i = i->next)
    {
      GtkTreeIter iter;
      GdkPixbuf *pb, *spb;

      spb = pb = gtk_icon_theme_load_icon (data->theme, i->data, size, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);

      if (pb)
        {
          /* scale pixbuf if needed */
          w = gdk_pixbuf_get_width (pb);
          h = gdk_pixbuf_get_height (pb);
          if (w > size || h > size)
            {
              pb = gdk_pixbuf_scale_simple (spb, size, size, GDK_INTERP_BILINEAR);
              g_object_unref (spb);
            }
        }

      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter, 0, pb, 1, i->data, -1);

      if (pb)
        g_object_unref (pb);
      g_free (i->data);
    }
  g_list_free (icons);

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 1, GTK_SORT_ASCENDING);

  return store;
}
示例#6
0
static GtkWidget*
create_icon_view ()
{
     GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL);
     GtkWidget *icon_view = gtk_icon_view_new ();

     int col_text = 0,col_icon = 1;

     GtkTreeModel *list_model = gtk_list_store_new (2,
						    G_TYPE_STRING,
						    GDK_TYPE_PIXBUF  ); 


     gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), list_model);

     gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), col_text);
     gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), col_icon);      
     gtk_icon_view_set_item_width (GTK_ICON_VIEW (icon_view), 100);

     GtkTreeIter iter;
     GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
     GList *contxt_list, *icon_names_list, *ctx, *icn;
     gint max_icons = 100;
     gint icon_size = 32;
     ctx = contxt_list = gtk_icon_theme_list_contexts (icon_theme);
     
     while (ctx && max_icons) {
	  gchar *context = ctx->data;
	  

	  icn = icon_names_list = gtk_icon_theme_list_icons (icon_theme, context);
	  g_debug ("Context %s: %d icons listed", context, g_list_length (icn));
	  while (icn && max_icons) {
	       gchar *icon_name = icn->data;
	       g_debug (" - %s", icon_name);

	       GdkPixbuf *pixbuf = NULL;
	       pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name, 
						  icon_size, GTK_ICON_LOOKUP_FORCE_SVG, NULL);
	       if (pixbuf != NULL){
		    gtk_list_store_append (list_model, &iter);
		    gtk_list_store_set (list_model, &iter,
					col_text, icon_name,
					col_icon, pixbuf,
					-1);
		    --max_icons;
	       }else{
		    g_free (icon_name);
	       }


	       icn = g_list_next (icn);
	  }
	  
	  g_list_free (icon_names_list);
	  g_free (context);
	  ctx = g_list_next (ctx);
     }

     g_list_free (contxt_list);


     gtk_container_add (GTK_CONTAINER (scroll), icon_view);

     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), 
				     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

     gtk_widget_set_name (scroll, "Icon View");
     return scroll;

}