static void
xfdesktop_regular_file_icon_finalize(GObject *obj)
{
    XfdesktopRegularFileIcon *icon = XFDESKTOP_REGULAR_FILE_ICON(obj);
    GtkIconTheme *itheme = gtk_icon_theme_get_for_screen(icon->priv->gscreen);
    
    g_signal_handlers_disconnect_by_func(G_OBJECT(itheme),
                                         G_CALLBACK(xfdesktop_icon_invalidate_pixbuf),
                                         icon);
    
    if(icon->priv->file_info)
        g_object_unref(icon->priv->file_info);

    if(icon->priv->filesystem_info)
        g_object_unref(icon->priv->filesystem_info);

    g_object_unref(icon->priv->file);
    
    g_free(icon->priv->display_name);

    if(icon->priv->tooltip)
        g_free(icon->priv->tooltip);

    if(icon->priv->thumbnail_file)
        g_object_unref(icon->priv->thumbnail_file);

    if(icon->priv->monitor)
        g_object_unref(icon->priv->monitor);

    G_OBJECT_CLASS(xfdesktop_regular_file_icon_parent_class)->finalize(obj);
}
Ejemplo n.º 2
0
static void
on_notebook_drag_begin (GtkWidget      *widget,
                        GdkDragContext *context,
                        gpointer        data)
{
  GdkPixbuf *pixbuf;
  guint page_num;

  page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (widget));

  if (page_num > 2)
    {
      GtkIconTheme *icon_theme;
      int width;

      icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
      gtk_icon_size_lookup (GTK_ICON_SIZE_DND, &width, NULL);
      pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                         (page_num % 2) ? "help-browser" : "process-stop",
                                         width,
                                         GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                                         NULL);

      gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0);
      g_object_unref (pixbuf);
    }
}
static void
from_gicon (GtkSourcePixbufHelper *helper,
            GtkWidget             *widget,
            gint                   size)
{
	GdkScreen *screen;
	GtkIconTheme *icon_theme;
	GtkIconInfo *info;
	GtkIconLookupFlags flags;

	screen = gtk_widget_get_screen (widget);
	icon_theme = gtk_icon_theme_get_for_screen (screen);

	flags = GTK_ICON_LOOKUP_USE_BUILTIN;

	info = gtk_icon_theme_lookup_by_gicon (icon_theme,
	                                       helper->gicon,
	                                       size,
	                                       flags);

	if (info)
	{
		set_cache (helper, gtk_icon_info_load_icon (info, NULL));
	}
}
Ejemplo n.º 4
0
static CanvasItem*
canvas_item_new (GtkWidget     *widget,
                 GtkToolButton *button,
                 gdouble        x,
                 gdouble        y)
{
  CanvasItem *item = NULL;
  const gchar *icon_name;
  GdkPixbuf *pixbuf;
  GtkIconTheme *icon_theme;
  int width;

  icon_name = gtk_tool_button_get_icon_name (button);
  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
  gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, NULL);
  pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                     icon_name,
                                     width,
                                     GTK_ICON_LOOKUP_GENERIC_FALLBACK,
                                     NULL);

  if (pixbuf)
    {
      item = g_slice_new0 (CanvasItem);
      item->pixbuf = pixbuf;
      item->x = x;
      item->y = y;
    }

  return item;
}
Ejemplo n.º 5
0
Archivo: testdnd2.c Proyecto: GYGit/gtk
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;
    }
}
Ejemplo n.º 6
0
static void
ev_stock_icons_add_icons_path_for_screen (GdkScreen *screen)
{
	GtkIconTheme *icon_theme;

	g_return_if_fail (ev_icons_path != NULL);

	icon_theme = screen ? gtk_icon_theme_get_for_screen (screen) : gtk_icon_theme_get_default ();
	if (icon_theme) {
		gchar **path = NULL;
		gint    n_paths;
		gint    i;

		/* GtkIconTheme will then look in Atril custom hicolor dir
		 * for icons as well as the standard search paths
		 */
		gtk_icon_theme_get_search_path (icon_theme, &path, &n_paths);
		for (i = n_paths - 1; i >= 0; i--) {
			if (g_ascii_strcasecmp (ev_icons_path, path[i]) == 0)
				break;
		}

		if (i < 0)
			gtk_icon_theme_append_search_path (icon_theme,
							   ev_icons_path);

		g_strfreev (path);
	}
}
Ejemplo n.º 7
0
static GtkCssImage *
gtk_css_image_icon_theme_compute (GtkCssImage             *image,
                                  guint                    property_id,
                                  GtkStyleProviderPrivate *provider,
                                  int                      scale,
                                  GtkCssComputedValues    *values,
                                  GtkCssComputedValues    *parent_values,
                                  GtkCssDependencies      *dependencies)
{
  GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
  GtkCssImageIconTheme *copy;
  GtkSettings *settings;
  GdkScreen *screen;

  settings = _gtk_style_provider_private_get_settings (provider);
  if (settings == NULL)
    screen = gdk_screen_get_default ();
  else
    screen = _gtk_settings_get_screen (settings);

  copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
  copy->name = g_strdup (icon_theme->name);
  copy->icon_theme = gtk_icon_theme_get_for_screen (screen);
  copy->scale = scale;
  copy->color = *_gtk_css_rgba_value_get_rgba (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_COLOR));

  *dependencies = GTK_CSS_DEPENDS_ON_COLOR;

  return GTK_CSS_IMAGE (copy);
}
Ejemplo n.º 8
0
static void show_desktop_applet_realized(MatePanelApplet* applet, gpointer data)
{
	ShowDesktopData* sdd;
	GdkScreen* screen;

	sdd = (ShowDesktopData*) data;

	if (sdd->matewnck_screen != NULL)
		g_signal_handlers_disconnect_by_func(sdd->matewnck_screen, show_desktop_changed_callback, sdd);

	if (sdd->icon_theme != NULL)
		g_signal_handlers_disconnect_by_func(sdd->icon_theme, theme_changed_callback, sdd);

	screen = gtk_widget_get_screen(sdd->applet);
	sdd->matewnck_screen = matewnck_screen_get(gdk_screen_get_number (screen));

	if (sdd->matewnck_screen != NULL)
		wncklet_connect_while_alive(sdd->matewnck_screen, "showing_desktop_changed", G_CALLBACK(show_desktop_changed_callback), sdd, sdd->applet);
	else
		g_warning("Could not get MatewnckScreen!");

	show_desktop_changed_callback(sdd->matewnck_screen, sdd);

	sdd->icon_theme = gtk_icon_theme_get_for_screen (screen);
	wncklet_connect_while_alive(sdd->icon_theme, "changed", G_CALLBACK(theme_changed_callback), sdd, sdd->applet);

	update_icon (sdd);
}
static GdkPixbuf *
load_pixbuf (GsdMediaKeysWindow *window,
             const char         *name,
             int                 icon_size)
{
        GtkIconTheme *theme;
        GdkPixbuf    *pixbuf;

        if (window != NULL && gtk_widget_has_screen (GTK_WIDGET (window))) {
                theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
        } else {
                theme = gtk_icon_theme_get_default ();
        }

        pixbuf = gtk_icon_theme_load_icon (theme,
                                           name,
                                           icon_size,
                                           GTK_ICON_LOOKUP_FORCE_SVG,
                                           NULL);

        /* make sure the pixbuf is close to the requested size
         * this is necessary because GTK_ICON_LOOKUP_FORCE_SVG
         * seems to be broken */
        if (pixbuf != NULL) {
                int width;

                width = gdk_pixbuf_get_width (pixbuf);
                if (width < (float)icon_size * 0.75) {
                        g_object_unref (pixbuf);
                        pixbuf = NULL;
                }
        }

        return pixbuf;
}
static void
xfdesktop_special_file_icon_finalize(GObject *obj)
{
    XfdesktopSpecialFileIcon *icon = XFDESKTOP_SPECIAL_FILE_ICON(obj);
    GtkIconTheme *itheme = gtk_icon_theme_get_for_screen(icon->priv->gscreen);

    g_signal_handlers_disconnect_by_func(G_OBJECT(itheme),
                                         G_CALLBACK(xfdesktop_icon_invalidate_pixbuf),
                                         icon);

    if(icon->priv->monitor) {
        g_signal_handlers_disconnect_by_func(icon->priv->monitor,
                                             G_CALLBACK(xfdesktop_special_file_icon_changed),
                                             icon);
        g_object_unref(icon->priv->monitor);
    }

    g_object_unref(icon->priv->file);

    if(icon->priv->file_info)
        g_object_unref(icon->priv->file_info);

    if(icon->priv->tooltip)
        g_free(icon->priv->tooltip);

    G_OBJECT_CLASS(xfdesktop_special_file_icon_parent_class)->finalize(obj);
}
Ejemplo n.º 11
0
static void
bigboard_button_applet_realized (PanelApplet *applet,
                                 gpointer     data)
{
        ButtonData *button_data;
        GdkScreen       *screen;

        button_data = (ButtonData *) data;

        if (button_data->icon_theme != NULL)
                g_signal_handlers_disconnect_by_func (button_data->icon_theme,
                                                      theme_changed_callback,
                                                      button_data);

        screen = gtk_widget_get_screen (button_data->applet);

        button_data->icon_theme = gtk_icon_theme_get_for_screen (screen);
        wncklet_connect_while_alive (button_data->icon_theme, "changed",
                                     G_CALLBACK (theme_changed_callback),
                                     button_data,
                                     button_data->applet);

        button_data->suppress_popout_set = TRUE;
        update_button_state (button_data);
        button_data->suppress_popout_set = FALSE;
}
Ejemplo n.º 12
0
static void
ensure_pixbuf_for_gicon (GtkIconHelper *self,
                         GtkStyleContext *context)
{
  GtkIconTheme *icon_theme;
  gint width, height;
  GtkIconInfo *info;
  GtkIconLookupFlags flags;

  if (!check_invalidate_pixbuf (self, context))
    return;

  icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
  flags = get_icon_lookup_flags (self, context);

  ensure_icon_size (self, context, &width, &height);

  if (self->priv->gicon != NULL)
    {
      info = gtk_icon_theme_lookup_by_gicon (icon_theme,
                                             self->priv->gicon,
                                             MIN (width, height), flags);
    }
  else
    {
      g_assert_not_reached ();
      return;
    }

  self->priv->rendered_pixbuf = ensure_stated_icon_from_info (self, context, info);

  if (info)
    g_object_unref (info);
}
Ejemplo n.º 13
0
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);
}
Ejemplo n.º 14
0
static void icon_gicon(pqi inst, GIcon* icon, int size)
{
	GtkIconTheme *ithm = gtk_icon_theme_get_for_screen(gtk_widget_get_screen(inst->box)); /* Get the image theme of our box. */
	GtkIconInfo *iinfo = gtk_icon_theme_lookup_by_gicon(ithm, icon, size, 0); /* We need the pixbuf of our icon. */
	inst->pmainicon = gtk_icon_info_load_icon(iinfo, NULL); /* Now we're cooking with gas. */
	inst->pmainicon_glow = make_bright_pixbuf(inst->pmainicon);
	g_object_ref(inst->pmainicon); g_object_ref(inst->pmainicon_glow);
}
Ejemplo n.º 15
0
static gboolean
xfce_panel_image_load (gpointer data)
{
  XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (data)->priv;
  GdkPixbuf             *pixbuf;
  GdkScreen             *screen;
  GtkIconTheme          *icon_theme = NULL;
  gint                   dest_w, dest_h;

  GDK_THREADS_ENTER ();

  dest_w = priv->width;
  dest_h = priv->height;

  if (G_UNLIKELY (priv->force_icon_sizes
      && dest_w < 32
      && dest_w == dest_h))
    {
      /* we use some hardcoded values here for convienence,
       * above 32 pixels svg icons will kick in */
      if (dest_w > 16 && dest_w < 22)
        dest_w = 16;
      else if (dest_w > 22 && dest_w < 24)
        dest_w = 22;
      else if (dest_w > 24 && dest_w < 32)
        dest_w = 24;

      dest_h = dest_w;
    }

  if (priv->pixbuf != NULL)
    {
      /* use the pixbuf set by the user */
      pixbuf = g_object_ref (G_OBJECT (priv->pixbuf));

      if (G_LIKELY (pixbuf != NULL))
        {
          /* scale the icon to the correct size */
          priv->cache = xfce_panel_image_scale_pixbuf (pixbuf, dest_w, dest_h);
          g_object_unref (G_OBJECT (pixbuf));
        }
    }
  else
    {
      screen = gtk_widget_get_screen (GTK_WIDGET (data));
      if (G_LIKELY (screen != NULL))
        icon_theme = gtk_icon_theme_get_for_screen (screen);

      priv->cache = xfce_panel_pixbuf_from_source_at_size (priv->source, icon_theme, dest_w, dest_h);
    }

  if (G_LIKELY (priv->cache != NULL))
    gtk_widget_queue_draw (GTK_WIDGET (data));

  GDK_THREADS_LEAVE ();

  return FALSE;
}
Ejemplo n.º 16
0
/**
 * gul_gui_image_set_from_mime_type:
 * @image: a #GtkImage
 * @mime_type: a MIME type
 * @icon_size: a stock icon size
 *
 * Set the @image to display the icon for MIME type @mime_type.  Sample MIME
 * types are "text/plain", "application/ogg".  Sample stock sizes are
 * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_DIALOG.
 */
