const gchar *
xfce_volstatus_get_icon_name()
{
    const gchar *icon_name = NULL;
    GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
    
    if(gtk_icon_theme_has_icon(icon_theme, "drive-removable-media"))
        icon_name = "drive-removable-media";
    else if(gtk_icon_theme_has_icon(icon_theme, "gnome-dev-removable"))
        icon_name = "gnome-dev-removable";
    
    return icon_name;
}
예제 #2
0
static void add_stock_item(void)
{
	GtkIconSet *icon_set;
	GtkIconFactory *factory = gtk_icon_factory_new();
	GtkIconTheme *theme = gtk_icon_theme_get_default();
	GtkStockItem item = { (gchar*)(GEANYSENDMAIL_STOCK_MAIL), (gchar*)(N_("Mail")), 0, 0, (gchar*)(GETTEXT_PACKAGE) };

	if (gtk_icon_theme_has_icon(theme, "mail-message-new"))
	{
		GtkIconSource *icon_source = gtk_icon_source_new();
		icon_set = gtk_icon_set_new();
		gtk_icon_source_set_icon_name(icon_source, "mail-message-new");
		gtk_icon_set_add_source(icon_set, icon_source);
		gtk_icon_source_free(icon_source);
	}
	else
	{
		GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data(mail_icon);
		icon_set = gtk_icon_set_new_from_pixbuf(pb);
		g_object_unref(pb);
	}
	gtk_icon_factory_add(factory, item.stock_id, icon_set);
	gtk_stock_add(&item, 1);
	gtk_icon_factory_add_default(factory);

	g_object_unref(factory);
	gtk_icon_set_unref(icon_set);
}
예제 #3
0
static const char *get_tray_icon_name (char *name)
{
	const char * icon_name;

	if (strcasecmp(show_in_the_tray, "Icon") == 0)
	{
		icon_name = PACKAGE;
		return icon_name;
	}

	GtkIconTheme * theme = gtk_icon_theme_get_default( );

	// if the tray's icon is a 48x48 file, use it;
	// otherwise, use the fallback builtin icon 
	if (!gtk_icon_theme_has_icon (theme, name))
	{
		icon_name = PACKAGE;
	}
	else
	{
		GtkIconInfo * icon_info = gtk_icon_theme_lookup_icon (theme, name, 48, GTK_ICON_LOOKUP_USE_BUILTIN);
		const gboolean icon_is_builtin = gtk_icon_info_get_filename (icon_info) == NULL;
		gtk_icon_info_free (icon_info);
		icon_name = icon_is_builtin ? PACKAGE : name;
	}

	return icon_name;
}
예제 #4
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;
}
예제 #5
0
파일: ui.c 프로젝트: fatman2021/marco
GdkPixbuf*
meta_ui_get_default_mini_icon (MetaUI *ui)
{
  static GdkPixbuf *default_icon = NULL;

  if (default_icon == NULL)
    {
      GtkIconTheme *theme;
      gboolean icon_exists;

      theme = gtk_icon_theme_get_default ();

      icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);

      if (icon_exists)
          default_icon = gtk_icon_theme_load_icon (theme,
                                                   META_DEFAULT_ICON_NAME,
                                                   META_MINI_ICON_WIDTH,
                                                   0,
                                                   NULL);
      else
          default_icon = gtk_icon_theme_load_icon (theme,
                                                   "image-missing",
                                                   META_MINI_ICON_WIDTH,
                                                   0,
                                                   NULL);

      g_assert (default_icon);
    }

  g_object_ref (G_OBJECT (default_icon));

  return default_icon;
}
예제 #6
0
	void mate_about_run(void)
	{
		mate_about_dialog = (GtkAboutDialog*) gtk_about_dialog_new();

		gtk_window_set_default_icon_name(desktop_icon);

		GtkIconTheme* icon_theme = gtk_icon_theme_get_default();

		if (gtk_icon_theme_has_icon(icon_theme, icon))
		{
			gtk_about_dialog_set_logo_icon_name(mate_about_dialog, icon);
		}
		else
		{
			gtk_about_dialog_set_logo_icon_name(mate_about_dialog, desktop_icon);
		}

		// name
		#if GTK_CHECK_VERSION(3, 0, 0) || GTK_CHECK_VERSION(2, 12, 0)
			gtk_about_dialog_set_program_name(mate_about_dialog, gettext(program_name));
		#else
			gtk_about_dialog_set_name(mate_about_dialog, gettext(program_name));
		#endif

		// version
		gtk_about_dialog_set_version(mate_about_dialog, version);

		// credits and website
		gtk_about_dialog_set_copyright(mate_about_dialog, copyright);
		gtk_about_dialog_set_website(mate_about_dialog, website);

		/**
		 * This generate a random message.
		 * The comments index must not be more than comments_count - 1
		 */
		gtk_about_dialog_set_comments(mate_about_dialog, gettext(comments_array[g_random_int_range(0, comments_count - 1)]));

		gtk_about_dialog_set_authors(mate_about_dialog, authors);
		gtk_about_dialog_set_artists(mate_about_dialog, artists);
		gtk_about_dialog_set_documenters(mate_about_dialog, documenters);
		/* Translators should localize the following string which will be
		 * displayed in the about box to give credit to the translator(s). */
		gtk_about_dialog_set_translator_credits(mate_about_dialog, _("translator-credits"));

		#if GTK_CHECK_VERSION(3, 0, 0)
			gtk_about_dialog_set_license_type(mate_about_dialog, GTK_LICENSE_GPL_3_0);
			gtk_about_dialog_set_wrap_license(mate_about_dialog, TRUE);
		#endif

		#ifdef USE_UNIQUE
			unique_app_watch_window(mate_about_application, (GtkWindow*) mate_about_dialog);
		#elif GTK_CHECK_VERSION(3, 0, 0) && !defined(UNIQUE)
			gtk_window_set_application(GTK_WINDOW(mate_about_dialog), mate_about_application);
		#endif

		// start and destroy
		gtk_dialog_run((GtkDialog*) mate_about_dialog);
		gtk_widget_destroy((GtkWidget*) mate_about_dialog);
	}
