int
main ()
{
  GooCanvasItemModel *model;
  GdkPixbuf *pixbuf;

  /* Initialize GTK+. */
  gtk_init ();

  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
				     "dialog-warning", 48, 0, NULL);

  model = create_model (pixbuf);

  /* Create 2 windows to show off multiple views. */
  create_window (model);
#if 1
  create_window (model);
#endif

  g_object_unref (model);

  gtk_main ();

  return 0;
}
RBVisualizerPage *
rb_visualizer_page_new (GObject *plugin, RBShell *shell, GtkToggleAction *fullscreen, GtkWidget *popup)
{
	GObject *page;
	GdkPixbuf *pixbuf;
	gint size;

	gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL);
	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					   "visualization",
					   size,
					   0, NULL);

	page = g_object_new (RB_TYPE_VISUALIZER_PAGE,
			     "plugin", plugin,
			     "shell", shell,
			     "name", _("Visual Effects"),
			     "pixbuf", pixbuf,
			     "fullscreen-action", fullscreen,
			     "popup", popup,
			     NULL);
	if (pixbuf != NULL) {
		g_object_unref (pixbuf);
	}

	return RB_VISUALIZER_PAGE (page);
}
Beispiel #3
0
/**
 * gdk_pixbuf_new_from_theme:
 * @name: the icon name
 * @size: the pixel size
 *
 * Creates a new pixbuf image from the icon @name and @size.
 *
 * Returns: a new pixbuf, g_object_unref() when done.
 */
