/** * workrave_timerbox_update: * * @self: a @WorkraveTimerbox * @image: a @GtkImage where the timerbox will be drawn into * */ void workrave_timerbox_update(WorkraveTimerbox *self, GtkImage *image) { int width = 24; int height = 24; workrave_timerbox_compute_dimensions(self, &width, &height); cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_t *cr = cairo_create(surface); workrave_timerbox_draw(self, cr); GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height); gtk_image_set_from_pixbuf(image, pixbuf); gdk_pixbuf_unref(pixbuf); cairo_surface_destroy(surface); cairo_destroy(cr); }
TILP_EXPORT void on_sc_load1_activate(GtkMenuItem * menuitem, gpointer user_data) { const gchar *filename; GdkPixbuf *pixbuf; GError *error = NULL; filename = create_fsel(local.cwdir, NULL, "*.jpg;*.png;*.xpm;*.bmp", FALSE); if (!filename) return; pixbuf = gdk_pixbuf_new_from_file(filename, &error); if (!pixbuf) { tilp_warning("Failed to load pixbuf file: %s: %s\n", filename, error->message); g_error_free(error); } gtk_image_set_from_pixbuf(GTK_IMAGE(scrn_img), pixbuf); g_object_unref(pixbuf); }
void fx_head_set_state_image(FxMain* fxmain , StateType type) { FxHead *fxhead = fxmain->headPanel; GdkPixbuf *pixbuf; gchar *statename = fx_util_get_state_name(type); gint use_status_icon = USE_STATUS_ICON(fxmain->user->config); gtk_label_set_markup(GTK_LABEL(fxhead->state_label) , statename); switch(type) { case P_ONLINE : pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"online.svg" , 20 , 20 , NULL); if(use_status_icon) gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"online.svg"); break; case P_BUSY : pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"busy.svg" , 20 , 20 , NULL); if(use_status_icon) gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"busy.svg"); break; case P_HIDDEN : pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"invisible.svg" , 20 , 20 , NULL); if(use_status_icon) gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"invisible.svg"); break; case P_OFFLINE : pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"offline.svg" , 20 , 20 , NULL); if(use_status_icon) gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"offline.svg"); gtk_widget_set_sensitive(fxhead->portrait, FALSE); break; default : pixbuf = gdk_pixbuf_new_from_file_at_size(SKIN_DIR"away.svg" , 20 , 20 , NULL); if(use_status_icon) gtk_status_icon_set_from_file(fxmain->trayIcon, SKIN_DIR"away.svg"); break; } gtk_image_set_from_pixbuf(GTK_IMAGE(fxhead->state_img) , pixbuf); g_object_unref(pixbuf); free(statename); }
static void gtk_message_row_update (GtkMessageRow *row) { GtkMessageRowPrivate *priv = row->priv; GDateTime *t; char *s; gtk_label_set_text (priv->source_name, priv->message->sender_name); gtk_label_set_text (priv->source_nick, priv->message->sender_nick); gtk_label_set_text (priv->content_label, priv->message->message); t = g_date_time_new_from_unix_utc (priv->message->time); s = g_date_time_format (t, "%e %b %y"); gtk_label_set_text (priv->short_time_label, s); g_free (s); s = g_date_time_format (t, "%X - %e %b %Y"); gtk_label_set_text (priv->detailed_time_label, s); g_free (s); g_date_time_unref (t); gtk_widget_set_visible (GTK_WIDGET(priv->n_favorites_label), priv->message->n_favorites != 0); s = g_strdup_printf ("<b>%d</b>\nFavorites", priv->message->n_favorites); gtk_label_set_markup (priv->n_favorites_label, s); g_free (s); gtk_widget_set_visible (GTK_WIDGET(priv->n_reshares_label), priv->message->n_reshares != 0); s = g_strdup_printf ("<b>%d</b>\nReshares", priv->message->n_reshares); gtk_label_set_markup (priv->n_reshares_label, s); g_free (s); gtk_widget_set_visible (GTK_WIDGET (priv->resent_box), priv->message->resent_by != NULL); if (priv->message->resent_by) gtk_button_set_label (GTK_BUTTON (priv->resent_by_button), priv->message->resent_by); if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0) gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo", GTK_ICON_SIZE_DND); else gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_other); }
static void on_update_img_preview( GtkFileChooser *chooser, GtkImage* img ) { char* file = gtk_file_chooser_get_preview_filename(chooser); GdkPixbuf* pix = NULL; if(file) { pix = gdk_pixbuf_new_from_file_at_scale( file, 128, 128, TRUE, NULL ); g_free( file ); } if(pix) { gtk_file_chooser_set_preview_widget_active(chooser, TRUE); gtk_image_set_from_pixbuf(img, pix); g_object_unref(pix); } else { gtk_image_clear(img); gtk_file_chooser_set_preview_widget_active(chooser, FALSE); } }
static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint32 time, gpointer data) { GtkWidget *image = GTK_WIDGET (data); GdkPixbuf *pixbuf; if (gtk_selection_data_get_length (selection_data) < 0) return; pixbuf = gtk_selection_data_get_pixbuf (selection_data); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); }
static void reload_image_menu_items (void) { GSList* l; for (l = image_menu_items; l; l = l->next) { GtkWidget *image = l->data; gboolean is_mapped; is_mapped = gtk_widget_get_mapped (image); if (is_mapped) gtk_widget_unmap (image); gtk_image_set_from_pixbuf (GTK_IMAGE (image), NULL); if (is_mapped) gtk_widget_map (image); } }
static void on_entry_changed( GtkEntry* entry, GtkImage* img ) { const char* str = gtk_entry_get_text(entry); MenuCacheApp* app = NULL; if( str && *str ) app = match_app_by_exec(str); if( app ) { int w, h; GdkPixbuf* pix; gtk_icon_size_lookup(GTK_ICON_SIZE_DIALOG, &w, &h); pix = lxpanel_load_icon(menu_cache_item_get_icon(MENU_CACHE_ITEM(app)), w, h, TRUE); gtk_image_set_from_pixbuf(img, pix); g_object_unref(pix); } else { gtk_image_set_from_stock(img, GTK_STOCK_EXECUTE, GTK_ICON_SIZE_DIALOG); } }
void load_image( APP *app ) { if( app->file == NULL ) return; GdkPixbuf *pb; GError *err = NULL; pb = gdk_pixbuf_new_from_file_at_scale( app->file, app->width, app->height, TRUE, &err ); if(! pb ) { g_print( "Error while load pixbuf\n" ); g_print( "Error: %s\n", err->message ); return; } gtk_image_set_from_pixbuf( GTK_IMAGE( app->img ), pb ); g_object_unref( pb ); }
void ImageOpenDlg::updatePreviewCallback(GtkFileChooser * fileChooser, void * userData) { gchar * filename = gtk_file_chooser_get_preview_filename(fileChooser); if (filename) { GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(filename, NULL); GtkWidget * image = gtk_file_chooser_get_preview_widget(fileChooser); if (pixbuf) { GdkPixbuf * scaled_pixbuf = pixbufScaleDownIfNecessary(pixbuf, 256); gtk_image_set_from_pixbuf(GTK_IMAGE(image), scaled_pixbuf); g_object_unref(scaled_pixbuf); g_object_unref(pixbuf); } else { gtk_image_set_from_stock(GTK_IMAGE(image), "gtk-dialog-question", GTK_ICON_SIZE_DIALOG); } g_free(filename); } gtk_file_chooser_set_preview_widget_active(fileChooser, true); }
static void show_account_creation(RingMainWindow *win) { RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_creation_1, CREATE_ACCOUNT_1_VIEW_NAME); gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_creation_2, CREATE_ACCOUNT_2_VIEW_NAME); /* hide settings button until account creation is complete */ gtk_widget_hide(priv->ring_settings); /* set ring logo */ GError *error = NULL; GdkPixbuf* logo_ring = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-logo-blue", -1, 75, TRUE, &error); if (logo_ring == NULL) { g_debug("Could not load logo: %s", error->message); g_clear_error(&error); } else gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_ring_logo), logo_ring); /* style of alias and hash entry; give them a larger font */ gtk_widget_override_font(priv->entry_alias, pango_font_description_from_string("15")); gtk_widget_override_font(priv->entry_hash, pango_font_description_from_string("monospace 15")); gtk_entry_set_text(GTK_ENTRY(priv->entry_alias), g_get_real_name()); /* connect signals */ g_signal_connect(priv->entry_alias, "changed", G_CALLBACK(alias_entry_changed), win); g_signal_connect(priv->button_account_creation_next, "clicked", G_CALLBACK(account_creation_next_clicked), win); g_signal_connect(priv->button_account_creation_done, "clicked", G_CALLBACK(account_creation_done_clicked), win); g_signal_connect(priv->entry_alias, "activate", G_CALLBACK(entry_alias_activated), win); g_signal_connect_swapped(priv->entry_hash, "activate", G_CALLBACK(gtk_button_clicked), priv->button_account_creation_done); gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), CREATE_ACCOUNT_1_VIEW_NAME); }
/** * empathy_avatar_image_set: * @avatar_image: an #EmpathyAvatarImage * @avatar: the #EmpathyAvatar to set @avatar_image to * * Sets @avatar_image to display the avatar indicated by @avatar. */ void empathy_avatar_image_set (EmpathyAvatarImage *avatar_image, EmpathyAvatar *avatar) { EmpathyAvatarImagePriv *priv = GET_PRIV (avatar_image); GdkPixbuf *scaled_pixbuf; g_return_if_fail (EMPATHY_IS_AVATAR_IMAGE (avatar_image)); if (priv->pixbuf) { g_object_unref (priv->pixbuf); priv->pixbuf = NULL; } if (avatar) { priv->pixbuf = empathy_pixbuf_from_data ((gchar *) avatar->data, avatar->len); } if (!priv->pixbuf) { gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), "stock_person", GTK_ICON_SIZE_DIALOG); return; } scaled_pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_SMALL); gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled_pixbuf); if (scaled_pixbuf != priv->pixbuf) { gtk_widget_set_tooltip_text (GTK_WIDGET (avatar_image), _("Click to enlarge")); } else { gtk_widget_set_tooltip_text (GTK_WIDGET (avatar_image), NULL); } g_object_unref (scaled_pixbuf); }
static void curl_pixbuf_update (void) { GdkPixbuf *pixbuf; gint index; switch (curl.edge) { case CURL_EDGE_LOWER_RIGHT: index = 0; break; case CURL_EDGE_LOWER_LEFT: index = 1; break; case CURL_EDGE_UPPER_RIGHT: index = 2; break; case CURL_EDGE_UPPER_LEFT: index = 3; break; default: return; } index += curl.orientation * 4; pixbuf = gdk_pixbuf_new_from_inline (-1, curl_pixbufs[index], FALSE, NULL); gtk_image_set_from_pixbuf (GTK_IMAGE (curl_image), pixbuf); g_object_unref (pixbuf); }
void wxTaskBarIcon::Private::size_allocate(int width, int height) { int size = height; EggTrayIcon* icon = EGG_TRAY_ICON(m_eggTrayIcon); if (egg_tray_icon_get_orientation(icon) == GTK_ORIENTATION_VERTICAL) size = width; if (m_size == size) return; m_size = size; int w = m_bitmap.GetWidth(); int h = m_bitmap.GetHeight(); if (w > size || h > size) { if (w > size) w = size; if (h > size) h = size; GdkPixbuf* pixbuf = gdk_pixbuf_scale_simple(m_bitmap.GetPixbuf(), w, h, GDK_INTERP_BILINEAR); GtkImage* image = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(m_eggTrayIcon))); gtk_image_set_from_pixbuf(image, pixbuf); g_object_unref(pixbuf); } }
/* Set notification icon */ void set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf) { WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata"); g_assert(windata != NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), pixbuf); if (pixbuf != NULL) { int pixbuf_width = gdk_pixbuf_get_width(pixbuf); gtk_widget_show(windata->icon); gtk_widget_set_size_request(windata->iconbox, MAX(BODY_X_OFFSET, pixbuf_width), -1); } else { gtk_widget_hide(windata->icon); gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1); } }
static void album_art_received (GObject *object, GAsyncResult *result, gpointer user_data) { IdoMediaPlayerMenuItem *self = user_data; GdkPixbuf *pixbuf; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_stream_finish (result, &error); if (pixbuf == NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("unable to fetch album art: %s", error->message); g_error_free (error); return; } gtk_image_set_from_pixbuf (GTK_IMAGE (self->album_art), pixbuf); g_object_unref (pixbuf); }
static void cb_gimmix_covers_plugin_cover_file_preview (GtkFileChooser *file_chooser, gpointer data) { GtkWidget *preview = NULL; char *filename = NULL; GdkPixbuf *pixbuf = NULL; gboolean have_preview; preview = GTK_WIDGET (data); filename = gtk_file_chooser_get_preview_filename (file_chooser); pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL); have_preview = (pixbuf != NULL); g_free (filename); gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf); if (pixbuf != NULL) { g_object_unref (pixbuf); } gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview); return; }
void wxAnimationCtrl::OnTimer(wxTimerEvent &ev) { wxASSERT(m_iter != NULL); // gdk_pixbuf_animation_iter_advance() will automatically restart // the animation, if necessary and we have no way to know !! if (gdk_pixbuf_animation_iter_advance(m_iter, NULL)) { // start a new one-shot timer int n = gdk_pixbuf_animation_iter_get_delay_time(m_iter); if (n >= 0) m_timer.Start(n, true); gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), gdk_pixbuf_animation_iter_get_pixbuf(m_iter)); } else { // no need to update the m_widget yet m_timer.Start(10, true); } }
/* desktopicon_set_icon */ static void _desktopicon_set_icon(DesktopIcon * desktopicon, GdkPixbuf * icon) { GdkPixbuf * i = NULL; if(icon == NULL) return; if(gdk_pixbuf_get_width(icon) != DESKTOPICON_ICON_SIZE && gdk_pixbuf_get_height(icon) != DESKTOPICON_ICON_SIZE && (i = gdk_pixbuf_scale_simple(icon, DESKTOPICON_ICON_SIZE, DESKTOPICON_ICON_SIZE, #ifdef EMBEDDED GDK_INTERP_NEAREST #else GDK_INTERP_HYPER #endif )) != NULL) icon = i; gtk_image_set_from_pixbuf(GTK_IMAGE(desktopicon->image), icon); if(i != NULL) g_object_unref(i); }
static void service_set_state(GtkService *service) { GtkServicePrivate *priv = service->priv; const struct connman_ipv4 *ipv4; enum connman_state state; GdkPixbuf *image = NULL; const char *ip = NULL; const char *info; if (connman_service_is_connected(service->path) == FALSE) { gtk_widget_set_tooltip_text((GtkWidget *)priv->name, ""); return; } ipv4 = connman_service_get_ipv4(service->path); if (ipv4 == NULL) { const struct connman_ipv6 *ipv6; ipv6 = connman_service_get_ipv6(service->path); if (ipv6 != NULL) ip = ipv6->address; } else ip = ipv4->address; if (ip == NULL) ip = ""; gtk_widget_set_tooltip_text((GtkWidget *)priv->name, ip); state = connman_service_get_state(service->path); cui_theme_get_state_icone_and_info(state, &image, &info); if (image == NULL) return; gtk_widget_set_visible((GtkWidget *)priv->state, TRUE); gtk_widget_set_tooltip_text((GtkWidget *)priv->state, info); gtk_image_set_from_pixbuf(priv->state, image); }
static void prefs_themes_display_theme_info(ThemesData *tdata, const ThemeInfo *info) { ThemesPage *theme = tdata->page; gchar *save_prefs_path; gint i; SET_LABEL_TEXT_UTF8(theme->name, info->name); SET_LABEL_TEXT_UTF8(theme->author, info->author); SET_LABEL_TEXT_UTF8(theme->url, info->url); SET_LABEL_TEXT_UTF8(theme->status, info->status); save_prefs_path = prefs_common.pixmap_theme_path; prefs_common.pixmap_theme_path = tdata->displayed; for (i = 0; i < PREVIEW_ICONS; ++i) { stock_pixbuf_gdk(prefs_themes_icons[i], &(theme->pixbufs[i])); gtk_image_set_from_pixbuf(GTK_IMAGE(theme->icons[i]), theme->pixbufs[i]); } prefs_common.pixmap_theme_path = save_prefs_path; prefs_themes_update_buttons(tdata); }
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); }
void clcon(GtkWidget *widget, gpointer data) { //connect or disconnect if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget))) { /* If control reaches here, the toggle button is down */ if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) puts("socket() failed"); /* Establish the connection to the server */ if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) puts("connect() failed"); gtk_button_set_label((GtkButton *) widget, "connected"); } else { /* If control reaches here, the toggle button is up */ send(sock, "exit\0", 5, 0); closesocket(sock); gtk_button_set_label((GtkButton *) widget, "disconnected"); gtk_widget_hide_all(gamebox); gtk_widget_show_all(logbox); pixbuf = gdk_pixbuf_new_from_file_at_scale_utf8("pic/0.jpg", 500, 500, TRUE, error); gtk_image_set_from_pixbuf((GtkImage *) image, pixbuf); } return; }
void onUpdatePreview() { // Disable preview because we don't know if we will be able to // load/generate the preview successfully. gtk_file_chooser_set_preview_widget_active(m_chooser, false); const char* fn = gtk_file_chooser_get_filename(m_chooser); if (fn && base::is_file(fn)) { GError* err = nullptr; GdkPixbuf* previewPixbuf = gdk_pixbuf_new_from_file_at_scale(fn, 256, 256, true, &err); if (previewPixbuf) { gtk_image_set_from_pixbuf(GTK_IMAGE(m_preview), previewPixbuf); g_object_unref(previewPixbuf); // Now we can enable the preview panel as the preview was // generated. gtk_file_chooser_set_preview_widget_active(m_chooser, true); } if (err) g_error_free(err); } }
void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call, gboolean val){ GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call); GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview"); //GtkWidget *mic=linphone_gtk_get_widget(callview,"incall_mic_icon"); GtkWidget *spk=linphone_gtk_get_widget(callview,"incall_spk_icon"); GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel"); GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel"); GdkPixbuf *pbuf; //gtk_image_set_from_pixbuf(GTK_IMAGE(mic),(pbuf=create_pixbuf("mic_active.png"))); //g_object_unref(pbuf); if (val){ gtk_image_set_from_pixbuf(GTK_IMAGE(spk),(pbuf=create_pixbuf("speaker.png"))); g_object_unref(pbuf); linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call); linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call); gtk_widget_show_all(audio_view); }else{ linphone_gtk_uninit_audio_meter(mic_level); linphone_gtk_uninit_audio_meter(spk_level); gtk_widget_hide(audio_view); } }
gboolean target_drag_drop (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time) { g_print("drop\n"); have_drag = FALSE; gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed); if (gdk_drag_context_list_targets (context)) { gtk_drag_get_data (widget, context, GDK_POINTER_TO_ATOM (gdk_drag_context_list_targets (context)->data), time); return TRUE; } return FALSE; }
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 do_icons_to_add (void) { while (icons_to_add) { IconToAdd *icon_to_add = icons_to_add->data; icons_to_add = g_list_delete_link (icons_to_add, icons_to_add); if (icon_to_add->stock_id) { gtk_image_set_from_stock ( GTK_IMAGE (icon_to_add->image), icon_to_add->stock_id, icon_to_add->icon_size); } else if (icon_to_add->gicon) { gtk_image_set_from_gicon ( GTK_IMAGE (icon_to_add->image), icon_to_add->gicon, icon_to_add->icon_size); } else { g_assert (icon_to_add->pixbuf); gtk_image_set_from_pixbuf ( GTK_IMAGE (icon_to_add->image), icon_to_add->pixbuf); g_signal_connect (icon_to_add->image, "style-set", G_CALLBACK (menu_item_style_set), GINT_TO_POINTER (icon_to_add->icon_size)); g_object_unref (icon_to_add->pixbuf); } if (icon_to_add->gicon) g_object_unref (icon_to_add->gicon); g_object_unref (icon_to_add->image); g_free (icon_to_add); } }
static void vwin_img_draw(void) { struct fp_minutia **minlist; unsigned char *rgbdata; GdkPixbuf *pixbuf; gchar *tmp; int nr_minutiae; int width; int height; if (!img_normal || !img_bin) return; minlist = fp_img_get_minutiae(img_normal, &nr_minutiae); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vwin_radio_normal))) rgbdata = img_to_rgbdata(img_normal); else rgbdata = img_to_rgbdata(img_bin); width = fp_img_get_width(img_normal); height = fp_img_get_height(img_normal); gtk_widget_set_size_request(vwin_verify_img, width, height); tmp = g_strdup_printf("Detected %d minutiae.", nr_minutiae); gtk_label_set_text(GTK_LABEL(vwin_minutiae_cnt), tmp); g_free(tmp); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vwin_show_minutiae))) plot_minutiae(rgbdata, width, height, minlist, nr_minutiae); pixbuf = gdk_pixbuf_new_from_data(rgbdata, GDK_COLORSPACE_RGB, FALSE, 8, width, height, width * 3, pixbuf_destroy, NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(vwin_verify_img), pixbuf); g_object_unref(pixbuf); gtk_widget_set_sensitive(vwin_img_save_btn, TRUE); }
static void gdict_applet_size_allocate (GtkWidget *widget, GdkRectangle *allocation) { GdictApplet *applet = GDICT_APPLET (widget); GdictAppletPrivate *priv = applet->priv; guint new_size; if (priv->orient == GTK_ORIENTATION_HORIZONTAL) new_size = allocation->height; else new_size = allocation->width; if (priv->size != new_size) { priv->size = new_size; gtk_image_set_pixel_size (GTK_IMAGE (priv->image), priv->size - 10); /* re-scale the icon, if it was found */ if (priv->icon) { GdkPixbuf *scaled; scaled = gdk_pixbuf_scale_simple (priv->icon, priv->size - 5, priv->size - 5, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled); g_object_unref (scaled); } } if (GTK_WIDGET_CLASS (gdict_applet_parent_class)->size_allocate) GTK_WIDGET_CLASS (gdict_applet_parent_class)->size_allocate (widget, allocation); }