예제 #7
0
static GtkStatusIcon *si_create(void)
{
    GtkStatusIcon *icon;
    GtkIconTheme *theme;

    theme = gtk_icon_theme_get_default();

    if (gtk_icon_theme_has_icon(theme, "audacious-panel"))
        icon = gtk_status_icon_new_from_icon_name("audacious-panel");
    else if (gtk_icon_theme_has_icon(theme, "audacious"))
        icon = gtk_status_icon_new_from_icon_name("audacious");
    else
    {
        gchar * path = g_strdup_printf ("%s/images/audacious.png",
         aud_get_path (AUD_PATH_DATA_DIR));
        icon = gtk_status_icon_new_from_file (path);
        g_free (path);
    }

    return icon;
}
예제 #8
0
const gchar *
empathy_icon_name_for_presence (TpConnectionPresenceType presence)
{
  switch (presence)
    {
      case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
        return EMPATHY_IMAGE_AVAILABLE;
      case TP_CONNECTION_PRESENCE_TYPE_BUSY:
        return EMPATHY_IMAGE_BUSY;
      case TP_CONNECTION_PRESENCE_TYPE_AWAY:
        return EMPATHY_IMAGE_AWAY;
      case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
        if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
                   EMPATHY_IMAGE_EXT_AWAY))
          return EMPATHY_IMAGE_EXT_AWAY;

        /* The 'extended-away' icon is not an official one so we fallback to
         * idle if it's not implemented */
        return EMPATHY_IMAGE_IDLE;
      case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
        if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
                   EMPATHY_IMAGE_HIDDEN))
          return EMPATHY_IMAGE_HIDDEN;

        /* The 'hidden' icon is not an official one so we fallback to offline if
         * it's not implemented */
        return EMPATHY_IMAGE_OFFLINE;
      case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
      case TP_CONNECTION_PRESENCE_TYPE_ERROR:
        return EMPATHY_IMAGE_OFFLINE;
      case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
        return EMPATHY_IMAGE_PENDING;
      case TP_CONNECTION_PRESENCE_TYPE_UNSET:
      default:
        return NULL;
    }

  return NULL;
}
static const gchar*
thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume,
                                        GtkIconTheme    *icon_theme)
{
  GList *lp;

  /* check if we have atleast one usable icon in our icon_list */
  for (lp = THUNAR_VFS_VOLUME_HAL (volume)->icon_list; lp != NULL; lp = lp->next)
    if (gtk_icon_theme_has_icon (icon_theme, lp->data))
      return lp->data;

  /* fallback in thunar_vfs_volume_lookup_icon() */
  return NULL;
}
예제 #10
0
const gchar *
eom_plugin_engine_get_plugin_icon_name (EomPluginInfo *info)
{
	g_return_val_if_fail (info != NULL, NULL);

	/* Use the eom-plugin icon as a default if the plugin does not
	   have its own */
	if (info->icon_name != NULL &&
	    gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
	    			     info->icon_name))
		return info->icon_name;
	else
		return "eom-plugin";
}
예제 #11
0
파일: icontheme.c 프로젝트: amery/clip-itk
int
clip_GTK_ICONTHEMEHASICON(ClipMachine * cm)
{
        C_object *cicon   = _fetch_co_arg(cm);
        gchar     *name   = _clip_parc(cm, 2);

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

	_clip_retl(cm, gtk_icon_theme_has_icon(GTK_ICON_THEME(cicon->object),
			name));
	return 0;
err:
	return 1;
}
예제 #12
0
static String lookupIconName(String MIMEType)
{
    /*
     Lookup an appropriate icon according to either the Icon Naming Spec
     or conventional Gnome icon names respectively.

     See http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

     The icon theme is probed for the following names:
     1. media-subtype
     2. gnome-mime-media-subtype
     3. media-x-generic
     4. gnome-mime-media

     In the worst case it falls back to the stock file icon.
    */
    int pos = MIMEType.find('/');
    if(pos >= 0) {
        String media = MIMEType.substring(0, pos);
        String subtype = MIMEType.substring(pos + 1);
        GtkIconTheme* iconTheme = gtk_icon_theme_get_default();
        String iconName = media + "-" + subtype;
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
            return iconName;
        iconName = "gnome-mime-" + media + "-" + subtype;
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
            return iconName;
        iconName = media + "-x-generic";
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
            return iconName;
        iconName = media + "gnome-mime-" + media;
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
            return iconName;
    }
    return GTK_STOCK_FILE;
}
예제 #13
0
static GtkToolItem * toggle_button_new (const gchar * icon, const gchar * alt,
 void (* toggled) (GtkToggleToolButton * button))
{
    GtkToolItem * item = gtk_toggle_tool_button_new ();

    if (! alt)
        gtk_tool_button_set_stock_id ((GtkToolButton *) item, icon);
    else if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), icon))
        gtk_tool_button_set_icon_name ((GtkToolButton *) item, icon);
    else
        gtk_tool_button_set_label ((GtkToolButton *) item, alt);

    g_signal_connect (item, "toggled", (GCallback) toggled, NULL);
    return item;
}
예제 #14
0
/**
 * _rb_action_group_add_source_actions:
 * @group: a #GtkActionGroup
 * @shell: the #RBShell
 * @actions: array of GtkActionEntry structures for the action group
 * @num_actions: number of actions in the @actions array
 *
 * Adds actions to an action group where the action callback is
 * called with the current selected source.  This can safely be called
 * multiple times on the same action group.
 */