GdkPixbuf *
gdk_pixbuf_new_from_theme (const gchar * name, gint size)
{
  GdkPixbuf *pixbuf;
  GError *error = NULL;
  GtkIconTheme *it = gtk_icon_theme_get_default ();

  /* TODO(ensonic): docs recommend to listen to GtkWidget::style-set and update icon or
   * do gdk_pixbuf_copy() to avoid gtk keeping icon-theme loaded if it changes
   */
  if (!(pixbuf =
          gtk_icon_theme_load_icon (it, name, size,
              GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_FORCE_SIZE,
              &error))) {
    GST_WARNING ("Couldn't load %s %dx%d icon: %s", name, size, size,
        error->message);
    g_error_free (error);
    /* TODO(ensonic): machine icons are in 'gnome' theme, how can we use this as a
     * fallback
     * gtk_icon_theme_set_custom_theme(it,"gnome");
     * is a bit brutal
     */
    return gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size);
    //return NULL;
  } else {
    GdkPixbuf *result = gdk_pixbuf_copy (pixbuf);
    g_object_unref (pixbuf);
    return result;
  }
}
static void
refresh_combo_box_icons(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list)
{
	GtkTreeIter iter;
	GtkTreeModel* model;
	gboolean valid;
	GdkPixbuf* pixbuf;
	gchar* icon_name;
	
	model = gtk_combo_box_get_model(combo_box);

	valid = gtk_tree_model_get_iter_first(model, &iter);
	
	while (valid)
    {
		gtk_tree_model_get(model, &iter,
				          ICONAME_COL, &icon_name,
				          -1);

		pixbuf = gtk_icon_theme_load_icon(theme, icon_name, 22, 0, NULL);

		gtk_list_store_set(GTK_LIST_STORE(model), &iter,
				PIXBUF_COL, pixbuf,
				-1);

		if (pixbuf)
		{
			g_object_unref(pixbuf);
		}
		
		g_free(icon_name);

		valid = gtk_tree_model_iter_next(model, &iter);
    }
}
static void refresh_combo_box_icons(GtkIconTheme* theme, GtkComboBox* combo_box, GList* app_list)
{
    GList *entry;
    MateDAItem *item;
    GtkTreeModel *model;
    GtkTreeIter iter;
    GdkPixbuf *pixbuf;

    for (entry = app_list; entry != NULL; entry = g_list_next (entry)) {
	item = (MateDAItem *) entry->data;

	model = gtk_combo_box_get_model (combo_box);

	if (item->icon_path && gtk_tree_model_get_iter_from_string (model, &iter, item->icon_path)) {
	    pixbuf = gtk_icon_theme_load_icon (theme, item->icon_name, 22, 0, NULL);

	    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
				PIXBUF_COL, pixbuf,
				-1);

	    if (pixbuf)
		g_object_unref (pixbuf);
	}
    }
}
Beispiel #6
0
int
clip_GTK_ICONTHEMELOADICON(ClipMachine * cm)
{
        C_object *cicon   = _fetch_co_arg(cm);
        gchar     *name   = _clip_parc(cm, 2);
        gint       size   = _clip_parni(cm, 3);
        GtkIconLookupFlags flags = _clip_parni(cm, 4);
        GError   *error   ;
        C_object *cpixbuf ;
        GdkPixbuf *pixbuf ;

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

	pixbuf = gtk_icon_theme_load_icon(GTK_ICON_THEME(cicon->object),
			name, size, flags, &error);

	if (pixbuf)
        {
        	cpixbuf = _list_get_cobject(cm, pixbuf);
                if (!cpixbuf) cpixbuf = _register_object(cm, pixbuf, GDK_TYPE_PIXBUF, NULL, NULL);
                if (cpixbuf) _clip_mclone(cm, RETPTR(cm), &cpixbuf->obj);
        }

	return 0;
err:
	return 1;
}
/* Esta funcion se llama cuando se cambia o actualizan los iconos */
static void
theme_changed_cb(GtkIconTheme* theme, MateDACapplet* capplet)
{
	GObject* icon;
	gint i;

	for (i = 0; i < G_N_ELEMENTS(icons); i++)
	{
		icon = gtk_builder_get_object(capplet->builder, icons[i].name);

		GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(theme, icons[i].icon, 32, 0, NULL);

		gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pixbuf);
		
		if (pixbuf)
		{
			g_object_unref(pixbuf);
		}
	}

	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->web_combo_box), capplet->web_browsers);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->mail_combo_box), capplet->mail_readers);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->media_combo_box), capplet->media_players);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->term_combo_box), capplet->terminals);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->visual_combo_box), capplet->visual_ats);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers);
	refresh_combo_box_icons(theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors);
}
Beispiel #8
0
static GdkPixbuf* load_icon(int what)
{
    GtkIconTheme *icon_theme;
    GdkPixbuf *pixbuf;
    GError *error = NULL;
    char* icon;

    icon_theme = gtk_icon_theme_get_default();

    switch(what)
    {
        case ICON_MOUSE: icon = "mouse"; break;
        case ICON_KEYBOARD: icon = "keyboard"; break;
        case ICON_FLOATING: icon = "dialog-warning"; break; /* XXX */
    }

    pixbuf = gtk_icon_theme_load_icon(icon_theme, icon,16, 0, &error);

    if (!pixbuf)
    {
        g_debug("Couldn't load icon: %s", error->message);
        g_error_free(error);
    }

    return pixbuf;
}
static void
xfpm_info_add_sidebar_icon (XfpmInfo *info, const gchar *name, const gchar *icon_name)
{
    GtkListStore *list_store;
    GtkTreeIter iter;
    GdkPixbuf *pix;
    guint nt;

    list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (info->sideview)));
    
    nt = gtk_notebook_get_n_pages (GTK_NOTEBOOK (info->notebook));
    
    pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
				    icon_name,
				    48,
				    GTK_ICON_LOOKUP_USE_BUILTIN,
				    NULL);
    
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter, 
			COL_SIDEBAR_ICON, pix,
			COL_SIDEBAR_NAME, name,
			COL_SIDEBAR_INT, nt,
			-1);
			
    if ( pix )
	g_object_unref (pix);
}
Beispiel #10
0
static GdkPixbuf *
gimp_page_selector_add_frame (GtkWidget *widget,
                              GdkPixbuf *pixbuf)
{
    GdkPixbuf *frame;
    gint       width, height;

    width  = gdk_pixbuf_get_width (pixbuf);
    height = gdk_pixbuf_get_height (pixbuf);

    frame = g_object_get_data (G_OBJECT (widget), "frame");

    if (! frame)
    {
        frame = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                          GIMP_STOCK_FRAME, 64, 0, NULL);
        g_object_set_data_full (G_OBJECT (widget), "frame", frame,
                                (GDestroyNotify) g_object_unref);
    }

    frame = stretch_frame_image (frame,
                                 FRAME_LEFT,
                                 FRAME_TOP,
                                 FRAME_RIGHT,
                                 FRAME_BOTTOM,
                                 width  + FRAME_LEFT + FRAME_RIGHT,
                                 height + FRAME_TOP  + FRAME_BOTTOM);

    gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height,
                          frame, FRAME_LEFT, FRAME_TOP);

    return frame;
}
/**
 * gpm_applet_get_icon:
 * @applet: Inhibit applet instance
 *
 * retrieve an icon from stock with a size adapted to panel
 **/