void
gul_gui_image_set_from_mime_type (GtkWidget  *image,
		                  const char *mime_type,
				  GtkIconSize icon_size)
{
	GtkIconTheme *theme;
	char           *icon;
	GtkIconSource  *source;
	GtkIconSet     *icon_set;

	g_return_if_fail (GTK_IS_IMAGE(image));
	g_return_if_fail (mime_type != NULL);

	theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (image));

	icon = gnome_icon_lookup (theme, NULL, NULL, NULL, NULL,
				  mime_type,
				  GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);

	if (!g_path_is_absolute (icon))
	{
		int   width, height;
		GtkIconInfo *icon_info;

		if (!gtk_icon_size_lookup_for_settings 
			(gtk_widget_get_settings (GTK_WIDGET(image)),
			 icon_size, &width, &height))
		{
			width = height = -1;
		}

		icon_info = gtk_icon_theme_lookup_icon (theme, icon, height,0);
		g_free (icon);

		g_return_if_fail (icon_info != NULL);

		icon = g_strdup (gtk_icon_info_get_filename (icon_info));
		gtk_icon_info_free (icon_info);
	}

	/* Now that we have the icon filename, wrap it into an GtkIconSet so
	 * that we really get the desired size; the icon size in the file may
	 * still be arbitrary, in case of SVG themes, for example.
	 */

	source = gtk_icon_source_new ();
	gtk_icon_source_set_filename (source, icon);
	g_free (icon);

	icon_set = gtk_icon_set_new ();
	gtk_icon_set_add_source (icon_set, source);
	gtk_icon_source_free (source);

	gtk_image_set_from_icon_set (GTK_IMAGE(image), icon_set, icon_size);

	gtk_icon_set_unref (icon_set);
}
Ejemplo n.º 17
0
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);
}
Ejemplo n.º 18
0
static void
xfce_xkb_construct (XfcePanelPlugin *plugin)
{
    GtkWidget *configure_layouts;
    GtkIconTheme *theme;
    GtkWidget *image;
    GdkPixbuf *pixbuf;

    t_xkb *xkb = xkb_new (plugin);

    xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

    xfce_panel_plugin_set_small (plugin, TRUE);

    g_signal_connect (plugin, "orientation-changed",
            G_CALLBACK (xfce_xkb_orientation_changed), xkb);

    g_signal_connect (plugin, "size-changed",
            G_CALLBACK (xfce_xkb_set_size), xkb);

    g_signal_connect (plugin, "free-data",
            G_CALLBACK (xfce_xkb_free_data), xkb);

    g_signal_connect (plugin, "save",
            G_CALLBACK (xfce_xkb_save_config), xkb);

    xfce_panel_plugin_menu_show_configure (plugin);
    g_signal_connect (plugin, "configure-plugin",
            G_CALLBACK (xfce_xkb_configure), xkb);

    xfce_panel_plugin_menu_show_about (plugin);
    g_signal_connect (plugin, "about",
            G_CALLBACK (xfce_xkb_about), xkb);

    configure_layouts =
        gtk_menu_item_new_with_label (_("Keyboard settings"));

    theme = gtk_icon_theme_get_for_screen (gdk_screen_get_default());
    pixbuf = gtk_icon_theme_load_icon (theme, "preferences-desktop-keyboard",
                                       GTK_ICON_SIZE_MENU, 0, NULL);
    if (pixbuf != NULL)
    {
        image = gtk_image_new ();
        gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (configure_layouts),
                                       image);
        g_object_unref (pixbuf);
    }

    gtk_widget_show (configure_layouts);
    xfce_panel_plugin_menu_insert_item (plugin,
                                        GTK_MENU_ITEM (configure_layouts));

    g_signal_connect (G_OBJECT (configure_layouts), "activate",
                      G_CALLBACK (xfce_xkb_configure_layout), NULL);
}
Ejemplo n.º 19
0
/**
 * gtk_clutter_texture_set_from_icon_name:
 * @texture: a #GtkClutterTexture
 * @widget: (allow-none): a #GtkWidget or %NULL
 * @icon_name: the name of the icon
 * @icon_size: the icon size or -1
 * @error: a return location for errors, or %NULL
 *
 * Sets the contents of @texture using the @icon_name from the
 * current icon theme.
 *
 * Return value: %TRUE on success, %FALSE on failure
 *
 * Since: 1.0
 */
