static void load_background_file (PanelBackground *background) { GError *error = NULL; if (!g_file_test (background->image, G_FILE_TEST_IS_REGULAR)) return; //FIXME add a monitor on the file so that we reload the background //when it changes background->loaded_image = gdk_pixbuf_new_from_file (background->image, &error); if (!background->loaded_image) { g_assert (error != NULL); g_warning (G_STRLOC ": unable to open '%s': %s", background->image, error->message); g_error_free (error); } panel_background_update_has_alpha (background); }
gboolean image_new(image_t *image, const char *filename) { GError **error = NULL; image->pbuf = gdk_pixbuf_new_from_file(filename, error); if (!image->pbuf) return FALSE; image->layer = create_layer(gdk_pixbuf_get_width(image->pbuf), gdk_pixbuf_get_height(image->pbuf)); image->rotation = 0; image->surface = create_surface(image->layer->width, image->layer->height); cairo_t *cr = cairo_create(image->surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_set_source_pixbuf(cr, image->pbuf, 0, 0); cairo_paint(cr); cairo_destroy(cr); add_layer(image->layer); return TRUE; }
/** * Initialize the application icons for the program. These icons are * the ones shown by the window manager within title bars and pagers. * The last icon listed in the array will be displayed in the About * dialog. * * @param top Toplevel whose icon to set. All child windows will * inherit these icons. */ static void init_icons(toplevel_t * top) { static const char *icon_names[] = { "sediffx-small.png", "sediffx.png" }; GdkPixbuf *icon; char *path; GList *icon_list = NULL; size_t i; for (i = 0; i < sizeof(icon_names) / sizeof(icon_names[0]); i++) { if ((path = apol_file_find_path(icon_names[i])) == NULL) { continue; } icon = gdk_pixbuf_new_from_file(path, NULL); free(path); if (icon == NULL) { continue; } icon_list = g_list_append(icon_list, icon); } gtk_window_set_default_icon_list(icon_list); gtk_window_set_icon_list(top->w, icon_list); }
/* * About window * */ void windows_about(){ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(ICON_ABOUT, NULL); GtkWidget *dialog = gtk_about_dialog_new(); GError *error = NULL; /* Set all window options (color, size, position, logo, icon, etc) */ gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(dialog), "TwitCrusader"); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), ""); gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), "(c) PTKDev, RoxShannon"); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), "Basato su librerie GTK e semplicità!\n\nVersion: "TWC_VERSION""TWC_VERSION_STATUS); gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), "http://www.twitcrusader.org/"); gtk_window_set_icon_from_file (GTK_WINDOW(dialog), ICON_STAR, &error); gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf); g_object_unref(pixbuf), pixbuf = NULL; /* CALLBACK: exit event and Widget Show */ gtk_dialog_run(GTK_DIALOG (dialog)); gtk_widget_destroy(dialog); }
static void init_candidate_items(void) { int i; GtkWidget *vbox, *hbox; GdkPixbuf *pixbuf = NULL; gchar *vs_file = NULL; GdkColor separator_color = { 0, 0xA000, 0xA000, 0xA000 }; vs_file = locate_img_file(VS_IMAGE); if (vs_file) pixbuf = gdk_pixbuf_new_from_file(vs_file, NULL); g_free(vs_file); for (i = 0; i < MAX_POP_WIN_ITEMS; i++) { if (pixbuf) { candidate_items[i].separator = gtk_image_new_from_pixbuf(pixbuf); } else { candidate_items[i].separator = gtk_vseparator_new(); gtk_widget_modify_bg(candidate_items[i].separator, GTK_STATE_NORMAL, &separator_color); } vbox = gtk_vbox_new(FALSE, 0); candidate_items[i].widget = vbox; hbox = gtk_hbox_new(FALSE, 0); candidate_items[i].dummy_width_widget = hbox; gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); candidate_items[i].label = gtk_button_new(); gtk_box_pack_start(GTK_BOX(vbox), candidate_items[i].label, TRUE, TRUE, 0); gtk_button_set_relief(GTK_BUTTON(candidate_items[i].label), GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(candidate_items[i].label), "clicked", G_CALLBACK(candidate_item_clicked_cb), &candidate_items[i]); } if (pixbuf) g_object_unref(pixbuf); }
gboolean set_gtk_widget_bg_image (GtkWidget *widget, const gchar *filename, guint bgcolor) { GdkPixbuf *pbuf, *bg; GdkPixmap *pixmap; gint width, height; if (GTK_WIDGET_NO_WINDOW(widget) || !GTK_WIDGET_REALIZED(widget) || !filename) goto fail; pbuf = gdk_pixbuf_new_from_file(filename, NULL); if (!pbuf) goto fail; width = gdk_pixbuf_get_width(pbuf); height = gdk_pixbuf_get_height(pbuf); bg = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, gdk_pixbuf_get_bits_per_sample(pbuf), width, height); gdk_pixbuf_fill(bg, bgcolor); gdk_pixbuf_composite(pbuf, bg, 0, 0, width, height, 0, 0, 1, 1, GDK_INTERP_BILINEAR,0xFF); pixmap = gdk_pixmap_new(widget->window, width, height, -1); gdk_draw_pixbuf(pixmap, NULL, bg, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0); g_object_unref(pbuf); g_object_unref(bg); gtk_widget_set_app_paintable(widget,TRUE); gdk_window_set_back_pixmap(widget->window, pixmap, FALSE); g_object_unref(pixmap); //gtk_widget_queue_draw(widget); return TRUE; fail: return FALSE; }
static void draw_page_image (GtkPrintOperation * op, GtkPrintContext * cnt, gint page, gpointer data) { cairo_t *cr; GdkPixbuf *pb, *spb; guint iw, ih; gdouble pw, ph; gdouble factor; cr = gtk_print_context_get_cairo_context (cnt); pw = gtk_print_context_get_width (cnt); ph = gtk_print_context_get_height (cnt); if (options.print_data.headers) ph -= HEADER_HEIGHT + HEADER_GAP; /* create header */ if (options.print_data.headers) draw_header (cnt, 1, 1); /* scale image to page size */ pb = gdk_pixbuf_new_from_file (options.common_data.uri, NULL); iw = gdk_pixbuf_get_width (pb); ih = gdk_pixbuf_get_height (pb); if (pw < iw || ph < ih) { factor = MIN (pw / iw, ph / ih); factor = (factor > 1.0) ? 1.0 : factor; spb = gdk_pixbuf_scale_simple (pb, iw * factor, ih * factor, GDK_INTERP_HYPER); } else spb = g_object_ref (pb); g_object_unref (pb); /* add image to surface */ gdk_cairo_set_source_pixbuf (cr, spb, 0.0, HEADER_HEIGHT + HEADER_GAP); cairo_paint (cr); g_object_unref (spb); }
static void download_banner(GtChannel* self) { GtChannelPrivate* priv = gt_channel_get_instance_private(self); if (priv->video_banner_url) { GdkPixbuf* banner = NULL; if (!g_file_test(priv->cache_filename, G_FILE_TEST_EXISTS)) g_info("{GtChannel} Cache miss for channel '%s'", priv->name); else { g_info("{GtChannel} Cache hit for channel '%s'", priv->name); banner = gdk_pixbuf_new_from_file(priv->cache_filename, NULL); priv->cache_timestamp = utils_timestamp_file(priv->cache_filename); } if (!banner) gt_twitch_download_picture_async(main_app->twitch, priv->video_banner_url, 0, priv->cancel, download_banner_cb, self); else { g_thread_pool_push(cache_update_pool, self, NULL); set_banner(self, banner, FALSE, TRUE); priv->updating = FALSE; g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]); } } else { set_banner(self, gdk_pixbuf_new_from_resource("/com/gnome-twitch/icons/offline.png", NULL), FALSE, TRUE); priv->updating = FALSE; g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]); } }
CMessagesDlg::CMessagesDlg(GtkWindow *pParent) { GtkWidget *text_view, *scrolled_window; GdkRectangle rc; // Dialog with buttons m_pDlg = gtk_dialog_new_with_buttons("Message log", pParent, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL); gtk_dialog_widget_standard_tooltips(GTK_DIALOG(m_pDlg)); g_signal_connect(G_OBJECT(m_pDlg), "response", G_CALLBACK(response_dialog), this); // Dialog size GdkScreen *scr = gtk_window_get_screen(pParent); int mon = gdk_screen_get_monitor_at_window(scr, GTK_WIDGET(pParent)->window); gdk_screen_get_monitor_geometry(scr, mon, &rc); if (rc.width>0 && rc.height>0) gtk_window_set_default_size(GTK_WINDOW(m_pDlg), RoundToInt(0.7*rc.width), RoundToInt(0.7*rc.height)); // Dialog icon gchar *icon = get_icon_file("messagelog"); gtk_window_set_icon(GTK_WINDOW(m_pDlg), gdk_pixbuf_new_from_file(icon, NULL)); g_free(icon); // List box text_view = gtk_text_view_new_with_buffer(ms_Buffer); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD_CHAR); gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), false); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text_view), false); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER(scrolled_window), text_view); gtk_widget_set_size_request(scrolled_window, 640, 480); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(m_pDlg)->vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show_all(GTK_DIALOG(m_pDlg)->vbox); }
/** * retourne le logo par défaut de grisbi * * * return a new pixbuf * */ GdkPixbuf *gsb_select_icon_get_default_logo_pixbuf ( void ) { GdkPixbuf *pixbuf = NULL; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file ( g_build_filename (gsb_dirs_get_pixmaps_dir ( ), "grisbi-logo.png", NULL), &error ); if ( ! pixbuf ) { devel_debug ( error -> message ); g_error_free ( error ); } if ( gdk_pixbuf_get_width (pixbuf) > LOGO_WIDTH || gdk_pixbuf_get_height (pixbuf) > LOGO_HEIGHT ) { return gsb_select_icon_resize_logo_pixbuf ( pixbuf ); } else return pixbuf; }
static GdkPixbuf * gsearchtool_get_thumbnail_image (const gchar * thumbnail) { GdkPixbuf * pixbuf = NULL; if (thumbnail != NULL) { if (g_file_test (thumbnail, G_FILE_TEST_EXISTS)) { GdkPixbuf * thumbnail_pixbuf = NULL; gfloat scale_factor_x = 1.0; gfloat scale_factor_y = 1.0; gint scale_x; gint scale_y; thumbnail_pixbuf = gdk_pixbuf_new_from_file (thumbnail, NULL); gsearchtool_thumbnail_frame_image (&thumbnail_pixbuf); if (gdk_pixbuf_get_width (thumbnail_pixbuf) > ICON_SIZE) { scale_factor_x = (gfloat) ICON_SIZE / (gfloat) gdk_pixbuf_get_width (thumbnail_pixbuf); } if (gdk_pixbuf_get_height (thumbnail_pixbuf) > ICON_SIZE) { scale_factor_y = (gfloat) ICON_SIZE / (gfloat) gdk_pixbuf_get_height (thumbnail_pixbuf); } if (gdk_pixbuf_get_width (thumbnail_pixbuf) > gdk_pixbuf_get_height (thumbnail_pixbuf)) { scale_x = ICON_SIZE; scale_y = (gint) (gdk_pixbuf_get_height (thumbnail_pixbuf) * scale_factor_x); } else { scale_x = (gint) (gdk_pixbuf_get_width (thumbnail_pixbuf) * scale_factor_y); scale_y = ICON_SIZE; } pixbuf = gdk_pixbuf_scale_simple (thumbnail_pixbuf, scale_x, scale_y, GDK_INTERP_BILINEAR); g_object_unref (thumbnail_pixbuf); } } return pixbuf; }
static GtkWidget * dnd_hints_init_window(const gchar *fname) { GdkPixbuf *pixbuf; GtkWidget *pix; GtkWidget *win; pixbuf = gdk_pixbuf_new_from_file(fname, NULL); g_return_val_if_fail(pixbuf, NULL); win = gtk_window_new(GTK_WINDOW_POPUP); pix = gtk_image_new_from_pixbuf(pixbuf); gtk_container_add(GTK_CONTAINER(win), pix); gtk_widget_show_all(pix); g_object_unref(G_OBJECT(pixbuf)); g_signal_connect(G_OBJECT(win), "realize", G_CALLBACK(dnd_hints_realized_cb), pix); return win; }
void addEntry (const gchar *group, const gchar *name, const gchar *icon_path, const gchar *execute) { GtkListStore *store = m_stores [group]; if (!store) { g_warning ("Didn't find group '%s' for entry '%s'.", group, name); return; } GdkPixbuf *icon = NULL; if (icon_path) { GError *error = 0; std::string path = ICONS + std::string (icon_path) + ".png"; icon = gdk_pixbuf_new_from_file (path.c_str(), &error); if (!icon) g_warning ("Could not load icon: %s.\nReason: %s", icon_path, error->message); } GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, name, 1, icon, 2, execute, -1); }
GdkPixbuf *icon_cache_get_pixbuf(const gchar * file) { GdkPixbuf *icon; if (!cache) icon_cache_init(); icon = g_hash_table_lookup(cache, file); if (!icon) { icon = gdk_pixbuf_new_from_file(idle_free (g_build_filename (params.path_data, "pixmaps", file, NULL)), NULL); g_hash_table_insert(cache, g_strdup(file), icon); } g_object_ref(icon); return icon; }
static GtkWidget * _toolbar_new (OlScrollModule *module) { GtkWidget *toolbar = gtk_hbox_new (FALSE, 0); OlImageButton *button = OL_IMAGE_BUTTON (ol_image_button_new ()); GtkIconTheme *icontheme = gtk_icon_theme_get_default (); GtkIconInfo *info = gtk_icon_theme_lookup_icon (icontheme, OL_STOCK_SCROLL_CLOSE, 16, 0); GdkPixbuf *image = gdk_pixbuf_new_from_file (gtk_icon_info_get_filename (info), NULL); ol_image_button_set_pixbuf (button, image); g_signal_connect (button, "clicked", G_CALLBACK (_close_clicked_cb), module); gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button)); gtk_icon_info_free (info); gtk_widget_show_all (toolbar); return toolbar; }
/** * glade_cursor_init: * * Initializes cursors for use with glade_cursor_set(). */ void glade_cursor_init (void) { gchar *path; GError *error = NULL; GdkDisplay *display; cursor = g_new0 (GladeCursor, 1); display = gdk_display_get_default (); cursor->selector = NULL; cursor->add_widget = gdk_cursor_new_from_name (display, "crosshair"); cursor->resize_top_left = gdk_cursor_new_from_name (display, "nw-resize"); cursor->resize_top_right = gdk_cursor_new_from_name (display, "ne-resize"); cursor->resize_bottom_left = gdk_cursor_new_from_name (display, "sw-resize"); cursor->resize_bottom_right = gdk_cursor_new_from_name (display, "se-resize"); cursor->resize_left = gdk_cursor_new_from_name (display, "w-resize"); cursor->resize_right = gdk_cursor_new_from_name (display, "e-resize"); cursor->resize_top = gdk_cursor_new_from_name (display, "n-resize"); cursor->resize_bottom = gdk_cursor_new_from_name (display, "s-resize"); cursor->drag = gdk_cursor_new_from_name (display, "move"); cursor->add_widget_pixbuf = NULL; /* load "add" cursor pixbuf */ path = g_build_filename (glade_app_get_pixmaps_dir (), ADD_PIXBUF_FILENAME, NULL); cursor->add_widget_pixbuf = gdk_pixbuf_new_from_file (path, &error); if (cursor->add_widget_pixbuf == NULL) { g_critical (_("Unable to load image (%s)"), error->message); g_error_free (error); error = NULL; } g_free (path); }
GdkPixbuf * rb_plugins_engine_get_plugin_icon (RBPluginInfo *info) { g_return_val_if_fail (info != NULL, NULL); if (info->icon_name == NULL) return NULL; if (info->icon_pixbuf == NULL) { char *filename = NULL; char *dirname; dirname = g_path_get_dirname (info->file); filename = g_build_filename (dirname, info->icon_name, NULL); g_free (dirname); info->icon_pixbuf = gdk_pixbuf_new_from_file (filename, NULL); g_free (filename); } return info->icon_pixbuf; }
static void verb_about(BonoboUIComponent *uic, gpointer data, const gchar *verbname) { GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(WORKRAVE_PKGDATADIR "/images/workrave.png", NULL); GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); gtk_container_set_border_width(GTK_CONTAINER(about), 5); gtk_show_about_dialog(NULL, "name", "Workrave", "version", PACKAGE_VERSION, "copyright", workrave_copyright, "website", "http://www.workrave.org", "website_label", "www.workrave.org", "comments", _("This program assists in the prevention and recovery" " of Repetitive Strain Injury (RSI)."), "translator-credits", workrave_translators, "authors", workrave_authors, "logo", pixbuf, NULL); g_object_unref(pixbuf); }
void fwitux_replies_window_set_image (const gchar *file, GtkTreeIter iter) { GtkListStore *store; GdkPixbuf *pixbuf; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file (file, &error); if (!pixbuf){ fwitux_debug (DEBUG_DOMAIN_SETUP, "Image error: %s: %s", file, error->message); g_error_free (error); return; } store = fwitux_reply_list_get_store (); gtk_list_store_set (store, &iter, PIXBUF_USER_PHOTO, pixbuf, -1); }
static gboolean save_image_verify (const gchar *filename, GError **error) { gboolean ret = FALSE; GdkPixbuf *pixbuf = NULL; const gchar *option; gchar *icc_profile = NULL; gsize len = 0; /* load */ pixbuf = gdk_pixbuf_new_from_file (filename, error); if (pixbuf == NULL) goto out; /* check values */ option = gdk_pixbuf_get_option (pixbuf, "icc-profile"); if (option == NULL) { *error = g_error_new (1, 0, "no profile set"); goto out; } /* decode base64 */ icc_profile = (gchar *) g_base64_decode (option, &len); if (len != ICC_PROFILE_SIZE) { *error = g_error_new (1, 0, "profile length invalid, got %" G_GSIZE_FORMAT, len); g_file_set_contents ("error.icc", icc_profile, len, NULL); goto out; } /* success */ ret = TRUE; out: if (pixbuf != NULL) g_object_unref (pixbuf); g_free (icc_profile); return ret; }
int main (int argc, char **argv) { GdkPixbuf *pixbuf; GdkPixbuf *gray; GError *err; if (argc != 2) { g_printerr ("specify a single image on the command line\n"); return 1; } g_type_init (); err = NULL; pixbuf = gdk_pixbuf_new_from_file (argv[1], &err); if (err != NULL) { g_printerr ("failed to load image: %s\n", err->message); g_error_free (err); return 1; } gray = grayscale_pixbuf (pixbuf); err = NULL; gdk_pixbuf_save (gray, "grayscale.png", "png", &err, NULL); if (err != NULL) { g_printerr ("failed to save image: %s\n", err->message); g_error_free (err); return 1; } g_print ("wrote grayscale.png\n"); return 0; }
static void UpdateFilePreviewWidget(GtkFileChooser *file_chooser, gpointer preview_widget_voidptr) { GtkImage *preview_widget = GTK_IMAGE(preview_widget_voidptr); char *image_filename = _gtk_file_chooser_get_preview_filename(file_chooser); if (!image_filename) { _gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE); return; } // We do this so GTK scales down images that are too big, but not scale up images that are too small GdkPixbuf *preview_pixbuf = gdk_pixbuf_new_from_file(image_filename, NULL); if (!preview_pixbuf) { g_free(image_filename); _gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE); return; } if (gdk_pixbuf_get_width(preview_pixbuf) > MAX_PREVIEW_SIZE || gdk_pixbuf_get_height(preview_pixbuf) > MAX_PREVIEW_SIZE) { g_object_unref(preview_pixbuf); preview_pixbuf = gdk_pixbuf_new_from_file_at_size(image_filename, MAX_PREVIEW_SIZE, MAX_PREVIEW_SIZE, NULL); } g_free(image_filename); if (!preview_pixbuf) { _gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE); return; } // This is the easiest way to do center alignment without worrying about containers // Minimum 3px padding each side (hence the 6) just to make things nice gint x_padding = (MAX_PREVIEW_SIZE + 6 - gdk_pixbuf_get_width(preview_pixbuf)) / 2; _gtk_misc_set_padding(GTK_MISC(preview_widget), x_padding, 0); _gtk_image_set_from_pixbuf(preview_widget, preview_pixbuf); g_object_unref(preview_pixbuf); _gtk_file_chooser_set_preview_widget_active(file_chooser, TRUE); }
// TODO derive? static void pixbufEditor_file_set(GtkFileChooserButton *fcb, gpointer data) { PixbufEditor *e = PIXBUF_EDITOR(data); GdkPixbuf *pixbuf; GError *err = NULL; pixbuf = gdk_pixbuf_new_from_file(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fcb)), &err); if (pixbuf == NULL) { GtkWidget *alert; alert = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error loading pixbuf: %s", err->message); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(alert), "The pixbuf has not been changed."); gtk_widget_show_all(gtk_message_dialog_get_image(GTK_MESSAGE_DIALOG(alert))); gtk_dialog_run(GTK_DIALOG(alert)); gtk_widget_destroy(alert); return; } g_object_set(e, PIXBUF_EDITOR_PROPERTY, pixbuf, NULL); }
static void update_image_preview(void *filechooser, void *image) { #define MAX_PREVIEW_SIZE 256 char *filename = gtk_file_chooser_get_preview_filename(filechooser); if (!filename) return; // load preview void *pixbuf = gdk_pixbuf_new_from_file(filename, NULL); if (!pixbuf) { g_free_utox(filename); gtk_file_chooser_set_preview_widget_active(filechooser, false); return; } // if preview too big load smaller if (gdk_pixbuf_get_width(pixbuf) > MAX_PREVIEW_SIZE || gdk_pixbuf_get_height(pixbuf) > MAX_PREVIEW_SIZE) { g_object_unref(pixbuf); pixbuf = gdk_pixbuf_new_from_file_at_size(filename, MAX_PREVIEW_SIZE, MAX_PREVIEW_SIZE, NULL); } g_free_utox(filename); if (!pixbuf) { gtk_file_chooser_set_preview_widget_active(filechooser, false); return; } // pad to MAX_PREVIEW_SIZE + 3px margins int margin = (MAX_PREVIEW_SIZE + 6 - gdk_pixbuf_get_width(pixbuf)) / 2; gtk_widget_set_margin_left(image, margin); gtk_widget_set_margin_right(image, margin); // set preview gtk_image_set_from_pixbuf(image, pixbuf); g_object_unref(pixbuf); gtk_file_chooser_set_preview_widget_active(filechooser, true); }
static void georef_layer_load_image ( VikGeorefLayer *vgl, VikViewport *vp, gboolean from_file ) { GError *gx = NULL; if ( vgl->image == NULL ) return; if ( vgl->pixbuf ) g_object_unref ( G_OBJECT(vgl->pixbuf) ); if ( vgl->scaled ) { g_object_unref ( G_OBJECT(vgl->scaled) ); vgl->scaled = NULL; } vgl->pixbuf = gdk_pixbuf_new_from_file ( vgl->image, &gx ); if (gx) { if ( !from_file ) a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(vp), _("Couldn't open image file: %s"), gx->message ); g_error_free ( gx ); } else { vgl->width = gdk_pixbuf_get_width ( vgl->pixbuf ); vgl->height = gdk_pixbuf_get_height ( vgl->pixbuf ); } if ( !from_file ) { if ( vik_viewport_get_drawmode(vp) != VIK_VIEWPORT_DRAWMODE_UTM ) { a_dialog_warning_msg ( VIK_GTK_WINDOW_FROM_WIDGET(vp), _("GeoRef map cannot be displayed in the current drawmode.\nSelect \"UTM Mode\" from View menu to view it.") ); } } /* should find length and width here too */ }
static void add_node_indicator (nodePtr node) { IndicateIndicator *indicator; GdkPixbuf *pixbuf; gchar count[10]; if (indicator_priv->indicators->len >= MAX_INDICATORS) return; if (IS_VFOLDER(node) || g_slist_length (node->children) > 0) { /* Not a feed - walk children and do nothing more */ node_foreach_child (node, add_node_indicator); return; } /* Skip feeds with no unread items */ if (node->unreadCount == 0) return; indicator = indicate_indicator_new_with_server (indicator_priv->server); g_signal_connect (indicator, "user-display", G_CALLBACK (on_indicator_clicked), node); /* load favicon */ pixbuf = gdk_pixbuf_new_from_file (node->iconFile, NULL); /* display favicon */ indicate_gtk_indicator_set_property_icon (indicator, "icon", pixbuf); g_object_unref (pixbuf); sprintf (count, "%u", node->unreadCount); indicate_indicator_set_property (indicator, "name", node->title); indicate_indicator_set_property (indicator, "count", count); #if SET_DRAW_ATTENTION indicate_indicator_set_property_bool (indicator, "draw-attention", TRUE); #endif g_ptr_array_add (indicator_priv->indicators, indicator); }
GtkWidget *gui_detach_box_from_parent (GtkWidget *box, GtkWidget *parent, gboolean *flag, gchar *window_title, gint x, gint y) { /* * This function detaches the box from its parent. If the flag=FALSE, than * it creates a new window and packs the box inside the window, otherwise * it packs the box in its original place inside the main window. */ GtkWidget *window; gchar *glade_pixmap_file = g_build_filename (PHOEBE_GLADE_PIXMAP_DIR, "ico.png", NULL); if(*flag){ window = gtk_widget_get_parent (box); gtk_widget_reparent(box, parent); gtk_widget_destroy(window); gui_status("%s reatached.", window_title); } else{ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_set_data (G_OBJECT (window), "data_box", (gpointer) box); g_object_set_data (G_OBJECT (window), "data_parent", (gpointer) parent); g_object_set_data (G_OBJECT (window), "data_flag", (gpointer) flag); gtk_window_set_icon (GTK_WINDOW(window), gdk_pixbuf_new_from_file(glade_pixmap_file, NULL)); gtk_window_set_title (GTK_WINDOW (window), window_title); gtk_widget_reparent(box, window); gtk_widget_set_size_request (window, x, y); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect (GTK_WIDGET(window), "delete-event", G_CALLBACK (tmp_circumvent_delete_event), NULL); gtk_widget_show_all (window); gui_status("%s detached.", window_title); } *flag = !(*flag); return window; }
/*--------------------------------------------------------------------------*/ void gb_update_druid (void) { GdkPixbuf *logo; gb_debug (DEBUG_UPDATE, "START"); if ( update_window == NULL ) { remote_dir_handle = NULL; remote_file_handle = NULL; update_cancel_flag = FALSE; logo = gdk_pixbuf_new_from_file (ICON_PIXMAP, NULL); update_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW(update_window), DRUID_WIDTH, DRUID_HEIGHT); update_druid = gnome_druid_new(); gtk_container_add( GTK_CONTAINER(update_window), update_druid ); add_start_page( GNOME_DRUID(update_druid), logo ); add_select_download_page( GNOME_DRUID(update_druid), logo ); add_downloading_page( GNOME_DRUID(update_druid), logo ); add_finish_page( GNOME_DRUID(update_druid), logo ); g_signal_connect( G_OBJECT(update_druid), "cancel", G_CALLBACK(cancel_cb), NULL ); g_signal_connect( G_OBJECT(update_window), "destroy", G_CALLBACK(destroy_cb), NULL ); gtk_widget_show_all( update_window ); } gb_debug (DEBUG_UPDATE, "END"); }
GdkPixbuf * xfsm_load_session_preview (const gchar *name) { GdkDisplay *display; GdkPixbuf *pb = NULL; gchar *display_name; gchar *filename; gchar *path; /* determine thumb file */ display = gdk_display_get_default (); display_name = xfsm_gdk_display_get_fullname (display); path = g_strconcat ("sessions/thumbs-", display_name, "/", name, ".png", NULL); filename = xfce_resource_lookup (XFCE_RESOURCE_CACHE, path); g_free (display_name); g_free (path); if (filename != NULL) pb = gdk_pixbuf_new_from_file (filename, NULL); g_free (filename); return pb; }
static void zenity_create_clothes (GtkWidget *canvas_board) { GdkPixbuf *pixbuf; GnomeCanvasItem *canvas_item; gchar *pixbuf_path; size_t i; for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) { pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL); canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), GNOME_TYPE_CANVAS_PIXBUF, "x", monk_clothes[i].x, "y", monk_clothes[i].y, "pixbuf", pixbuf, "anchor", GTK_ANCHOR_NW, NULL); g_signal_connect (G_OBJECT (canvas_item), "event", G_CALLBACK (zenity_move_clothes_event), NULL); } }