static void
gpm_applet_get_icon (GpmInhibitApplet *applet)
{
	const gchar *icon;

	/* free */
	if (applet->icon != NULL) {
		g_object_unref (applet->icon);
		applet->icon = NULL;
	}

	if (applet->size <= 2) {
		return;
	}

	/* get icon */
	if (applet->proxy == NULL) {
		icon = GPM_INHIBIT_APPLET_ICON_INVALID;
	} else if (applet->cookie > 0) {
		icon = GPM_INHIBIT_APPLET_ICON_INHIBIT;
	} else {
		icon = GPM_INHIBIT_APPLET_ICON_UNINHIBIT;
	}
	applet->icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
						 icon,
						 applet->size - 2,
						 0,
						 NULL);

	/* update size cache */
	applet->icon_height = gdk_pixbuf_get_height (applet->icon);
	applet->icon_width = gdk_pixbuf_get_width (applet->icon);
}
Beispiel #12
0
static GdkPixbuf *
get_image_pixbuf (GtkImage *image)
{
  const gchar *icon_name;
  GtkIconSize size;
  GtkIconTheme *icon_theme;
  int width;

  switch (gtk_image_get_storage_type (image))
    {
    case GTK_IMAGE_PIXBUF:
      return g_object_ref (gtk_image_get_pixbuf (image));
    case GTK_IMAGE_ICON_NAME:
      gtk_image_get_icon_name (image, &icon_name, &size);
      icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (image)));
      gtk_icon_size_lookup (size, &width, NULL);
      return gtk_icon_theme_load_icon (icon_theme,
                                       icon_name,
                                       width,
                                       GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                                       NULL);
    default:
      g_warning ("Image storage type %d not handled",
                 gtk_image_get_storage_type (image));
      return NULL;
    }
}
Beispiel #13
0
static GdkPixbuf *
icon_cache_get_mime_type_icon( IconCache * icon_cache, const char * mime_type )
{
    GdkPixbuf  * pixbuf;
    const char * stock_name;

    if( !strcmp( mime_type, UNKNOWN_MIME_TYPE ) )
        stock_name = GTK_STOCK_MISSING_IMAGE;
    else if( !strcmp( mime_type, DIRECTORY_MIME_TYPE ) )
        stock_name = GTK_STOCK_DIRECTORY;
    else
        stock_name = GTK_STOCK_FILE;

    pixbuf = g_hash_table_lookup( icon_cache->cache, stock_name );

    if( pixbuf != NULL )
    {
        g_object_ref( pixbuf );
        return pixbuf;
    }

    pixbuf = gtk_icon_theme_load_icon( icon_cache->icon_theme,
                                       stock_name,
                                       icon_cache->icon_size,
                                       0, NULL );
    g_hash_table_insert( icon_cache->cache, (gpointer) stock_name, g_object_ref( pixbuf ));
    return pixbuf;
}
Beispiel #14
0
GdkPixbuf *get_icon(const char *icon_name, int icon_size)
{
	GtkIconTheme *icon_theme;
	GdkPixbuf *pixbuf = NULL;
	GError *error = NULL;


	if (icon_name) {
		icon_theme = gtk_icon_theme_get_default();

		pixbuf = gtk_icon_theme_load_icon(icon_theme,
				icon_name,
				icon_size,
				GTK_ICON_LOOKUP_NO_SVG, &error);

		if (error) {
			g_warning("Error loading icon '%s': %s\n", icon_name,
					error->message);
			g_error_free(error);
			error = NULL;
		}
	} else {
		g_warning("Error loading icon: no icon name\n");
	}

	return pixbuf;
} /* static GdkPixbuf *get_icon() */
Beispiel #15
0
static void
icon_shape_renderer (cairo_t        *cr,
                     PangoAttrShape *attr,
                     gboolean        do_path,
                     gpointer        user_data)
{
        IconShapeData *data = user_data;
        gdouble x, y;

        cairo_get_current_point (cr, &x, &y);
        if (GPOINTER_TO_UINT (attr->data) == data->placeholder) {
                gdouble ascent;
                gdouble height;
                gdouble width;
                GdkPixbuf *pixbuf;

                ascent = pango_units_to_double (attr->ink_rect.y);
                height = pango_units_to_double (attr->ink_rect.height);
                width = pango_units_to_double (attr->ink_rect.width);
                pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                                   data->stock_id,
                                                   (gint)height,
                                                   GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_USE_BUILTIN,
                                                   NULL);

                cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
                cairo_reset_clip (cr);
                gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y + ascent);
                cairo_paint (cr);
                g_object_unref (pixbuf);
        }
}
static void
share_nfs_add_static_combo_elements (GtkListStore *store)
{
	GtkTreeIter  iter;
	GdkPixbuf   *pixbuf;

	pixbuf = gtk_icon_theme_load_icon (gst_tool_get_icon_theme (tool),
					   "gnome-fs-network",
					   16, 0, NULL);

	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    0, pixbuf,
			    1, _("Specify hostname"),
			    2, NFS_SHARE_HOSTNAME,
			    3, NULL,
			    -1);
	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    0, pixbuf,
			    1, _("Specify IP address"),
			    2, NFS_SHARE_ADDRESS,
			    3, NULL,
			    -1);
	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    0, pixbuf,
			    1, _("Specify network"),
			    2, NFS_SHARE_NETWORK,
			    3, NULL,
			    -1);
	gdk_pixbuf_unref (pixbuf);
}
Beispiel #17
0
/* level - per cent level from 0 to 100 */
static void
meter_set_level(meter_priv *m, int level)
{
    int i;
    GdkPixbuf *pb;

    ENTER;
    if (m->level == level)
        RET();
    if (!m->num)
        RET();
    if (level < 0 || level > 100) {
        ERR("meter: illegal level %d\n", level);
        RET();
    }
    i = roundf((gfloat) level / 100 * (m->num - 1));
    DBG("level=%f icon=%d\n", level, i);
    if (i != m->cur_icon) {
        m->cur_icon = i;
        pb = gtk_icon_theme_load_icon(icon_theme, m->icons[i],
            m->size, GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
        DBG("loading icon '%s' %s\n", m->icons[i], pb ? "ok" : "failed");
        gtk_image_set_from_pixbuf(GTK_IMAGE(m->meter), pb);
        if (pb)
            g_object_unref(G_OBJECT(pb));
    }
    m->level = level;
    RET();
}
Beispiel #18
0
static void
about_action_callback (GtkAction *action, gpointer user_data)
{
        MduShell *shell = MDU_SHELL (user_data);
        GdkPixbuf *logo;
        const char *artists[] = {
                "Mike Langlie <*****@*****.**>",
                NULL
        };
        const char *authors[] = {
                "David Zeuthen <*****@*****.**>",
                NULL
        };

        logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                         "mate-disk",
                                         96,
                                         GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                                         NULL);

        gtk_show_about_dialog (GTK_WINDOW (shell->priv->app_window),
                               "program-name", _("Disk Utility"),
                               "version", VERSION,
                               "copyright", "\xc2\xa9 2007-2009 Red Hat, Inc.",
                               "authors", authors,
                               "artists", artists,
                               "translator-credits", _("translator-credits"),
                               "logo", logo,
                               NULL);
        if (logo != NULL)
                g_object_unref (logo);
}
static gboolean
clipman_set_size (XfcePanelPlugin *plugin,
                  gint             wsize,
                  ClipmanPlugin   *clipman)
{
    GdkPixbuf *pb;
    gint       newsize;
    
    DBG("Set clipman button size");

    newsize = wsize - 10;
    if (newsize < 1)
        newsize = 1;
    
    gtk_widget_set_size_request (clipman->button, wsize, wsize);
    
    if (clipman->icon)
        gtk_widget_destroy (clipman->icon);
    
    pb = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-paste", newsize , 0, NULL);
    clipman->icon = gtk_image_new_from_pixbuf (pb);
    gtk_widget_show (clipman->icon);
    gtk_container_add (GTK_CONTAINER (clipman->button), clipman->icon);
    
    g_object_unref (pb);

    return TRUE;
}
Beispiel #20
0
static GdkPixbuf *load_icon(const gchar *name, gint size)
{
    g_return_val_if_fail(name != NULL, NULL);
    g_return_val_if_fail(size > 0, NULL);
    GError *error = NULL;
    GdkPixbuf *pixbuf = NULL;

    /* First try to load the icon from the icon theme */
    GtkIconTheme *theme = gtk_icon_theme_get_default();

    if (gtk_icon_theme_has_icon(theme, name)) {
        pixbuf = gtk_icon_theme_load_icon(theme, name, size, GTK_ICON_LOOKUP_FORCE_SVG, &error);

        if (error) {
            g_warning("Failed to load icon '%s' from icon theme: %s", name, error->message);
        } else {
            return pixbuf;
        }
    }

    /* Otherwise load from the icon installation path */
    gchar *path = g_strdup_printf(ICONS_DIR "/hicolor/scalable/status/%s.svg", name);
    pixbuf = gdk_pixbuf_new_from_file_at_scale(path, size, size, FALSE, &error);

    if (error) {
        g_warning("Failed to load icon at '%s': %s", path, error->message);
        pixbuf = NULL;
    }

    g_free(path);
    return pixbuf;
}
Beispiel #21
0
/* compose_attach */
int compose_attach(Compose * compose, char const * filename)
{
	const int iconsize = 48;
	GtkIconTheme * theme;
	char const * type;
	GdkPixbuf * pixbuf;
	GtkTreeIter iter;
	char * p;
	FILE * fp;

	if(filename == NULL)
		return compose_attach_dialog(compose);
	if((fp = fopen(filename, "rb")) == NULL)
		return -compose_error(compose, strerror(errno), 1);
	if((p = strdup(filename)) == NULL)
	{
		fclose(fp);
		return -compose_error(compose, strerror(errno), 1);
	}
	compose_set_modified(compose, TRUE);
	theme = gtk_icon_theme_get_default();
	pixbuf = NULL;
	if((type = mime_type(compose->mime, filename)) != NULL)
		mime_icons(compose->mime, type, iconsize, &pixbuf, -1);
	if(pixbuf == NULL)
		pixbuf = gtk_icon_theme_load_icon(theme, GTK_STOCK_FILE,
				iconsize, 0, NULL);
	gtk_list_store_append(compose->a_store, &iter);
	gtk_list_store_set(compose->a_store, &iter, CAC_FILENAME, filename,
			CAC_BASENAME, basename(p), CAC_ICON, pixbuf,
			CAC_FILE_POINTER, fp, -1);
	g_object_unref(pixbuf);
	free(p);
	return 0;
}
/**
 * gpm_applet_dialog_about_cb:
 *
 * displays about dialog
 **/