void
_rb_action_group_add_source_actions (GtkActionGroup *group,
				     GObject *shell,
				     GtkActionEntry *actions,
				     int num_actions)
{
	int i;
	for (i = 0; i < num_actions; i++) {
		GtkAction *action;
		const char *label;
		const char *tooltip;
		SourceActionData *source_action_data;

		if (gtk_action_group_get_action (group, actions[i].name) != NULL) {
			/* action was already added */
			continue;
		}

		label = gtk_action_group_translate_string (group, actions[i].label);
		tooltip = gtk_action_group_translate_string (group, actions[i].tooltip);

		action = gtk_action_new (actions[i].name, label, tooltip, NULL);
		if (actions[i].stock_id != NULL) {
			g_object_set (action, "stock-id", actions[i].stock_id, NULL);
			if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
						     actions[i].stock_id)) {
				g_object_set (action, "icon-name", actions[i].stock_id, NULL);
			}
		}

		if (actions[i].callback) {
			GClosure *closure;
			source_action_data = g_slice_new0 (SourceActionData);
			source_action_data->callback = (SourceActionCallback) actions[i].callback;
			source_action_data->shell = shell;
			g_object_add_weak_pointer (shell, &source_action_data->shell);

			closure = g_cclosure_new (G_CALLBACK (source_action_cb),
						  source_action_data,
						  (GClosureNotify) source_action_data_destroy);
			g_signal_connect_closure (action, "activate", closure, FALSE);
		}

		gtk_action_group_add_action_with_accel (group, action, actions[i].accelerator);
		g_object_unref (action);
	}
}
예제 #15
0
static void
set_icon(GtkWindow *window, const gchar *uri)
{
    GFile *file;
    GIcon *icon;
    GFileInfo *info;
    GdkScreen *screen;
    GtkIconTheme *icon_theme;
    const gchar *icon_name = NULL, *content_type;

    screen = gtk_widget_get_screen (GTK_WIDGET (window));
    icon_theme = gtk_icon_theme_get_for_screen (screen);

    file = g_file_new_for_uri (uri);

    info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
                              G_FILE_QUERY_INFO_NONE, NULL, NULL);
    g_object_unref (file);

    if (! info)
	return;

    content_type = g_file_info_get_content_type (info);
    icon = g_content_type_get_icon (content_type);

    if (G_IS_THEMED_ICON (icon)) {
       const gchar * const *names = NULL;

       names = g_themed_icon_get_names (G_THEMED_ICON (icon));
       if (names) {
          gint i;
          for (i = 0; names[i]; i++) {
	      if (gtk_icon_theme_has_icon (icon_theme, names[i])) {
		  icon_name = names[i];
		  break;
	      }
          }
       }
    }

    if (icon_name) {
        gtk_window_set_icon_name (window, icon_name);
    }

    g_object_unref (icon);
}
예제 #16
0
static GdkPixbuf *
task_item_sized_pixbuf_for_window (TaskItem   *item,
                                   WnckWindow *window,
                                   gint size)
{
  GdkPixbuf *pbuf = NULL;
  
  g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
  
  if (wnck_window_has_icon_name (window))
  {
    const gchar *icon_name = wnck_window_get_icon_name (window);
    GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
    
    if (gtk_icon_theme_has_icon (icon_theme, icon_name))
    {
      GdkPixbuf *internal = gtk_icon_theme_load_icon (icon_theme, 
                                                      icon_name,
                                                      size,
                                                      GTK_ICON_LOOKUP_FORCE_SIZE,
                                                      NULL);
      pbuf = gdk_pixbuf_copy (internal);
      g_object_unref (internal);
    }
  }
  
  if (!pbuf)
  {
    pbuf = gdk_pixbuf_copy (wnck_window_get_icon (item->priv->window));
  }
  
  gint width = gdk_pixbuf_get_width (pbuf);
  gint height = gdk_pixbuf_get_height (pbuf);

  if (MAX (width, height) != size)
  {
    gdouble scale = (gdouble) size / (gdouble) MAX (width, height);
  
    GdkPixbuf *tmp = pbuf;
    pbuf = gdk_pixbuf_scale_simple (tmp, (gint) (width * scale), (gint) (height * scale), GDK_INTERP_HYPER);
    
    g_object_unref (tmp);
  }
 
  return pbuf;
}
예제 #17
0
gboolean
nautilus_icon_theme_can_render (GThemedIcon *icon)
{
	GtkIconTheme *icon_theme;
	const gchar * const *names;
	gint idx;

	names = g_themed_icon_get_names (icon);

	icon_theme = gtk_icon_theme_get_default ();

	for (idx = 0; names[idx] != NULL; idx++) {
		if (gtk_icon_theme_has_icon (icon_theme, names[idx])) {
			return TRUE;
		}
	}

	return FALSE;
}
static void power_action(const PowerActionData* action)
{
    g_return_if_fail(config.power.enabled && action->get_allow());

    if(*action->show_prompt_ptr)
    {
        GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
                                                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
                                                   "%s", _(action->prompt));
        gtk_dialog_add_buttons(GTK_DIALOG(dialog),
                               _("Return to Login"), GTK_RESPONSE_CANCEL,
                               _(action->name), GTK_RESPONSE_OK, NULL);
        gtk_widget_set_name(dialog, "power_dialog");
        gtk_window_set_title(GTK_WINDOW(dialog), action->name);
        setup_window(GTK_WINDOW(dialog));
        if(action->icon && gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), action->icon))
        {
            GtkWidget* image = gtk_image_new_from_icon_name(action->icon, GTK_ICON_SIZE_DIALOG);
            gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), image);
        }
        gtk_widget_hide(greeter.ui.login_window);
        gtk_widget_set_sensitive(greeter.ui.power.widget, FALSE);
        gtk_widget_show_all(dialog);
        set_window_position(dialog, &WINDOW_POSITION_CENTER);

        gboolean result = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
        gtk_widget_destroy(dialog);
        gtk_widget_show(greeter.ui.login_window);
        update_windows_layout();
        gtk_widget_set_sensitive(greeter.ui.power.widget, TRUE);

        if(!result)
            return;
    }

    GError* error = NULL;
    if(!action->do_action(&error) && error)
    {
        g_warning("Action \"%s\" failed with error: %s.", action->name, error->message);
        show_error(_(action->name), _("Action \"%s\" failed with error: %s."), _(action->name), error->message);
        g_clear_error(&error);
    }
}
예제 #19
0
char *
panel_util_get_icon_name_from_g_icon (GIcon *gicon)
{
	const char * const *names;
	GtkIconTheme *icon_theme;
	int i;

	if (!G_IS_THEMED_ICON (gicon))
		return NULL;

	names = g_themed_icon_get_names (G_THEMED_ICON (gicon));
	icon_theme = gtk_icon_theme_get_default ();

	for (i = 0; names[i] != NULL; i++) {
		if (gtk_icon_theme_has_icon (icon_theme, names[i]))
			return g_strdup (names[i]);
	}

	return NULL;
}
예제 #20
0
GdkPixbuf* create_pixbuf_by_icon_name(const char *icon_name, gint icon_size_px)
{
    GtkIconTheme *default_icon_theme = gtk_icon_theme_get_default();

    GError *error = NULL;
    GdkPixbuf *pixbuf = NULL;

    if(gtk_icon_theme_has_icon(default_icon_theme, icon_name))
    {
        pixbuf = gtk_icon_theme_load_icon(default_icon_theme, icon_name, icon_size_px, GTK_ICON_LOOKUP_FORCE_SIZE, &error);
    }
    else
    {
        trace("Current theme does not have icon %s\n", icon_name);
        pixbuf = gtk_icon_theme_load_icon(default_icon_theme, "image-missing", icon_size_px, GTK_ICON_LOOKUP_FORCE_SIZE, &error); // TODO: is it bulletproof or could also fail?
    }

    assert(pixbuf != NULL);

    return pixbuf;
}
예제 #21
0
GimpAction *
gimp_action_new (const gchar *name,
                 const gchar *label,
                 const gchar *tooltip,
                 const gchar *stock_id)
{
  GimpAction *action;

  action = g_object_new (GIMP_TYPE_ACTION,
                         "name",     name,
                         "label",    label,
                         "tooltip",  tooltip,
                         "stock-id", stock_id,
                         NULL);

  if (stock_id)
    {
      if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), stock_id))
        gtk_action_set_icon_name (GTK_ACTION (action), stock_id);
    }

  return action;
}
예제 #22
0
struct statusicon *create_statusicon(GtkWidget *box, const char *filename,
        const char *tooltips, const char* icon_name)
{
    struct statusicon *newicon;
    newicon = malloc(sizeof(struct statusicon));

    /* main */
    newicon->main = gtk_event_box_new();

    gtk_widget_set_has_window(newicon->main, FALSE);
    gtk_widget_add_events(newicon->main, GDK_BUTTON_PRESS_MASK);
    gtk_widget_set_size_request(newicon->main, 24, 24);
    gtk_box_pack_start(GTK_BOX(box), newicon->main, TRUE, TRUE, 0);

    /* icon */

    /*icon theme*/
    GtkIconTheme* icon_theme = gtk_icon_theme_get_default();

    /*if we've got a theme*/
    if(gtk_icon_theme_has_icon(icon_theme, icon_name)) {
        GdkPixbuf* temp_pixbuf = gtk_icon_theme_load_icon(icon_theme, icon_name, 24, 0, NULL);
        newicon->icon = gtk_image_new_from_pixbuf(temp_pixbuf);
    }

    /* oh well...*/
    else {
        newicon->icon = gtk_image_new_from_file(filename);
    }
    gtk_container_add(GTK_CONTAINER(newicon->main), newicon->icon);
    gtk_widget_show_all(newicon->main);

    /* tooltip */
    gtk_widget_set_tooltip_text(newicon->main, tooltips);

    return newicon;
}
예제 #23
0
static GtkWidget *get_image(const char *icon_name) {
    if (STR_IS_EMPTY(icon_name))
        icon_name = "applications-other";

    GtkWidget *image = NULL;

    if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), icon_name)) {
        GdkPixbuf *pixbuf = get_pixbuf_from_icon(icon_name);
        if (!pixbuf && *icon_name != '/') {
            char buf[1024] = { 0 };
            snprintf(buf, 1024, "/usr/share/pixmaps/%s", icon_name);
            pixbuf = get_pixbuf_from_icon(buf);
        }
        if (pixbuf) {
            image = gtk_image_new_from_pixbuf(pixbuf);
        }
    }

    if (!image) {
        image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
    }

    return image;
}
예제 #24
0
static VALUE
it_has_icon(VALUE self, VALUE icon_name)
{
    return CBOOL2RVAL(gtk_icon_theme_has_icon(_SELF(self), 
                                              RVAL2CSTR(icon_name)));
}
예제 #25
0
void init_ui(int *argcp, char ***argvp)
{
	GtkWidget *win;
	GtkWidget *notebook;
	GtkWidget *dive_info;
	GtkWidget *dive_list;
	GtkWidget *equipment;
	GtkWidget *stats;
	GtkWidget *menubar;
	GtkWidget *vbox;
	GdkScreen *screen;
	GtkIconTheme *icon_theme=NULL;
	GtkSettings *settings;

	gtk_init(argcp, argvp);
	settings = gtk_settings_get_default();
	gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "subsurface setting");

	g_type_init();

	subsurface_open_conf();
	if (subsurface_get_conf("feet", PREF_BOOL))
		output_units.length = FEET;
	if (subsurface_get_conf("psi", PREF_BOOL))
		output_units.pressure = PSI;
	if (subsurface_get_conf("cuft", PREF_BOOL))
		output_units.volume = CUFT;
	if (subsurface_get_conf("fahrenheit", PREF_BOOL))
		output_units.temperature = FAHRENHEIT;
	/* an unset key is FALSE - all these are hidden by default */
	visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL));
	visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL));
	visible_cols.nitrox = PTR_TO_BOOL(subsurface_get_conf("NITROX", PREF_BOOL));
	visible_cols.otu = PTR_TO_BOOL(subsurface_get_conf("OTU", PREF_BOOL));
	visible_cols.sac = PTR_TO_BOOL(subsurface_get_conf("SAC", PREF_BOOL));

	divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);

	if (!divelist_font)
		divelist_font = DIVELIST_DEFAULT_FONT;

	error_info_bar = NULL;
	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_set_application_name ("subsurface");
	/* Let's check if the subsurface icon has been installed or if
	 * we need to try to load it from the current directory */
	screen = gdk_screen_get_default();
	if (screen)
		icon_theme = gtk_icon_theme_get_for_screen(screen);
	if (icon_theme) {
		if (gtk_icon_theme_has_icon(icon_theme, "subsurface")) {
			need_icon = FALSE;
			gtk_window_set_default_icon_name ("subsurface");
		}
	}
	if (need_icon)
