Ejemplo n.º 1
0
int
main(int argc, char *argv[])
{
	DHCPCD_CONNECTION *con;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, NULL);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);

	gtk_init(&argc, &argv);
	g_set_application_name("Network Configurator");
	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
	    ICONDIR);
	status_icon = gtk_status_icon_new_from_icon_name("network-offline");

	gtk_status_icon_set_tooltip_text(status_icon,
	    _("Connecting to dhcpcd ..."));
	gtk_status_icon_set_visible(status_icon, true);
	online = false;
#ifdef NOTIFY
	notify_init(PACKAGE);
#endif

	g_message(_("Connecting ..."));
	con = dhcpcd_new();
	if (con ==  NULL) {
		g_critical("libdhcpcd: %s", strerror(errno));
		exit(EXIT_FAILURE);
	}
	dhcpcd_set_progname(con, "dhcpcd-gtk");
	dhcpcd_set_status_callback(con, dhcpcd_status_cb, NULL);
	dhcpcd_set_if_callback(con, dhcpcd_if_cb, NULL);
	dhcpcd_wpa_set_scan_callback(con, dhcpcd_wpa_scan_cb, NULL);
	//dhcpcd_wpa_set_status_callback(con, dhcpcd_wpa_status_cb, NULL);
	if (dhcpcd_try_open(con))
		g_timeout_add(DHCPCD_RETRYOPEN, dhcpcd_try_open, con);

	menu_init(status_icon, con);

	gtk_main();
	dhcpcd_close(con);
	dhcpcd_free(con);
	return 0;
}
GtkWidget *
xfce_mailwatch_custom_button_new(const gchar *text, const gchar *icon)
{
    GtkWidget *btn, *hbox, *img, *lbl;
    GdkPixbuf *pix;
    gint iw, ih;
    
    g_return_val_if_fail((text && *text) || icon, NULL);
    
    btn = gtk_button_new();
    
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
    gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
    gtk_widget_show(hbox);
    gtk_container_add(GTK_CONTAINER(btn), hbox);
    
    if(icon) {
        img = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
        if(!img || gtk_image_get_storage_type(GTK_IMAGE(img)) == GTK_IMAGE_EMPTY) {
            gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &iw, &ih);
            pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(), icon,
                                            iw, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
            if(pix) {
                if(img)
                    gtk_image_set_from_pixbuf(GTK_IMAGE(img), pix);
                else
                    img = gtk_image_new_from_pixbuf(pix);
                g_object_unref(G_OBJECT(pix));
            }
        }
        if(img) {
            gtk_widget_show(img);
            gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
        }
    }
    
    if(text) {
        lbl = gtk_label_new_with_mnemonic(text);
        gtk_widget_show(lbl);
        gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);
        gtk_label_set_mnemonic_widget(GTK_LABEL(lbl), btn);
    }
    
    return btn;
}
static void
set_calibration_status (CalibArea *area)
{
  GtkIconTheme *icon_theme;
  GtkIconInfo  *icon_info;
  GdkRGBA       white;

  icon_theme = gtk_icon_theme_get_default ();
  icon_info = gtk_icon_theme_lookup_icon (icon_theme,
                                          ICON_SUCCESS,
                                          ICON_SIZE,
                                          GTK_ICON_LOOKUP_USE_BUILTIN);
  if (icon_info == NULL)
    {
      g_warning ("Failed to find icon \"%s\"", ICON_SUCCESS);
      goto out;
    }

  gdk_rgba_parse (&white, "White");
  area->icon_success = gtk_icon_info_load_symbolic (icon_info,
                                                    &white,
                                                    NULL,
                                                    NULL,
                                                    NULL,
                                                    NULL,
                                                    NULL);
  g_object_unref (icon_info);

  if (!area->icon_success)
    g_warning ("Failed to load icon \"%s\"", ICON_SUCCESS);

 out:
  area->success = finish (&area->calibrator, &area->axis, &area->swap);
  if (area->success && area->icon_success)
    {
      set_success (area);
      g_timeout_add (END_TIME,
                     (GSourceFunc) draw_success_end_wait_callback,
                     area);
    }
  else
    {
      on_delete_event (NULL, NULL, area);
    }
}
Ejemplo n.º 4
0
static void
ensure_surface_for_icon_name_or_gicon (GtkIconHelper *self,
				       GtkStyleContext *context)
{
  GtkIconTheme *icon_theme;
  gint width, height, scale;
  GtkIconInfo *info;
  GtkIconLookupFlags flags;

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

  icon_theme = gtk_icon_theme_get_default ();
  flags = get_icon_lookup_flags (self);

  ensure_icon_size (self, context, &width, &height);
  scale = get_scale_factor (self, context);

  if (self->priv->storage_type == GTK_IMAGE_ICON_NAME &&
      self->priv->icon_name != NULL)
    {
      info = gtk_icon_theme_lookup_icon_for_scale (icon_theme,
						   self->priv->icon_name,
						   MIN (width, height),
						   scale, flags);
    }
  else if (self->priv->storage_type == GTK_IMAGE_GICON &&
           self->priv->gicon != NULL)
    {
      info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
						       self->priv->gicon,
						       MIN (width, height),
						       scale, flags);
    }
  else
    {
      g_assert_not_reached ();
      return;
    }

  ensure_stated_surface_from_info (self, context, info, scale);

  if (info)
    g_object_unref (info);
}
Ejemplo n.º 5
0
static void
rb_missing_files_source_init (RBMissingFilesSource *source)
{
	gint size;
	GdkPixbuf *pixbuf;

	source->priv = G_TYPE_INSTANCE_GET_PRIVATE (source, RB_TYPE_MISSING_FILES_SOURCE, RBMissingFilesSourcePrivate);

	gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL);
	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					   "dialog-warning",
					   size,
					   0, NULL);
	rb_source_set_pixbuf (RB_SOURCE (source), pixbuf);
	if (pixbuf != NULL) {
		g_object_unref (pixbuf);
	}
}
Ejemplo n.º 6
0
static void
rb_import_errors_source_init (RBImportErrorsSource *source)
{
	gint size;
	GdkPixbuf *pixbuf;

	source->priv = G_TYPE_INSTANCE_GET_PRIVATE (source, RB_TYPE_IMPORT_ERRORS_SOURCE, RBImportErrorsSourcePrivate);

	gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL);
	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					   "dialog-error",
					   size,
					   0, NULL);
	rb_source_set_pixbuf (RB_SOURCE (source), pixbuf);
	if (pixbuf != NULL) {
		g_object_unref (pixbuf);
	}
}
Ejemplo n.º 7
0
/* consumes reference on icon */
static GtkWidget *_gtk_image_new_for_icon(FmIcon *icon, gint size)
{
    GtkWidget * img = gtk_image_new();
    ImgData * data = g_new0(ImgData, 1);

    data->icon = icon;
    data->size = size;
    if (img_data_id == 0)
        img_data_id = g_quark_from_static_string("ImgData");
    g_object_set_qdata_full(G_OBJECT(img), img_data_id, data, (GDestroyNotify) img_data_free);
    _gtk_image_set_from_file_scaled(img, data);
    if (G_IS_THEMED_ICON(data->icon))
    {
        /* This image is loaded from icon theme.  Update the image if the icon theme is changed. */
        data->theme_changed_handler = g_signal_connect(gtk_icon_theme_get_default(), "changed", G_CALLBACK(on_theme_changed), img);
    }
    return img;
}
Ejemplo n.º 8
0
static void
window_set_icons (GtkWidget *window)
{
  GtkIconTheme *theme   = gtk_icon_theme_get_default ();
  gint          sizes[] = { 16, 24, 32, 64 };
  GList        *list    = NULL;
  gint          i;

  for (i = 0; i < G_N_ELEMENTS (sizes); i++)
    list = g_list_prepend (list,
                           gtk_icon_theme_load_icon (theme,
                                                     GIMP_STOCK_USER_MANUAL,
                                                     sizes[i], 0, NULL));

  gtk_window_set_icon_list (GTK_WINDOW (window), list);

  g_list_free_full (list, (GDestroyNotify) g_object_unref);
}
Ejemplo n.º 9
0
static gboolean
has_icon_path (const char *path)
{
  char **paths;
  int i;
  gboolean has = FALSE;

  gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &paths, NULL);
  for (i = 0; paths[i]; i++)
    if (! strcmp(paths[i], path))
      {
	has = TRUE;
	break;
      }
  g_strfreev(paths);

  return has;
}
Ejemplo n.º 10
0
static void
setup_icons (GdmUserChooserWidget *widget)
{
        if (gtk_widget_has_screen (GTK_WIDGET (widget))) {
                widget->priv->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (widget)));
        } else {
                widget->priv->icon_theme = gtk_icon_theme_get_default ();
        }

        if (widget->priv->icon_theme != NULL) {
                g_signal_connect (widget->priv->icon_theme,
                                  "changed",
                                  G_CALLBACK (on_icon_theme_changed),
                                  widget);
        }

        load_icons (widget);
}
Ejemplo n.º 11
0
/**
 * Looks up icons based on the currently selected theme.
 *
 * @param iconname icon name to look up
 * @param size size of the icon
 * @return the corresponding theme icon, NULL on failure,
 * use g_object_unref() to release the reference to the icon
 */