static void
gpm_applet_dialog_about_cb (GtkAction *action, gpointer data)
{
	GtkAboutDialog *about;

	GdkPixbuf *logo =
		gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					  GPM_INHIBIT_APPLET_ICON_INHIBIT,
					  128, 0, NULL);

	static const gchar *authors[] = {
		"Benjamin Canou <*****@*****.**>",
		"Richard Hughes <*****@*****.**>",
		NULL
	};
	const char *documenters [] = {
		NULL
	};
	const char *license[] = {
		 N_("Licensed under the GNU General Public License Version 2"),
		 N_("Power Manager is free software; you can redistribute it and/or\n"
		   "modify it under the terms of the GNU General Public License\n"
		   "as published by the Free Software Foundation; either version 2\n"
		   "of the License, or (at your option) any later version."),
		 N_("Power Manager is distributed in the hope that it will be useful,\n"
		   "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
		   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
		   "GNU General Public License for more details."),
		 N_("You should have received a copy of the GNU General Public License\n"
		   "along with this program; if not, write to the Free Software\n"
		   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
		   "02110-1301, USA.")
	};
	const char *translator_credits = NULL;
	char	   *license_trans;

	license_trans = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n",
				     _(license[2]), "\n\n", _(license[3]), "\n", NULL);

	about = (GtkAboutDialog*) gtk_about_dialog_new ();
	gtk_about_dialog_set_program_name (about, GPM_INHIBIT_APPLET_NAME);
	gtk_about_dialog_set_version (about, VERSION);
	gtk_about_dialog_set_copyright (about, _("Copyright \xc2\xa9 2006-2007 Richard Hughes"));
	gtk_about_dialog_set_comments (about, GPM_INHIBIT_APPLET_DESC);
	gtk_about_dialog_set_authors (about, authors);
	gtk_about_dialog_set_documenters (about, documenters);
	gtk_about_dialog_set_translator_credits (about, translator_credits);
	gtk_about_dialog_set_logo (about, logo);
	gtk_about_dialog_set_license (about, license_trans);
	gtk_about_dialog_set_website (about, GPM_HOMEPAGE_URL);

	g_signal_connect (G_OBJECT(about), "response",
			  G_CALLBACK(gtk_widget_destroy), NULL);

	gtk_widget_show (GTK_WIDGET(about));

	g_free (license_trans);
	g_object_unref (logo);
}
static void fill_combo_box (GtkIconTheme *theme, GtkComboBox *combo_box, GList *app_list)
{
    GList *entry;
    GtkTreeModel *model;
    GtkCellRenderer *renderer;
    GtkTreeIter iter;
    GdkPixbuf *pixbuf;

    if (theme == NULL) {
	theme = gtk_icon_theme_get_default ();
    }

    gtk_combo_box_set_row_separator_func (combo_box, is_separator,
					  GINT_TO_POINTER (g_list_length (app_list)), NULL);

    model = GTK_TREE_MODEL (gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING));
    gtk_combo_box_set_model (combo_box, model);

    renderer = gtk_cell_renderer_pixbuf_new ();

    /* not all cells have a pixbuf, this prevents the combo box to shrink */
    gtk_cell_renderer_set_fixed_size (renderer, -1, 22);
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
				    "pixbuf", PIXBUF_COL,
				    NULL);

    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
				    "text", TEXT_COL,
				    NULL);

    for (entry = app_list; entry != NULL; entry = g_list_next (entry)) {
	MateDAItem *item;
	item = (MateDAItem *) entry->data;

	pixbuf = gtk_icon_theme_load_icon (theme, item->icon_name, 22, 0, NULL);

	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
	gtk_list_store_set (GTK_LIST_STORE (model), &iter,
			    PIXBUF_COL, pixbuf,
			    TEXT_COL, item->name,
			    -1);

	item->icon_path = gtk_tree_model_get_string_from_iter (model, &iter);

	if (pixbuf)
	    g_object_unref (pixbuf);
    }

    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter, -1);
    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
			PIXBUF_COL, NULL,
			TEXT_COL, _("Custom"),
			-1);
}
void
gth_application_activate_about (GSimpleAction *action,
				GVariant      *parameter,
				gpointer       user_data)
{
        GApplication *application = user_data;
	GthWindow    *window;
	const char   *authors[] = {
#include "AUTHORS.tab"
		NULL
	};
	const char   *documenters [] = {
		"Paolo Bacchilega",
		"Alexander Kirillov",
		NULL
	};
	char       *license_text;
	const char *license[] = {
		N_("gThumb is free software; you can redistribute it and/or modify "
		"it under the terms of the GNU General Public License as published by "
		"the Free Software Foundation; either version 2 of the License, or "
		"(at your option) any later version."),
		N_("gThumb is distributed in the hope that it will be useful, "
		"but WITHOUT ANY WARRANTY; without even the implied warranty of "
		"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
		"GNU General Public License for more details."),
		N_("You should have received a copy of the GNU General Public License "
		"along with gThumb.  If not, see http://www.gnu.org/licenses/.")
	};
	GdkPixbuf *logo;

	window = (GthWindow *) _gth_application_get_current_window (application);
	license_text = g_strconcat (_(license[0]), "\n\n",
				    _(license[1]), "\n\n",
				    _(license[2]),
				    NULL);

	logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
					 "gthumb",
					 128,
					 GTK_ICON_LOOKUP_NO_SVG,
					 NULL);

	gtk_show_about_dialog (GTK_WINDOW (window),
			       "version", VERSION,
			       "copyright", "Copyright \xc2\xa9 2001-2013 Free Software Foundation, Inc.",
			       "comments", _("An image viewer and browser for GNOME."),
			       "authors", authors,
			       "documenters", documenters,
			       "translator-credits", _("translator-credits"),
			       "license", license_text,
			       "wrap-license", TRUE,
			       "website", "http://live.gnome.org/Apps/gthumb",
			       (logo != NULL ? "logo" : NULL), logo,
			       NULL);

	_g_object_unref (logo);
	g_free (license_text);
}
Beispiel #25
0
static void on_add( GtkButton* btn, gpointer data )
{
    GtkWindow* parent = GTK_WINDOW(data);
    GtkTreeViewColumn* col;
    GtkTreeIter it, new_it, *pit;
    GtkTreePath* tree_path;
    GtkTreeView* view = (GtkTreeView*)g_object_get_data( G_OBJECT(data),
                                                         "list_view" );
    GtkTreeModel* model;
    GtkTreeSelection* sel = gtk_tree_view_get_selection( view );

    GdkPixbuf* icon = gtk_icon_theme_load_icon( gtk_icon_theme_get_default(),
                                                "gnome-fs-directory",
                                                20, 0, NULL );
    GtkWidget* dlg;
    char *path = NULL, *basename = NULL;

    if( gtk_tree_selection_get_selected ( sel, &model, &it ) )
    {
        tree_path = gtk_tree_model_get_path( model, &it );
        gtk_tree_path_next( tree_path );
        pit = &it;
    }
    else
    {
        tree_path = gtk_tree_path_new_first();
        pit = NULL;
    }

    dlg = gtk_file_chooser_dialog_new( NULL, parent,
                            GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK, GTK_RESPONSE_OK, NULL );
    if( gtk_dialog_run( (GtkDialog*) dlg ) == GTK_RESPONSE_OK )
    {
        path = gtk_file_chooser_get_filename( (GtkFileChooser*)dlg );
        basename = g_filename_display_basename( path );
    }
    gtk_widget_destroy( dlg );

    col = gtk_tree_view_get_column( view, 1 );
    gtk_list_store_insert_after( GTK_LIST_STORE(model), &new_it, pit );
    gtk_list_store_set( GTK_LIST_STORE(model), &new_it,
                        COL_ICON, icon,
                        COL_NAME, basename ? basename : _("New Item"),
                        COL_DIRPATH, path, -1);

    g_free( path );
    g_free( basename );

    if( tree_path )
    {
        gtk_tree_view_set_cursor_on_cell( view, tree_path, col, NULL, TRUE );
        gtk_tree_path_free( tree_path );
    }

    if( icon )
        g_object_unref( icon );
}
static GdkPixbuf*
get_share_icon (OobsShare *share)
{
	GdkPixbuf *pixbuf = NULL;

	if (OOBS_IS_SHARE_SMB (share)) {
		pixbuf = gtk_icon_theme_load_icon (gst_tool_get_icon_theme (tool),
						   "gnome-fs-smb",
						   48, 0, NULL);
	} else if (OOBS_IS_SHARE_NFS (share)) {
		pixbuf = gtk_icon_theme_load_icon (gst_tool_get_icon_theme (tool),
						   "gnome-fs-nfs",
						   48, 0, NULL);
	}

	return pixbuf;
}
Beispiel #27
0
/* libbalsa_icon_finder:
 *   locate a suitable icon (pixmap graphic) based on 'mime-type' and/or
 *   'filename', either of which can be NULL.  If both arguments are
 *   non-NULL, 'mime-type' has priority.  If both are NULL, the default
 *   'attachment.png' icon will be returned.  This function *MUST*
 *   return the complete path to the icon file.
 */