gboolean
gtk_clutter_texture_set_from_icon_name (GtkClutterTexture  *texture,
                                        GtkWidget          *widget,
                                        const gchar        *icon_name,
                                        GtkIconSize         icon_size,
                                        GError            **error)
{
  GError *local_error = NULL;
  GtkSettings *settings;
  GtkIconTheme *icon_theme;
  gboolean returnval;
  gint width, height;
  GdkPixbuf *pixbuf;

  g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
  g_return_val_if_fail (icon_name != NULL, FALSE);
  g_return_val_if_fail ((icon_size > GTK_ICON_SIZE_INVALID) || (icon_size == -1), FALSE);

  if (widget && gtk_widget_has_screen (widget))
    {
      GdkScreen *screen;

      screen = gtk_widget_get_screen (widget);
      settings = gtk_settings_get_for_screen (screen);
      icon_theme = gtk_icon_theme_get_for_screen (screen);
    }
  else
    {
      settings = gtk_settings_get_default ();
      icon_theme = gtk_icon_theme_get_default ();
    }

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  if (icon_size == -1 ||
      !gtk_icon_size_lookup_for_settings (settings, icon_size, &width, &height))
    {
      width = height = 48;
    }
  G_GNUC_END_IGNORE_DEPRECATIONS

  pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                     icon_name,
                                     MIN (width, height), 0,
                                     &local_error);
  if (local_error)
    {
      g_propagate_error (error, local_error);
      return FALSE;
    }

  returnval = gtk_clutter_texture_set_from_pixbuf (texture, pixbuf, error);
  g_object_unref (pixbuf);

  return returnval;
}
Ejemplo n.º 20
0
static void
event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
{
  GtkImageType type;

  set_drag_cursor (widget);

  type = gtk_image_get_storage_type (icon);
  if (type == GTK_IMAGE_STOCK)
    {
      gchar *stock_id;
      GdkPixbuf *pixbuf;

      gtk_image_get_stock (icon, &stock_id, NULL);
      pixbuf = gtk_widget_render_icon (widget, stock_id,
	                               GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
      gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
      g_object_unref (pixbuf);
    }
  else if (type == GTK_IMAGE_ICON_NAME)
    {
      const gchar *icon_name;
      GdkScreen *screen;
      GtkIconTheme *icon_theme;
      GtkSettings *settings;
      gint width, height;
      GdkPixbuf *pixbuf;

      gtk_image_get_icon_name (icon, &icon_name, NULL);
      screen = gtk_widget_get_screen (widget);
      icon_theme = gtk_icon_theme_get_for_screen (screen);
      settings = gtk_settings_get_for_screen (screen);

      if (!gtk_icon_size_lookup_for_settings (settings,
                                              GTK_ICON_SIZE_LARGE_TOOLBAR,
					      &width, &height))
        {
	  width = height = 24;
	}

      pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
                                         MIN (width, height), 0, NULL);
      if (G_UNLIKELY (!pixbuf))
        return;

      gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
      g_object_unref (pixbuf);

    }
  else if (type == GTK_IMAGE_PIXBUF)
    {
      GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon);
      gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
    }
}
Ejemplo n.º 21
0
static void
xplayer_fullscreen_window_unrealize_cb (GtkWidget *widget, XplayerFullscreen *fs)
{
	GdkScreen *screen;

	screen = gtk_widget_get_screen (widget);
	g_signal_handlers_disconnect_by_func (screen,
					      G_CALLBACK (xplayer_fullscreen_size_changed_cb), fs);
	g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_for_screen (screen),
					      G_CALLBACK (xplayer_fullscreen_theme_changed_cb), fs);
}
Ejemplo n.º 22
0
GthIconCache *
gth_icon_cache_new_for_widget (GtkWidget   *widget,
	                       GtkIconSize  icon_size)
{
	GtkIconTheme *icon_theme;
	int           pixel_size;

	icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
	pixel_size = _gtk_icon_get_pixel_size (widget, GTK_ICON_SIZE_MENU);

	return gth_icon_cache_new (icon_theme, pixel_size);
}
Ejemplo n.º 23
0
static void
xplayer_fullscreen_window_realize_cb (GtkWidget *widget, XplayerFullscreen *fs)
{
	GdkScreen *screen;

	screen = gtk_widget_get_screen (widget);
	g_signal_connect (G_OBJECT (screen), "size-changed",
			  G_CALLBACK (xplayer_fullscreen_size_changed_cb), fs);
	g_signal_connect (G_OBJECT (gtk_icon_theme_get_for_screen (screen)),
			  "changed",
			  G_CALLBACK (xplayer_fullscreen_theme_changed_cb), fs);
}
Ejemplo n.º 24
0
static void
applet_realized (PanelApplet  *applet,
		 TasklistData *tasklist)
{
	WnckScreen *screen;

	screen = wncklet_get_screen (GTK_WIDGET (applet));

	wnck_tasklist_set_screen (WNCK_TASKLIST (tasklist->tasklist), screen);

	tasklist->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (tasklist->applet));
}
static GdkPixbuf *
gimp_view_renderer_imagefile_get_icon (GimpImagefile *imagefile,
                                       GtkWidget     *widget,
                                       gint           size)
{
  GdkScreen     *screen     = gtk_widget_get_screen (widget);
  GtkIconTheme  *icon_theme = gtk_icon_theme_get_for_screen (screen);
  GimpThumbnail *thumbnail  = gimp_imagefile_get_thumbnail (imagefile);
  GdkPixbuf     *pixbuf     = NULL;

  if (! gimp_object_get_name (imagefile))
    return NULL;

  if (! pixbuf)
    {
      GIcon *icon = gimp_imagefile_get_gicon (imagefile);

      if (icon)
        {
          GtkIconInfo *info;

          info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon, size, 0);

          if (info)
            {
              pixbuf = gtk_icon_info_load_icon (info, NULL);

              gtk_icon_info_free (info);
            }
        }
    }

  if (! pixbuf && thumbnail->image_mimetype)
    {
      pixbuf = get_icon_for_mime_type (thumbnail->image_mimetype, size);
    }

  if (! pixbuf)
    {
      const gchar *icon_name = "text-x-generic";

      if (thumbnail->image_state == GIMP_THUMB_STATE_FOLDER)
        icon_name = "folder";

      pixbuf = gtk_icon_theme_load_icon (icon_theme,
                                         icon_name, size,
                                         GTK_ICON_LOOKUP_USE_BUILTIN,
                                         NULL);
    }

  return pixbuf;
}
Ejemplo n.º 26
0
static void
update_preview_cb (GtkFileChooser *chooser)
{
	gchar *filename = gtk_file_chooser_get_preview_filename (chooser);
	GtkWidget *label = g_object_get_data (G_OBJECT (chooser), "label-widget");
	GtkWidget *image = g_object_get_data (G_OBJECT (chooser), "image-widget");

	if (filename == NULL) {
		gtk_widget_hide (image);
		gtk_widget_hide (label);
	} else if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
		/* Not quite sure what to do here.  */
		gtk_widget_hide (image);
		gtk_widget_hide (label);
	} else {
		GdkPixbuf *buf;
		gboolean dummy;

		buf = gdk_pixbuf_new_from_file (filename, NULL);
		if (buf) {
			dummy = FALSE;
		} else {
			GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (chooser));
			buf = gtk_icon_theme_load_icon
				(gtk_icon_theme_get_for_screen (screen),
				 "unknown_image", 100, 100, NULL);
			dummy = buf != NULL;
		}

		if (buf) {
			GdkPixbuf *pixbuf = go_pixbuf_intelligent_scale (buf, PREVIEW_HSIZE, PREVIEW_VSIZE);
			gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
			g_object_unref (pixbuf);
			gtk_widget_show (image);

			if (dummy)
				gtk_label_set_text (GTK_LABEL (label), "");
			else {
				int w = gdk_pixbuf_get_width (buf);
				int h = gdk_pixbuf_get_height (buf);
				char *size = g_strdup_printf (_("%d x %d"), w, h);
				gtk_label_set_text (GTK_LABEL (label), size);
				g_free (size);
			}
			gtk_widget_show (label);

			g_object_unref (buf);
		}

		g_free (filename);
	}
}
Ejemplo n.º 27
0
static void
task_title_setup (TaskTitle *title)
{
    TaskTitlePrivate *priv = title->priv;

    priv->screen = wnck_screen_get_default ();
    priv->window = NULL;
    gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
    priv->align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (priv->align),
        0, 0, 6, 6);
    gtk_container_add (GTK_CONTAINER (title), priv->align);
    priv->grid = gtk_grid_new();
    gtk_grid_set_row_spacing (GTK_GRID(priv->grid), 2);
    gtk_container_add (GTK_CONTAINER (priv->align), priv->grid);
    gtk_widget_set_no_show_all (priv->grid, TRUE);
    gtk_widget_show (priv->grid);

    //Prepare and show the title label
    priv->label = getTitleLabel();
    gtk_grid_attach (GTK_GRID(priv->grid), priv->label, 0, 0, 1, 1);
    gtk_widget_show (priv->label);

    //Create the close button
    priv->button = getCloseButton (title);
    gtk_grid_attach (GTK_GRID(priv->grid), priv->button, 1, 0, 1, 1);
    gtk_widget_show (priv->button);

    g_signal_connect (GTK_WIDGET(title), "draw",
        G_CALLBACK (on_draw), title);

    // Prepare and add the logoff icon to the title
    GdkScreen *gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
    GtkIconTheme *theme = gtk_icon_theme_get_for_screen (gdkscreen);
    //this shows a little green exit icon, like the ones on emergency exits
    priv->quit_icon = gtk_icon_theme_load_icon (
        theme, "gnome-logout", 16, 0, NULL
    );
    priv->button_image = gtk_image_new_from_pixbuf (priv->quit_icon);
    gtk_container_add (GTK_CONTAINER (priv->button), priv->button_image);
    gtk_widget_show (priv->button_image);
    gtk_widget_set_tooltip_text (priv->button,
        _("Log off, switch user, lock screen or "
        "power down the computer")
    );
    gtk_widget_set_tooltip_text (GTK_WIDGET (title), _("Home"));
    gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
    g_signal_connect (priv->screen, "active-window-changed",
        G_CALLBACK (on_active_window_changed), title);
    g_signal_connect (title, "button-press-event",
        G_CALLBACK (on_button_press), NULL);
}
Ejemplo n.º 28
0
static void
gth_window_realize (GtkWidget *widget)
{
	GTK_WIDGET_CLASS (gth_window_parent_class)->realize (widget);

	gtk_icon_theme_append_search_path (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)), GTHUMB_ICON_DIR);

	_gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb.css");
	if ((gtk_major_version >= 3) && (gtk_minor_version >= 14))
		_gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb-gtk314.css");
	else if ((gtk_major_version >= 3) && (gtk_minor_version >= 10))
		_gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb-gtk312.css");
}
Ejemplo n.º 29
0
void
gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
				    GtkIconEntryPosition icon_pos,
				    GIcon *icon)
{
  GdkPixbuf *pixbuf = NULL;
  GtkIconEntryPrivate *priv;
  EntryIconInfo *icon_info;
  GdkScreen *screen;
  GtkIconTheme *icon_theme;
  GtkSettings *settings;
  gint width, height;
  GError *error = NULL;
  GtkIconInfo *info;

  priv = GTK_ICON_ENTRY_GET_PRIVATE (entry);
  icon_info = &priv->icons[icon_pos];

  screen = gtk_widget_get_screen (GTK_WIDGET (entry));
  icon_theme = gtk_icon_theme_get_for_screen (screen);
  settings = gtk_settings_get_for_screen (screen);

  if (icon != NULL)
    {
      gtk_icon_size_lookup_for_settings (settings,
					 GTK_ICON_SIZE_MENU,
					 &width, &height);

      #if #GTK_CHECK_VERSION (2, 14, 0)
      info = gtk_icon_theme_lookup_by_gicon (icon_theme,
					     icon,
					     MIN (width, height), 0);
      #else
      info = NULL;
      #endif
      pixbuf = gtk_icon_info_load_icon (info, &error);
      if (pixbuf == NULL)
	{
	  g_error_free (error);
	  pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry),
					   GTK_STOCK_MISSING_IMAGE,
					   GTK_ICON_SIZE_MENU,
					   NULL);
	}
    }

  gtk_icon_entry_set_icon_internal ((GtkIconEntry*)entry,
				    icon_pos,
				    pixbuf);
}
Ejemplo n.º 30
0
static void
pluma_spinner_screen_changed (GtkWidget *widget,
			      GdkScreen *old_screen)
{
	PlumaSpinner *spinner = PLUMA_SPINNER (widget);
	PlumaSpinnerPrivate *priv = spinner->priv;
	GdkScreen *screen;

	if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
	{
		GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, old_screen);
	}

	screen = gtk_widget_get_screen (widget);

	/* FIXME: this seems to be happening when then spinner is destroyed!? */
	if (old_screen == screen)
		return;

	/* We'll get mapped again on the new screen, but not unmapped from
	 * the old screen, so remove timeout here.
	 */
	pluma_spinner_remove_update_callback (spinner);

	pluma_spinner_unload_images (spinner);

	if (old_screen != NULL)
	{
		g_signal_handlers_disconnect_by_func
			(gtk_icon_theme_get_for_screen (old_screen),
			 G_CALLBACK (icon_theme_changed_cb), spinner);
	}

	priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
	g_signal_connect (priv->icon_theme, "changed",
			  G_CALLBACK (icon_theme_changed_cb), spinner);
}