static GdkPixbuf *
pixbuf_new_from_stock(const gchar *iconname, gint size)
{
	static GtkIconTheme *icon_theme = NULL;
	GError *err = NULL;
	GdkPixbuf *pixbuf = NULL;

	if (icon_theme == NULL)
		icon_theme = gtk_icon_theme_get_default();

	pixbuf = gtk_icon_theme_load_icon(icon_theme, iconname, size, 0, &err);
	if (!pixbuf) {
		WARN("Unable to load icon '%s': %s", iconname, err->message);
		g_error_free(err);
	}

	return pixbuf;
}
Ejemplo n.º 12
0
static void
impl_constructed (GObject *object)
{
	RBPodcastMainSource *source;
	RBPodcastManager *podcast_mgr;
	GdkPixbuf *pixbuf;
	gint size;
	
	RB_CHAIN_GOBJECT_METHOD (rb_podcast_main_source_parent_class, constructed, object);
	source = RB_PODCAST_MAIN_SOURCE (object);

	g_object_get (source, "podcast-manager", &podcast_mgr, NULL);

	g_signal_connect_object (podcast_mgr,
	 		        "start_download",
			  	G_CALLBACK (start_download_cb),
			  	source, 0);

	g_signal_connect_object (podcast_mgr,
			  	"finish_download",
			  	G_CALLBACK (finish_download_cb),
			  	source, 0);

	g_signal_connect_object (podcast_mgr,
			  	"feed_updates_available",
 			  	G_CALLBACK (feed_updates_available_cb),
			  	source, 0);

	g_signal_connect_object (podcast_mgr,
			  	 "process_error",
			 	 G_CALLBACK (feed_error_cb),
			  	 source, 0);

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

	if (pixbuf != NULL) {
		rb_source_set_pixbuf (RB_SOURCE (source), pixbuf);
		g_object_unref (pixbuf);
	}
}
void
matekbd_indicator_config_init (MatekbdIndicatorConfig * ind_config,
			    MateConfClient * conf_client, XklEngine * engine)
{
	GError *gerror = NULL;
	gchar *sp;

	memset (ind_config, 0, sizeof (*ind_config));
	ind_config->conf_client = conf_client;
	ind_config->engine = engine;
	g_object_ref (ind_config->conf_client);

	mateconf_client_add_dir (ind_config->conf_client,
			      MATEKBD_INDICATOR_CONFIG_DIR,
			      MATECONF_CLIENT_PRELOAD_NONE, &gerror);
	if (gerror != NULL) {
		g_warning ("err1:%s\n", gerror->message);
		g_error_free (gerror);
		gerror = NULL;
	}

	ind_config->icon_theme = gtk_icon_theme_get_default ();

	gtk_icon_theme_append_search_path (ind_config->icon_theme, sp =
					   g_build_filename (g_get_home_dir
							     (),
							     ".icons/flags",
							     NULL));
	g_free (sp);

	gtk_icon_theme_append_search_path (ind_config->icon_theme,
					   sp =
					   g_build_filename (DATADIR,
							     "pixmaps/flags",
							     NULL));
	g_free (sp);

	gtk_icon_theme_append_search_path (ind_config->icon_theme,
					   sp =
					   g_build_filename (DATADIR,
							     "icons/flags",
							     NULL));
	g_free (sp);
}
Ejemplo n.º 14
0
/**
 * @brief Initialize the GTK user interface.
 *
 * @param display_name name of the X display to use or NULL (using the DISPLAY environment variable)
 */