GdkPixbuf *
libbalsa_icon_finder(GtkWidget         * widget,
                     const char        * mime_type,
                     const LibbalsaVfs * for_file,
                     gchar            ** used_type,
                     GtkIconSize         size)
{
    const gchar *content_type;
    GdkPixbuf *pixbuf = NULL;
    gint width, height;
    GtkIconTheme *icon_theme;
    GIcon *icon;

    if (!gtk_icon_size_lookup(size, &width, &height))
        width = 16;

    if (mime_type)
        content_type = mime_type;
    else if (for_file) {
        content_type = libbalsa_vfs_get_mime_type(for_file);
    } else
        content_type = "application/octet-stream";

    /* ask GIO for the icon */
    if ((icon_theme = gtk_icon_theme_get_default()) == NULL)
        return NULL;

    icon = g_content_type_get_icon(content_type);

    if (icon != NULL) {
        if (G_IS_THEMED_ICON(icon)) {
            gint i;
            GStrv icon_names;

            g_object_get(G_OBJECT(icon), "names", &icon_names, NULL);

            if (icon_names != NULL) {
                for (i = 0; pixbuf == NULL && icon_names[i] != NULL; i++) {
                    pixbuf =
                        gtk_icon_theme_load_icon(icon_theme, icon_names[i], width,
                                                 GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
                }
                g_strfreev(icon_names);
            }
        }
        g_object_unref(icon);
    }

    if (pixbuf == NULL) {
        /* load the default pixbuf */
        pixbuf = libbalsa_default_attachment_pixbuf(width);
    }

    if (used_type)
        *used_type = g_strdup(content_type);

    return pixbuf;
}
Beispiel #28
0
/* If we can't find a matching icon size, use the one provided as parameter
 * This is to avoid having two pixbufs in memory when not needed.
 */
GdkPixbuf *get_icon_with_fallback(const char *icon_name,
                                  int icon_size,
                                  GdkPixbuf *fallback)
{
    gint *icon_sizes;
    gint i;
    gboolean found;
	GtkIconTheme *icon_theme;
	GdkPixbuf *pixbuf = NULL;
	GError *error = NULL;

	if (icon_name) {
		icon_theme = gtk_icon_theme_get_default();

        icon_sizes = gtk_icon_theme_get_icon_sizes(icon_theme, icon_name);
        
        i = 0;
        found = FALSE;
        while (icon_sizes[i] != 0)
        {
            /* If found or has scalable icon (-1), use it
             * Well, in theory at least. Maemo-Gtk+ doesn't return -1 at all
             * it seems (scalable is a synonyme for "64" really)
             */ 
            if (icon_sizes[i] == icon_size || icon_sizes[i] == -1)
            {
                found = TRUE;
                break;
            }
            i++;
        }

        g_free (icon_sizes);

        if (!found)
        {
            g_object_ref(fallback);
            return fallback;
        }
    
		pixbuf = gtk_icon_theme_load_icon(icon_theme,
				icon_name,
				icon_size,
				GTK_ICON_LOOKUP_NO_SVG, &error);

		if (error) {
			g_warning("Error loading icon '%s': %s\n", icon_name,
					error->message);
			g_error_free(error);
			error = NULL;
		}
	} else {
		g_warning("Error loading icon: no icon name\n");
	}

	return pixbuf;
} /* static GdkPixbuf *get_icon_with_fallback() */
/* Get pixbuf icon from current icon theme */
GdkPixbuf *
utils_pixbuf_from_stock (const gchar *icon_name, gint size)
{
    GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
    if (icon_theme)
        return gtk_icon_theme_load_icon (icon_theme, icon_name, size, 0, NULL);

    return NULL;
}
Beispiel #30
0
static GdkPixbuf*
get_icon_for_device(const char *mountpoint)
{
    const char* icon_name = get_icon_for_path(mountpoint);
    if (!strcmp(icon_name, ""))
        // FIXME: defaults to a safe value
        icon_name = "drive-harddisk"; // get_icon_for_path("/");
    return gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), icon_name, 24, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
}