#if defined __linux__ || defined __APPLE__
		gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL);
#elif defined WIN32
		gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL);
#endif
	g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL);
	g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
	main_window = win;

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(win), vbox);
	main_vbox = vbox;

	menubar = get_menubar_menu(win);
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);

	vpane = gtk_vpaned_new();
	gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 3);

	hpane = gtk_hpaned_new();
	gtk_paned_add1(GTK_PANED(vpane), hpane);

	/* Notebook for dive info vs profile vs .. */
	notebook = gtk_notebook_new();
	gtk_paned_add1(GTK_PANED(hpane), notebook);
	g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL);

	/* Create the actual divelist */
	dive_list = dive_list_create();
	gtk_widget_set_name(dive_list, "Dive List");
	gtk_paned_add2(GTK_PANED(vpane), dive_list);

	/* Frame for dive profile */
	dive_profile = dive_profile_widget();
	gtk_widget_set_name(dive_profile, "Dive Profile");
	gtk_paned_add2(GTK_PANED(hpane), dive_profile);

	/* Frame for extended dive info */
	dive_info = extended_dive_info_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_info, gtk_label_new("Dive Notes"));

	/* Frame for dive equipment */
	equipment = equipment_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), equipment, gtk_label_new("Equipment"));

	/* Frame for dive statistics */
	stats = stats_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), stats, gtk_label_new("Info & Stats"));

	gtk_widget_set_app_paintable(win, TRUE);
	gtk_widget_show_all(win);

	return;
}
static GIcon *
xfdesktop_load_icon_from_desktop_file(XfdesktopRegularFileIcon *regular_icon)
{
    gchar *contents, *icon_name;
    gsize length;
    GIcon *gicon = NULL;
    gchar *p;
    GKeyFile *key_file;

    /* try to load the file into memory */
    if(!g_file_load_contents(regular_icon->priv->file, NULL, &contents, &length, NULL, NULL))
        return NULL;

    /* allocate a new key file */
    key_file = g_key_file_new();

    /* try to parse the key file from the contents of the file */
    if(!g_key_file_load_from_data(key_file, contents, length, 0, NULL)) {
        g_free(contents);
        return NULL;
    }

    /* try to determine the custom icon name */
    icon_name = g_key_file_get_string(key_file,
                                      G_KEY_FILE_DESKTOP_GROUP,
                                      G_KEY_FILE_DESKTOP_KEY_ICON,
                                      NULL);

    /* No icon name in the desktop file */
    if(icon_name == NULL) {
        /* free key file and in-memory data */
        g_key_file_free(key_file);
        g_free(contents);
        return NULL;
    }

    /* icon_name is an absolute path, create it as a file icon */
    if(g_file_test(icon_name, G_FILE_TEST_IS_REGULAR)) {
        gicon = g_file_icon_new(g_file_new_for_path(icon_name));
    }

    /* check if the icon theme includes the icon name as-is */
    if(gicon == NULL) {
        if(gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), icon_name)) {
            /* load it */
            gicon = g_themed_icon_new(icon_name);
        }
    }

    /* drop any suffix (e.g. '.png') from themed icons and try to laod that */
    if(gicon == NULL) {
        gchar *tmp_name = NULL;

        p = strrchr(icon_name, '.');
        if(p != NULL)
            tmp_name = g_strndup(icon_name, p - icon_name);

        /* check if the icon theme includes the icon name */
        if(tmp_name && gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), tmp_name)) {
            /* load it */
            gicon = g_themed_icon_new(tmp_name);
        }
        g_free(tmp_name);
    }

    /* maybe it points to a file in the pixmaps folder */
    if(gicon == NULL) {
        gchar *filename = g_build_filename("pixmaps", icon_name, NULL);
        gchar *tmp_name = NULL;

        if(filename)
            tmp_name = xfce_resource_lookup(XFCE_RESOURCE_DATA, filename);

        if(tmp_name)
            gicon = g_file_icon_new(g_file_new_for_path(tmp_name));

        g_free(filename);
        g_free(tmp_name);
    }

    /* free key file and in-memory data */
    g_key_file_free(key_file);
    g_free(contents);
    g_free(icon_name);

    return gicon;
}
예제 #27
0
/* Does the current iconset have all the icons the application (plugin authors,
 * add requests here) needs? If icons could use themed icons, but fallbacks would
 * be okay (non-standard themed icons), don't check here, and use a force flag of
 * TRUE in your set_icon() calls.
 */