void gtkInit(char *display_name)
{
    int argc = 0;
    char *arg[3], **argv = arg;
    char *env;
    GtkIconTheme *theme;
    GdkPixmap *gdkIcon;
    GdkBitmap *gdkIconMask;

    mp_msg(MSGT_GPLAYER, MSGL_V, "GTK init.\n");

    arg[argc++] = gmplayer;

    if (display_name) {             // MPlayer option '-display' was given
        arg[argc++] = "--display";  // Pass corresponding command line arguments to GTK,
        arg[argc++] = display_name; // to open the requested display for the GUI, too.
    }

    gtk_disable_setlocale();

    env = getenv("G_FILENAME_ENCODING");

    if ((!env && getenv("G_BROKEN_FILENAMES")) || (gstrncmp(env, "@locale", 7) == 0))
        mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_GUI_MSG_LocaleEncoding);

    gtk_init(&argc, &argv);
    wsSetErrorHandler();      // GDK has just set its own handler

    theme = gtk_icon_theme_get_default();

    if (gtkLoadIcon(theme, 16, &gdkIcon, &gdkIconMask)) {
        guiIcon.small      = GDK_PIXMAP_XID(gdkIcon);
        guiIcon.small_mask = GDK_PIXMAP_XID(gdkIconMask);
    }

    if (gtkLoadIcon(theme, 32, &gdkIcon, &gdkIconMask)) {
        guiIcon.normal      = GDK_PIXMAP_XID(gdkIcon);
        guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
    }

    gtkLoadIcon(theme, 48, &gdkIcon, &gdkIconMask);

    gtkInitialized = True;
}
Ejemplo n.º 15
0
void
initialize_data (void)
{
	if (initialized)
		return;
	initialized = TRUE;

	ProgramsCache = g_hash_table_new_full (g_str_hash,
					       g_str_equal,
					       g_free,
					       NULL);

	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
					   PKG_DATA_DIR G_DIR_SEPARATOR_S "icons");

	migrate_options_directory ();
	register_archives ();
	compute_supported_archive_types ();
}
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);
    }
}
Ejemplo n.º 17
0
static void fm_dir_tree_model_finalize (GObject *object)
{
    FmDirTreeModel *dir_tree_model;

    g_return_if_fail (object != NULL);
    g_return_if_fail (FM_IS_DIR_TREE_MODEL (object));

    dir_tree_model = FM_DIR_TREE_MODEL (object);

    fm_foreach (dir_tree_model->root_list, (GFunc) fm_dir_tree_item_free_l, NULL);
    g_list_free (dir_tree_model->root_list);

    // Check Subdirectories job...
    g_object_unref (dir_tree_model->subdir_cancellable); 
    
    g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_default (), on_theme_changed, dir_tree_model);

    G_OBJECT_CLASS (fm_dir_tree_model_parent_class)->finalize (object);
}
Ejemplo n.º 18
0
static void
book_view_gtk_update_contact (BookViewGtk *self,
			      Ekiga::ContactPtr contact,
			      GtkTreeIter *iter)
{
  GtkListStore *store = NULL;
  GdkPixbuf *pixbuf = NULL;

  store = GTK_LIST_STORE (gtk_tree_view_get_model (self->priv->tree_view));
  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
                                     "avatar-default",
                                     GTK_ICON_SIZE_MENU, (GtkIconLookupFlags) 0, NULL);
  gtk_list_store_set (store, iter,
                      COLUMN_PIXBUF, pixbuf,
		      COLUMN_NAME, contact->get_name ().c_str (),
		      -1);
  if (pixbuf)
    g_object_unref (pixbuf);
}
Ejemplo n.º 19
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;
}
Ejemplo n.º 20
0
    //_______________________________________________________
    void DemoWidget::realize( void )
    {
        assert( !_mainWidget );
        assert( _widget );

        // create main widget (vbox)
        _mainWidget = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
        gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 );
        gtk_widget_show( _mainWidget );

        // horizontal box
        GtkWidget* hbox( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) );
        gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 );
        gtk_widget_show( hbox );

        // label
        std::string comments( _comments.empty() ? _name:_comments );
        GtkWidget* label( gtk_label_new( comments.c_str() ) );

        PangoAttrList* attributes( pango_attr_list_new() );
        pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) );
        gtk_label_set_attributes( GTK_LABEL( label ), attributes );
        pango_attr_list_unref( attributes );

        gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 );

        gtk_widget_show( label );

        // icon
        if( !_iconName.empty() )
        {
            GtkIconTheme* theme( gtk_icon_theme_get_default() );
            GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) );
            GtkWidget* image( gtk_image_new_from_pixbuf( icon ) );
            gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 );
            gtk_widget_show( image );

        }

        // main content
        gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 );
        gtk_widget_show( _widget );
    }
Ejemplo n.º 21
0
static void ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e) {
    GdkPixbuf *pixbuf;
    GError *error = NULL;

    SJCDPlugin* plugin = SJCD_PLUGIN(ipref);
    plugin->prefs = init_sjcd_preferences();
    if (plugin->prefs == NULL)
        return;

    pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), PREFERENCE_ICON, 48, 0, &error);

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

    anjuta_preferences_dialog_add_page(ANJUTA_PREFERENCES_DIALOG (anjuta_preferences_get_dialog (prefs)), "gtkpod-track-display-settings", TAB_NAME, pixbuf, plugin->prefs);
    g_object_unref(pixbuf);
}
Ejemplo n.º 22
0
static void on_model_destroy(gpointer unused, GObject* _model)
{
    GtkTreeIter it;
    if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &it))
    {
        do
        {
            PlaceItem* item;
            gtk_tree_model_get(GTK_TREE_MODEL(model), &it, COL_INFO, &item, -1);
            if(G_LIKELY(item))
                place_item_free(item);
        }while(gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &it));
    }
    model = NULL;

    g_signal_handler_disconnect(gtk_icon_theme_get_default(), theme_change_handler);
    theme_change_handler = 0;

    g_signal_handler_disconnect(fm_config, use_trash_change_handler);
    use_trash_change_handler = 0;

    g_signal_handler_disconnect(fm_config, pane_icon_size_change_handler);
    pane_icon_size_change_handler = 0;

    g_signal_handlers_disconnect_by_func(vol_mon, on_vol_added, NULL);
    g_signal_handlers_disconnect_by_func(vol_mon, on_vol_removed, NULL);
    g_signal_handlers_disconnect_by_func(vol_mon, on_vol_changed, NULL);
    g_object_unref(vol_mon);
    vol_mon = NULL;

    if(trash_monitor)
    {
        g_signal_handlers_disconnect_by_func(trash_monitor, on_trash_changed, NULL);
        g_object_unref(trash_monitor);
        trash_monitor = NULL;
    }
    if(trash_idle)
        g_source_remove(trash_idle);
    trash_idle = 0;

    memset(&trash_it, 0, sizeof(GtkTreeIter));
    memset(&sep_it, 0, sizeof(GtkTreeIter));
}
Ejemplo n.º 23
0
static void
ol_osd_module_init_osd (OlOsdModule *osd)
{
  osd->window = OL_OSD_WINDOW (ol_osd_window_new ());
  if (osd->window == NULL)
    return;
  GtkIconTheme *icontheme = gtk_icon_theme_get_default ();
  GdkPixbuf *bg = gtk_icon_theme_load_icon (icontheme,
                                            OL_STOCK_OSD_BG,
                                            32,
                                            0,
                                            NULL);
  ol_osd_window_set_bg (osd->window, bg);
  g_object_unref (bg);
  osd->toolbar = OL_OSD_TOOLBAR (ol_osd_toolbar_new ());
  if (osd->toolbar != NULL)
  {
    gtk_container_add (GTK_CONTAINER (osd->window),
                       GTK_WIDGET (osd->toolbar));
    gtk_widget_show_all (GTK_WIDGET (osd->toolbar));
    g_object_ref (osd->toolbar);
    ol_osd_toolbar_set_player (osd->toolbar, osd->player);
  }
  osd->display = FALSE;
  OlConfigProxy *config = ol_config_proxy_get_instance ();
  ol_assert (config != NULL);
  
  _bind_all_config (osd);
  
  g_signal_connect (osd->window, "moved",
                    G_CALLBACK (ol_osd_moved_handler),
                    NULL);
  g_signal_connect (osd->window, "resize",
                    G_CALLBACK (ol_osd_resize_handler),
                    NULL);
  g_signal_connect (osd->window, "button-release-event",
                    G_CALLBACK (ol_osd_button_release),
                    NULL);
  g_signal_connect (osd->window, "scroll-event",
                    G_CALLBACK (ol_osd_scroll),
                    NULL);
}
static void
test_window (void)
{
  GsdOsdDrawContext ctx;
  ClutterActor *stage, *actor;
  ClutterContent *canvas;
  GtkWidgetPath *widget_path;

  /* create a resizable stage */
  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "OSD Test");
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
  clutter_actor_set_background_color (stage, CLUTTER_COLOR_Red);
  clutter_actor_set_size (stage, 300, 300);
  clutter_actor_show (stage);

  /* box canvas */
  canvas = clutter_canvas_new ();
  clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 300, 300);

  actor = clutter_actor_new ();
  clutter_actor_add_constraint (actor, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0));
  clutter_actor_set_content (actor, canvas);
  g_object_unref (canvas);

  clutter_actor_add_child (stage, actor);

  memset (&ctx, 0, sizeof(ctx));

  widget_path = gtk_widget_path_new ();
  gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
  ctx.style = gtk_style_context_new ();
  gtk_style_context_set_path (ctx.style, widget_path);

  ctx.direction = clutter_get_default_text_direction ();
  ctx.theme = gtk_icon_theme_get_default ();

  g_signal_connect (canvas, "draw", G_CALLBACK (draw_box), &ctx);
  clutter_content_invalidate (canvas);

  g_signal_connect (stage, "destroy", G_CALLBACK (gtk_main_quit), NULL);
}
Ejemplo n.º 25
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;
}
Ejemplo n.º 26
0
GdkPixbuf *
_g_mime_type_get_icon (const char   *mime_type,
		       int           icon_size,
		       GtkIconTheme *icon_theme)
{
	GdkPixbuf *pixbuf = NULL;
	GIcon     *icon;

	if (icon_theme == NULL)
		icon_theme = gtk_icon_theme_get_default ();

	icon = g_content_type_get_icon (mime_type);
	if (icon == NULL)
		icon = g_themed_icon_new ("text-x-generic");
	pixbuf = _g_icon_get_pixbuf (icon, icon_size, icon_theme);

	g_object_unref (icon);

	return pixbuf;
}
Ejemplo n.º 27
0
GdkPixbuf *
gedit_file_browser_utils_pixbuf_from_theme (gchar const *name,
                                            GtkIconSize  size)
{
	gint width;
	GError *error = NULL;
	GdkPixbuf *pixbuf;

	gtk_icon_size_lookup (size, &width, NULL);

	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					   name,
					   width,
					   0,
					   &error);

	pixbuf = process_icon_pixbuf (pixbuf, name, width, error);

	return pixbuf;
}
Ejemplo n.º 28
0
static void
etc_load_icon (ETableCol *etc)
{
	/* FIXME This ignores theme changes. */

	GtkIconTheme *icon_theme;
	gint width, height;
	GError *error = NULL;

	icon_theme = gtk_icon_theme_get_default ();
	gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);

	etc->pixbuf = gtk_icon_theme_load_icon (
		icon_theme, etc->icon_name, height, GTK_ICON_LOOKUP_FORCE_SIZE, &error);

	if (error != NULL) {
		g_warning ("%s", error->message);
		g_error_free (error);
	}
}
Ejemplo n.º 29
0
/* compose_attach_dialog */
void compose_attach_dialog(Compose * compose)
{
	GtkWidget * dialog;
	GSList * filenames = NULL;
	GSList * p;
	char const * type;
	GdkPixbuf * pixbuf;
	GtkIconTheme * theme;
	GtkTreeIter iter;

	dialog = gtk_file_chooser_dialog_new(_("Attach file..."),
			GTK_WINDOW(compose->window),
			GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
	gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
	if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
		filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(
					dialog));
	gtk_widget_destroy(dialog);
	if(filenames == NULL)
		return;
	compose_set_modified(compose, TRUE);
	theme = gtk_icon_theme_get_default();
	for(p = filenames; p != NULL; p = p->next)
	{
		pixbuf = NULL;
		if((type = mime_type(compose->mime, p->data)) != NULL)
			mime_icons(compose->mime, type, 48, &pixbuf, -1);
		if(pixbuf == NULL)
			pixbuf = gtk_icon_theme_load_icon(theme, GTK_STOCK_FILE,
					48, 0, NULL);
		gtk_list_store_append(compose->a_store, &iter);
		gtk_list_store_set(compose->a_store, &iter, CAC_FILENAME,
				p->data, CAC_BASENAME, basename(p->data),
				CAC_ICON, pixbuf, -1);
	}
	g_slist_foreach(filenames, (GFunc)g_free, NULL);
	g_slist_free(filenames);
	gtk_widget_show(compose->a_window);
}
Ejemplo n.º 30
0
static GdkPixbuf * _mime_icon_emblem(GdkPixbuf * pixbuf, int size,
		char const * emblem)
{
	int esize;
	GdkPixbuf * epixbuf;
	GtkIconTheme * icontheme;
#if GTK_CHECK_VERSION(2, 14, 0)
	const unsigned int flags = GTK_ICON_LOOKUP_USE_BUILTIN
		| GTK_ICON_LOOKUP_FORCE_SIZE;
#else
	const unsigned int flags = GTK_ICON_LOOKUP_USE_BUILTIN;
#endif

	/* work on a copy */
	epixbuf = gdk_pixbuf_copy(pixbuf);
	g_object_unref(pixbuf);
	pixbuf = epixbuf;
	/* determine the size of the emblem */
	if(size >= 96)
		esize = 32;
	else if(size >= 48)
		esize = 24;
	else
		esize = 12;
	/* obtain the emblem's icon */
	icontheme = gtk_icon_theme_get_default();
	if((epixbuf = gtk_icon_theme_load_icon(icontheme, emblem, esize, flags,
					NULL)) == NULL)
		return pixbuf;
	/* blit the emblem */
#if 0 /* XXX does not show anything (bottom right) */
	gdk_pixbuf_composite(epixbuf, pixbuf, size - esize, size - esize,
			esize, esize, 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST,
			255);
#else /* blitting at the top left instead */
	gdk_pixbuf_composite(epixbuf, pixbuf, 0, 0, esize, esize, 0, 0,
			1.0, 1.0, GDK_INTERP_NEAREST, 255);
#endif
	g_object_unref(epixbuf);
	return pixbuf;
}