gboolean check_icon_theme()
{
    icontheme = gtk_icon_theme_get_default();
    if(gtk_icon_theme_has_icon(icontheme, "media-playback-start")&&
            gtk_icon_theme_has_icon(icontheme, "media-playback-pause")&&
            gtk_icon_theme_has_icon(icontheme, "media-playback-stop")&&
            gtk_icon_theme_has_icon(icontheme, "view-fullscreen")&&
            gtk_icon_theme_has_icon(icontheme, "preferences-system")&&
            gtk_icon_theme_has_icon(icontheme, "dialog-warning")&&
            gtk_icon_theme_has_icon(icontheme, "dialog-error")&&
            gtk_icon_theme_has_icon(icontheme, "dialog-question")&&
            gtk_icon_theme_has_icon(icontheme, "video-display")&&
            gtk_icon_theme_has_icon(icontheme, "audio-card")&&
            gtk_icon_theme_has_icon(icontheme, "input-gaming")&&
            gtk_icon_theme_has_icon(icontheme, "window-close")&&
            gtk_icon_theme_has_icon(icontheme, "document-save")&&
            gtk_icon_theme_has_icon(icontheme, "document-save-as")&&
            gtk_icon_theme_has_icon(icontheme, "document-revert")&&
            gtk_icon_theme_has_icon(icontheme, "document-open")&&
            gtk_icon_theme_has_icon(icontheme, "gtk-about"))
        usefallbacks = TRUE;
    else
        usefallbacks = FALSE;

    return usefallbacks;
}
예제 #28
0
static GdkPixbuf* plank_drawing_drawing_service_load_pixbuf (const gchar* icon, gint size) {
	GdkPixbuf* result = NULL;
	GdkPixbuf* pbuf = NULL;
	GtkIconTheme* icon_theme = NULL;
	GtkIconTheme* _tmp0_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (icon != NULL, NULL);
	pbuf = NULL;
	_tmp0_ = gtk_icon_theme_get_default ();
	icon_theme = _tmp0_;
	{
		GtkIconTheme* _tmp1_ = NULL;
		const gchar* _tmp2_ = NULL;
		gboolean _tmp3_ = FALSE;
		_tmp1_ = icon_theme;
		_tmp2_ = icon;
		_tmp3_ = gtk_icon_theme_has_icon (_tmp1_, _tmp2_);
		if (_tmp3_) {
			GdkPixbuf* _tmp4_ = NULL;
			GtkIconTheme* _tmp5_ = NULL;
			const gchar* _tmp6_ = NULL;
			gint _tmp7_ = 0;
			GdkPixbuf* _tmp8_ = NULL;
			GdkPixbuf* _tmp9_ = NULL;
			_tmp5_ = icon_theme;
			_tmp6_ = icon;
			_tmp7_ = size;
			_tmp8_ = gtk_icon_theme_load_icon (_tmp5_, _tmp6_, _tmp7_, 0, &_inner_error_);
			_tmp4_ = _tmp8_;
			if (_inner_error_ != NULL) {
				goto __catch4_g_error;
			}
			_tmp9_ = _tmp4_;
			_tmp4_ = NULL;
			_g_object_unref0 (pbuf);
			pbuf = _tmp9_;
			_g_object_unref0 (_tmp4_);
		} else {
			const gchar* _tmp10_ = NULL;
			gboolean _tmp11_ = FALSE;
			_tmp10_ = icon;
			_tmp11_ = string_contains (_tmp10_, ".");
			if (_tmp11_) {
				gchar** parts = NULL;
				const gchar* _tmp12_ = NULL;
				gchar** _tmp13_ = NULL;
				gchar** _tmp14_ = NULL;
				gint parts_length1 = 0;
				gint _parts_size_ = 0;
				GtkIconTheme* _tmp15_ = NULL;
				gchar** _tmp16_ = NULL;
				gint _tmp16__length1 = 0;
				const gchar* _tmp17_ = NULL;
				gboolean _tmp18_ = FALSE;
				_tmp12_ = icon;
				_tmp14_ = _tmp13_ = g_strsplit (_tmp12_, ".", 0);
				parts = _tmp14_;
				parts_length1 = _vala_array_length (_tmp13_);
				_parts_size_ = parts_length1;
				_tmp15_ = icon_theme;
				_tmp16_ = parts;
				_tmp16__length1 = parts_length1;
				_tmp17_ = _tmp16_[0];
				_tmp18_ = gtk_icon_theme_has_icon (_tmp15_, _tmp17_);
				if (_tmp18_) {
					GdkPixbuf* _tmp19_ = NULL;
					GtkIconTheme* _tmp20_ = NULL;
					gchar** _tmp21_ = NULL;
					gint _tmp21__length1 = 0;
					const gchar* _tmp22_ = NULL;
					gint _tmp23_ = 0;
					GdkPixbuf* _tmp24_ = NULL;
					GdkPixbuf* _tmp25_ = NULL;
					_tmp20_ = icon_theme;
					_tmp21_ = parts;
					_tmp21__length1 = parts_length1;
					_tmp22_ = _tmp21_[0];
					_tmp23_ = size;
					_tmp24_ = gtk_icon_theme_load_icon (_tmp20_, _tmp22_, _tmp23_, 0, &_inner_error_);
					_tmp19_ = _tmp24_;
					if (_inner_error_ != NULL) {
						parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
						goto __catch4_g_error;
					}
					_tmp25_ = _tmp19_;
					_tmp19_ = NULL;
					_g_object_unref0 (pbuf);
					pbuf = _tmp25_;
					_g_object_unref0 (_tmp19_);
				}
				parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
			}
		}
	}
	goto __finally4;
	__catch4_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
	}
	__finally4:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (pbuf);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	result = pbuf;
	return result;
}
예제 #29
0
void slingshot_backend_gmenu_entries_enumerate_apps (GeeArrayList* source, GeeHashMap* icons, gint icon_size, GeeArrayList** list) {
    GeeArrayList* _vala_list = NULL;
    GtkIconTheme* _tmp0_ = NULL;
    GtkIconTheme* _tmp1_;
    GtkIconTheme* icon_theme;
    GeeArrayList* _tmp2_;
    GError * _inner_error_ = NULL;
    g_return_if_fail (source != NULL);
    g_return_if_fail (icons != NULL);
    _tmp0_ = gtk_icon_theme_get_default ();
    _tmp1_ = _g_object_ref0 (_tmp0_);
    icon_theme = _tmp1_;
    _tmp2_ = gee_array_list_new (GEE_TYPE_HASH_MAP, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
    _g_object_unref0 (_vala_list);
    _vala_list = _tmp2_;
    {
        GeeArrayList* _tmp3_;
        GeeArrayList* _tmp4_;
        GeeArrayList* _app_list;
        GeeArrayList* _tmp5_;
        gint _tmp6_;
        gint _tmp7_;
        gint _app_size;
        gint _app_index;
        _tmp3_ = source;
        _tmp4_ = _g_object_ref0 (_tmp3_);
        _app_list = _tmp4_;
        _tmp5_ = _app_list;
        _tmp6_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp5_);
        _tmp7_ = _tmp6_;
        _app_size = _tmp7_;
        _app_index = -1;
        while (TRUE) {
            gint _tmp8_;
            gint _tmp9_;
            gint _tmp10_;
            GeeArrayList* _tmp11_;
            gint _tmp12_;
            gpointer _tmp13_ = NULL;
            GMenuTreeEntry* app;
            gboolean _tmp14_ = FALSE;
            gboolean _tmp15_ = FALSE;
            GMenuTreeEntry* _tmp16_;
            gboolean _tmp17_ = FALSE;
            gboolean _tmp20_;
            gboolean _tmp23_;
            _tmp8_ = _app_index;
            _app_index = _tmp8_ + 1;
            _tmp9_ = _app_index;
            _tmp10_ = _app_size;
            if (!(_tmp9_ < _tmp10_)) {
                break;
            }
            _tmp11_ = _app_list;
            _tmp12_ = _app_index;
            _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _tmp12_);
            app = (GMenuTreeEntry*) _tmp13_;
            _tmp16_ = app;
            _tmp17_ = gmenu_tree_entry_get_is_nodisplay (_tmp16_);
            if (_tmp17_ == FALSE) {
                GMenuTreeEntry* _tmp18_;
                gboolean _tmp19_ = FALSE;
                _tmp18_ = app;
                _tmp19_ = gmenu_tree_entry_get_is_excluded (_tmp18_);
                _tmp15_ = _tmp19_ == FALSE;
            } else {
                _tmp15_ = FALSE;
            }
            _tmp20_ = _tmp15_;
            if (_tmp20_) {
                GMenuTreeEntry* _tmp21_;
                const gchar* _tmp22_ = NULL;
                _tmp21_ = app;
                _tmp22_ = gmenu_tree_entry_get_icon (_tmp21_);
                _tmp14_ = _tmp22_ != NULL;
            } else {
                _tmp14_ = FALSE;
            }
            _tmp23_ = _tmp14_;
            if (_tmp23_) {
                GeeHashMap* _tmp24_;
                GeeHashMap* app_to_add;
                GeeHashMap* _tmp25_;
                GMenuTreeEntry* _tmp26_;
                const gchar* _tmp27_ = NULL;
                GeeHashMap* _tmp28_;
                GMenuTreeEntry* _tmp29_;
                const gchar* _tmp30_ = NULL;
                GeeHashMap* _tmp31_;
                GMenuTreeEntry* _tmp32_;
                const gchar* _tmp33_ = NULL;
                GeeHashMap* _tmp34_;
                GMenuTreeEntry* _tmp35_;
                const gchar* _tmp36_ = NULL;
                GeeHashMap* _tmp37_;
                GeeHashMap* _tmp38_;
                gpointer _tmp39_ = NULL;
                gchar* _tmp40_;
                gboolean _tmp41_ = FALSE;
                gboolean _tmp42_;
                GeeArrayList* _tmp102_;
                GeeHashMap* _tmp103_;
                _tmp24_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
                app_to_add = _tmp24_;
                _tmp25_ = app_to_add;
                _tmp26_ = app;
                _tmp27_ = gmenu_tree_entry_get_comment (_tmp26_);
                gee_abstract_map_set ((GeeAbstractMap*) _tmp25_, "description", _tmp27_);
                _tmp28_ = app_to_add;
                _tmp29_ = app;
                _tmp30_ = gmenu_tree_entry_get_name (_tmp29_);
                gee_abstract_map_set ((GeeAbstractMap*) _tmp28_, "name", _tmp30_);
                _tmp31_ = app_to_add;
                _tmp32_ = app;
                _tmp33_ = gmenu_tree_entry_get_exec (_tmp32_);
                gee_abstract_map_set ((GeeAbstractMap*) _tmp31_, "command", _tmp33_);
                _tmp34_ = app_to_add;
                _tmp35_ = app;
                _tmp36_ = gmenu_tree_entry_get_desktop_file_path (_tmp35_);
                gee_abstract_map_set ((GeeAbstractMap*) _tmp34_, "desktop_file", _tmp36_);
                _tmp37_ = icons;
                _tmp38_ = app_to_add;
                _tmp39_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp38_, "command");
                _tmp40_ = (gchar*) _tmp39_;
                _tmp41_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp37_, _tmp40_);
                _tmp42_ = !_tmp41_;
                _g_free0 (_tmp40_);
                if (_tmp42_) {
                    GMenuTreeEntry* _tmp43_;
                    const gchar* _tmp44_ = NULL;
                    gchar* _tmp45_;
                    gchar* app_icon;
                    GtkIconTheme* _tmp46_;
                    const gchar* _tmp47_;
                    gboolean _tmp48_ = FALSE;
                    _tmp43_ = app;
                    _tmp44_ = gmenu_tree_entry_get_icon (_tmp43_);
                    _tmp45_ = g_strdup (_tmp44_);
                    app_icon = _tmp45_;
                    _tmp46_ = icon_theme;
                    _tmp47_ = app_icon;
                    _tmp48_ = gtk_icon_theme_has_icon (_tmp46_, _tmp47_);
                    if (_tmp48_) {
                        GtkIconTheme* _tmp49_;
                        const gchar* _tmp50_;
                        gint _tmp51_;
                        GtkIconInfo* _tmp52_ = NULL;
                        GtkIconInfo* _tmp53_;
                        GdkPixbuf* _tmp54_ = NULL;
                        GdkPixbuf* _tmp55_;
                        GdkPixbuf* _tmp56_;
                        GeeHashMap* _tmp57_;
                        GeeHashMap* _tmp58_;
                        gpointer _tmp59_ = NULL;
                        gchar* _tmp60_;
                        GdkPixbuf* _tmp61_;
                        _tmp49_ = icon_theme;
                        _tmp50_ = app_icon;
                        _tmp51_ = icon_size;
                        _tmp52_ = gtk_icon_theme_lookup_icon (_tmp49_, _tmp50_, _tmp51_, 0);
                        _tmp53_ = _tmp52_;
                        _tmp54_ = gtk_icon_info_load_icon (_tmp53_, &_inner_error_);
                        _tmp55_ = _tmp54_;
                        _gtk_icon_info_free0 (_tmp53_);
                        _tmp56_ = _tmp55_;
                        if (_inner_error_ != NULL) {
                            _g_free0 (app_icon);
                            _g_object_unref0 (app_to_add);
                            _gmenu_tree_item_unref0 (app);
                            _g_object_unref0 (_app_list);
                            _g_object_unref0 (icon_theme);
                            g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
                            g_clear_error (&_inner_error_);
                            return;
                        }
                        _tmp57_ = icons;
                        _tmp58_ = app_to_add;
                        _tmp59_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp58_, "command");
                        _tmp60_ = (gchar*) _tmp59_;
                        _tmp61_ = _tmp56_;
                        gee_abstract_map_set ((GeeAbstractMap*) _tmp57_, _tmp60_, _tmp61_);
                        _g_object_unref0 (_tmp61_);
                        _g_free0 (_tmp60_);
                    } else {
                        const gchar* _tmp62_;
                        GFile* _tmp63_ = NULL;
                        GFile* _tmp64_;
                        gboolean _tmp65_ = FALSE;
                        gboolean _tmp66_;
                        _tmp62_ = app_icon;
                        _tmp63_ = g_file_new_for_path (_tmp62_);
                        _tmp64_ = _tmp63_;
                        _tmp65_ = g_file_query_exists (_tmp64_, NULL);
                        _tmp66_ = _tmp65_;
                        _g_object_unref0 (_tmp64_);
                        if (_tmp66_) {
                            {
                                const gchar* _tmp67_;
                                const gchar* _tmp68_ = NULL;
                                gint _tmp69_;
                                GdkPixbuf* _tmp70_;
                                GdkPixbuf* _tmp71_;
                                GeeHashMap* _tmp72_;
                                GeeHashMap* _tmp73_;
                                gpointer _tmp74_ = NULL;
                                gchar* _tmp75_;
                                GdkPixbuf* _tmp76_;
                                _tmp67_ = app_icon;
                                _tmp68_ = string_to_string (_tmp67_);
                                _tmp69_ = icon_size;
                                _tmp70_ = gdk_pixbuf_new_from_file_at_scale (_tmp68_, -1, _tmp69_, TRUE, &_inner_error_);
                                _tmp71_ = _tmp70_;
                                if (_inner_error_ != NULL) {
                                    goto __catch1_g_error;
                                }
                                _tmp72_ = icons;
                                _tmp73_ = app_to_add;
                                _tmp74_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp73_, "command");
                                _tmp75_ = (gchar*) _tmp74_;
                                _tmp76_ = _tmp71_;
                                gee_abstract_map_set ((GeeAbstractMap*) _tmp72_, _tmp75_, _tmp76_);
                                _g_object_unref0 (_tmp76_);
                                _g_free0 (_tmp75_);
                            }
                            goto __finally1;
__catch1_g_error:
                            {
                                GtkIconTheme* _tmp77_;
                                gint _tmp78_;
                                GtkIconInfo* _tmp79_ = NULL;
                                GtkIconInfo* _tmp80_;
                                GdkPixbuf* _tmp81_ = NULL;
                                GdkPixbuf* _tmp82_;
                                GdkPixbuf* _tmp83_;
                                GeeHashMap* _tmp84_;
                                GeeHashMap* _tmp85_;
                                gpointer _tmp86_ = NULL;
                                gchar* _tmp87_;
                                GdkPixbuf* _tmp88_;
                                FILE* _tmp89_;
                                g_clear_error (&_inner_error_);
                                _inner_error_ = NULL;
                                _tmp77_ = icon_theme;
                                _tmp78_ = icon_size;
                                _tmp79_ = gtk_icon_theme_lookup_icon (_tmp77_, "application-default-icon", _tmp78_, 0);
                                _tmp80_ = _tmp79_;
                                _tmp81_ = gtk_icon_info_load_icon (_tmp80_, &_inner_error_);
                                _tmp82_ = _tmp81_;
                                _gtk_icon_info_free0 (_tmp80_);
                                _tmp83_ = _tmp82_;
                                if (_inner_error_ != NULL) {
                                    goto __finally1;
                                }
                                _tmp84_ = icons;
                                _tmp85_ = app_to_add;
                                _tmp86_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp85_, "command");
                                _tmp87_ = (gchar*) _tmp86_;
                                _tmp88_ = _tmp83_;
                                gee_abstract_map_set ((GeeAbstractMap*) _tmp84_, _tmp87_, _tmp88_);
                                _g_object_unref0 (_tmp88_);
                                _g_free0 (_tmp87_);
                                _tmp89_ = stdout;
                                fprintf (_tmp89_, "Failed to load icon from file.\n");
                            }
__finally1:
                            if (_inner_error_ != NULL) {
                                _g_free0 (app_icon);
                                _g_object_unref0 (app_to_add);
                                _gmenu_tree_item_unref0 (app);
                                _g_object_unref0 (_app_list);
                                _g_object_unref0 (icon_theme);
                                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
                                g_clear_error (&_inner_error_);
                                return;
                            }
                        } else {
                            GtkIconTheme* _tmp90_;
                            gint _tmp91_;
                            GtkIconInfo* _tmp92_ = NULL;
                            GtkIconInfo* _tmp93_;
                            GdkPixbuf* _tmp94_ = NULL;
                            GdkPixbuf* _tmp95_;
                            GdkPixbuf* _tmp96_;
                            GeeHashMap* _tmp97_;
                            GeeHashMap* _tmp98_;
                            gpointer _tmp99_ = NULL;
                            gchar* _tmp100_;
                            GdkPixbuf* _tmp101_;
                            _tmp90_ = icon_theme;
                            _tmp91_ = icon_size;
                            _tmp92_ = gtk_icon_theme_lookup_icon (_tmp90_, "application-default-icon", _tmp91_, 0);
                            _tmp93_ = _tmp92_;
                            _tmp94_ = gtk_icon_info_load_icon (_tmp93_, &_inner_error_);
                            _tmp95_ = _tmp94_;
                            _gtk_icon_info_free0 (_tmp93_);
                            _tmp96_ = _tmp95_;
                            if (_inner_error_ != NULL) {
                                _g_free0 (app_icon);
                                _g_object_unref0 (app_to_add);
                                _gmenu_tree_item_unref0 (app);
                                _g_object_unref0 (_app_list);
                                _g_object_unref0 (icon_theme);
                                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
                                g_clear_error (&_inner_error_);
                                return;
                            }
                            _tmp97_ = icons;
                            _tmp98_ = app_to_add;
                            _tmp99_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp98_, "command");
                            _tmp100_ = (gchar*) _tmp99_;
                            _tmp101_ = _tmp96_;
                            gee_abstract_map_set ((GeeAbstractMap*) _tmp97_, _tmp100_, _tmp101_);
                            _g_object_unref0 (_tmp101_);
                            _g_free0 (_tmp100_);
                        }
                    }
                    _g_free0 (app_icon);
                }
                _tmp102_ = _vala_list;
                _tmp103_ = app_to_add;
                gee_abstract_collection_add ((GeeAbstractCollection*) _tmp102_, _tmp103_);
                _g_object_unref0 (app_to_add);
            }
            _gmenu_tree_item_unref0 (app);
        }
        _g_object_unref0 (_app_list);
    }
    _g_object_unref0 (icon_theme);
    if (list) {
        *list = _vala_list;
    } else {
        _g_object_unref0 (_vala_list);
    }
}
예제 #30
0
gboolean
load_image_by_id (GtkImage * image, GtkIconSize size, const gchar * image_id)
{
	GdkPixbuf *pixbuf;
	gint width;
	gint height;

	GtkIconTheme *icon_theme;

	gchar *id;

	gboolean icon_exists;

	if (!image_id)
		return FALSE;

	id = g_strdup (image_id);

	gtk_icon_size_lookup (size, &width, &height);

	if (g_path_is_absolute (id))
	{
		pixbuf = gdk_pixbuf_new_from_file_at_size (id, width, height, NULL);

		icon_exists = (pixbuf != NULL);

		if (icon_exists)
		{
			gtk_image_set_from_pixbuf (image, pixbuf);

			g_object_unref (pixbuf);
		}
		else
			gtk_image_set_from_icon_name (image, "image-missing", size);
	}
	else
	{
		if (		/* file extensions are not copesetic with loading by "name" */
			g_str_has_suffix (id, ".png") ||
			g_str_has_suffix (id, ".svg") ||
			g_str_has_suffix (id, ".xpm")
		   )

			id[strlen (id) - 4] = '\0';

		if (gtk_widget_has_screen (GTK_WIDGET (image)))
			icon_theme =
				gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET
					(image)));
		else
			icon_theme = gtk_icon_theme_get_default ();

		icon_exists = gtk_icon_theme_has_icon (icon_theme, id);

		if (icon_exists)
			gtk_image_set_from_icon_name (image, id, size);
		else
			gtk_image_set_from_icon_name (image, "image-missing", size);

	}

	g_free (id);

	return icon_exists;
}