//----- we must make sure that the images for the status icon be there int gx_pixmap_check() { struct stat my_stat; string gx_pix = gx_pixmap_dir + "Jc_Gui.png"; string warn_pix = gx_pixmap_dir + "Jc_Gui-warn.png"; if ((stat(gx_pix.c_str(), &my_stat) != 0) || (stat(warn_pix.c_str(), &my_stat) != 0)) { gx_print_error("Pixmap Check", " cannot find installed pixmaps! giving up ..."); // giving up return 1; } GtkWidget *ibf = gtk_image_new_from_file (gx_pix.c_str()); gx_gui::ib = gtk_image_get_pixbuf (GTK_IMAGE(ibf)); GtkWidget *stir = gtk_image_new_from_file (warn_pix.c_str()); gx_gui::ibr = gtk_image_get_pixbuf (GTK_IMAGE(stir)); return 0; }
static void button_click2(GtkWidget * widget, gpointer data) { if(strcmp("button.zoomp", (char *)data) == 0) { GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); double h = gdk_pixbuf_get_height(pixbuf), w = gdk_pixbuf_get_width(pixbuf); if(h < config->maxzoom || w < config->maxzoom) { GdkPixbuf * rpixbuf = gdk_pixbuf_scale_simple(dimage, h * config->zooms, w * config->zooms, config->interp); gtk_image_set_from_pixbuf(GTK_IMAGE(image), rpixbuf); g_object_unref(rpixbuf); } } else if(strcmp("button.zoomm", (char *)data) == 0) { GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); double h = gdk_pixbuf_get_height(pixbuf), w = gdk_pixbuf_get_width(pixbuf); if(h > config->minzoom || w > config->minzoom) { GdkPixbuf * rpixbuf = gdk_pixbuf_scale_simple(dimage, h / config->zooms, w / config->zooms, config->interp); gtk_image_set_from_pixbuf(GTK_IMAGE(image), rpixbuf); g_object_unref(rpixbuf); } } else if(strcmp("button.zoome", (char *)data) == 0) { GdkPixbuf * rpixbuf = gdk_pixbuf_scale_simple(dimage, 128 * config->stdzoom, 128 * config->stdzoom, config->interp); gtk_image_set_from_pixbuf(GTK_IMAGE(image), rpixbuf); g_object_unref(rpixbuf); } }
void ISFSetupWin::update_factory_list_store (void) { GtkTreeIter iter; GdkPixbuf *icon = NULL, *icon2 = NULL; GtkWidget *pix = NULL, *pix2 = NULL; _display_selected_items = 0; pix = gtk_image_new_from_file (ISE_SETUP_ICON_FILE); icon = gtk_image_get_pixbuf (GTK_IMAGE (pix)); pix2 = gtk_image_new_from_file (ISE_HELP_ICON_FILE); icon2 = gtk_image_get_pixbuf (GTK_IMAGE (pix2)); String _app_name = gtk_combo_box_get_active_text ((GtkComboBox *) _combo_app); gtk_list_store_clear (_factory_list_store); std::vector<String> f_show; for (MapStringVectorSizeT::iterator it = _groups.begin (); it != _groups.end (); ++it) { String lang_name; lang_name = scim_get_language_name (it->first); if (std::find (_disabled_langs.begin (), _disabled_langs.end (), lang_name) == _disabled_langs.end ()) { for (size_t i = 0; i < it->second.size (); i++) { // protect from add the same ise more than once in case of multiple langs.-->f_show list if (std::find (f_show.begin (), f_show.end (), _uuids[it->second[i]]) == f_show.end ()) { gtk_list_store_append (_factory_list_store, &iter); gtk_list_store_set (_factory_list_store, &iter, FACTORY_LIST_NAME, _names[it->second[i]].c_str (), FACTORY_LIST_MODULE_NAME, _module_names[it->second[i]].c_str (), FACTORY_LIST_UUID, _uuids[it->second[i]].c_str (), FACTORY_LIST_TYPE, (gint)_modes[it->second[i]], FACTORY_LIST_OPTION_PIX, icon, FACTORY_LIST_HELP_PIX,icon2, -1); f_show.push_back (_uuids[it->second[i]]); if (std::find (_disabled_ise_map[_app_name].begin (), _disabled_ise_map[_app_name].end (), _uuids[it->second[i]]) ==_disabled_ise_map[_app_name].end ()) { gtk_list_store_set (_factory_list_store, &iter, FACTORY_LIST_ENABLE, true, -1); _display_selected_items++; } else { gtk_list_store_set (_factory_list_store, &iter, FACTORY_LIST_ENABLE, false, -1); } } } } } if (icon) { gdk_pixbuf_unref (icon); icon = 0; } if (icon2) { gdk_pixbuf_unref (icon2); icon2 = 0; } }
/*--------------------------------------------------------------------------*/ static void s_ctk_draw_init(void) { GtkWidget *image; image = gtk_image_new_from_file(CTK_GTKSIM_SERVICE_PNGDIR "/background.png"); background = gtk_image_get_pixbuf(GTK_IMAGE(image)); image = gtk_image_new_from_file(CTK_GTKSIM_SERVICE_PNGDIR "/windowborder.png"); windowborder = gtk_image_get_pixbuf(GTK_IMAGE(image)); image = gtk_image_new_from_file(CTK_GTKSIM_SERVICE_PNGDIR "/menubar.png"); menubar = gtk_image_get_pixbuf(GTK_IMAGE(image)); ctk_gtksim_init(); ctk_gtksim_draw_init(); blue = get_color(0, 0, 0xffff); white = get_color(0xffff, 0xffff, 0xffff); lightgray = get_color(0xefff, 0xefff, 0xefff); midgray = get_color(0xdfff, 0xdfff, 0xdfff); darkgray = get_color(0xcfff, 0xcfff, 0xcfff); ddarkgray = get_color(0xafff, 0xafff, 0xafff); black = get_color(0, 0, 0); }
static gboolean prefs_custom_header_selected(GtkTreeSelection *selector, GtkTreeModel *model, GtkTreePath *path, gboolean currently_selected, gpointer data) { GtkTreeIter iter; CustomHeader *ch; GtkImage *preview; GdkPixbuf *pixbuf; CustomHeader default_ch = { 0, "", NULL }; if (currently_selected) return TRUE; if (!gtk_tree_model_get_iter(model, &iter, path)) return TRUE; gtk_tree_model_get(model, &iter, CUSTHDR_DATA, &ch, -1); if (!ch) ch = &default_ch; ENTRY_SET_TEXT(customhdr.hdr_entry, ch->name); ENTRY_SET_TEXT(customhdr.val_entry, ch->value); if (!strcmp2("Face",ch->name)) { preview = GTK_IMAGE(face_get_from_header (ch->value)); pixbuf = gtk_image_get_pixbuf(preview); gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf); gtk_widget_show(customhdr.preview); #if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink (G_OBJECT(preview)); #else gtk_object_ref (G_OBJECT(preview)); gtk_object_sink (G_OBJECT(preview)); #endif } #if HAVE_LIBCOMPFACE else if (!strcmp2("X-Face", ch->name)) { preview = GTK_IMAGE(xface_get_from_header(ch->value)); pixbuf = gtk_image_get_pixbuf(preview); gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf); gtk_widget_show(customhdr.preview); #if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink (G_OBJECT(preview)); #else gtk_object_ref (G_OBJECT(preview)); gtk_object_sink (G_OBJECT(preview)); #endif } #endif else { gtk_widget_hide(customhdr.preview); } return TRUE; }
void load_icon() { GtkWidget *img_record, *img_record_g, *img_stop, *img_pause, *img_refresh; GtkWidget *img_leftarrow, *img_rightarrow, *img_status_ok, *img_status_fail; char icon_file[FILENAME_MAX]; sprintf(icon_file, "%s/%s", data->icon_directory, "record-64.png"); img_record = gtk_image_new_from_file(icon_file); data->record_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_record)); sprintf(icon_file, "%s/%s", data->icon_directory, "record_g-64.png"); img_record_g = gtk_image_new_from_file(icon_file); data->record_g_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_record_g)); sprintf(icon_file, "%s/%s", data->icon_directory, "pause-64.png"); img_pause = gtk_image_new_from_file(icon_file); data->pause_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_pause)); sprintf(icon_file, "%s/%s", data->icon_directory, "stop-64.png"); img_stop = gtk_image_new_from_file(icon_file); data->stop_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_stop)); sprintf(icon_file, "%s/%s", data->icon_directory, "refresh-64.png"); img_refresh = gtk_image_new_from_file(icon_file); data->refresh_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_refresh)); sprintf(icon_file, "%s/%s", data->icon_directory, "rightarrow-64.png"); img_rightarrow = gtk_image_new_from_file(icon_file); data->rightarrow_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_rightarrow)); sprintf(icon_file, "%s/%s", data->icon_directory, "leftarrow-64.png"); img_leftarrow = gtk_image_new_from_file(icon_file); data->leftarrow_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_leftarrow)); sprintf(icon_file, "%s/%s", data->icon_directory, "status-ok-64.png"); img_status_ok = gtk_image_new_from_file(icon_file); data->status_ok_icon_64 = gtk_image_get_pixbuf(GTK_IMAGE (img_status_ok)); sprintf(icon_file, "%s/%s", data->icon_directory, "status-fail-64.png"); img_status_fail = gtk_image_new_from_file(icon_file); data->status_fail_icon_64 = gtk_image_get_pixbuf( GTK_IMAGE (img_status_fail)); data->status_ok_icon_motor = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_ok_icon_64, 22, 22, GDK_INTERP_HYPER))); data->status_fail_icon_motor = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_fail_icon_64, 22, 22, GDK_INTERP_HYPER))); data->status_ok_icon_gps = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_ok_icon_64, 22, 22, GDK_INTERP_HYPER))); data->status_fail_icon_gps = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_fail_icon_64, 22, 22, GDK_INTERP_HYPER))); //data->status_ok_icon_flying = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_ok_icon_64, 22, 22, GDK_INTERP_HYPER))); //data->status_fail_icon_flying = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->status_fail_icon_64, 22, 22, GDK_INTERP_HYPER))); data->record_icon = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->record_icon_64, 30, 30, GDK_INTERP_HYPER))); data->record_g_icon = GTK_WIDGET (gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->record_g_icon_64, 30, 30, GDK_INTERP_HYPER))); }
/* Dump the given image into the given GtkImage, scaling it to the * provided sizes. Enforces aspect ratio. */ void fill_image(GdkPixbuf *original, GtkImage *target, int t_width, int t_height, int force) { GdkPixbuf *img; GtkImage *oimg; int width, height; double t_ratio, ratio; width = gdk_pixbuf_get_width(original); height = gdk_pixbuf_get_height(original); ratio = (double)height/(double)width; t_ratio = (double)t_height/(double)t_width; printf("%d %d -> %d %d\n", width, height, t_width, t_height); printf("%lf and %lf\n", ratio, t_ratio); if (ratio > t_ratio) { // wide frame, relative to image printf("wide frame: "); width = t_height / ratio; height = t_height; printf("h = %d, w = %d\n", height, width); } else { // narrow frame, relative to image printf("narrow frame: "); height = t_width * ratio; width = t_width; } oimg = gtk_image_get_pixbuf(target); if (width == gdk_pixbuf_get_width(oimg) && height == gdk_pixbuf_get_height(oimg) && !force) { // image is already sized appropriately return; } img = gdk_pixbuf_scale_simple(original, width, height, GDK_INTERP_BILINEAR); oimg = gtk_image_get_pixbuf(target); if (width == gdk_pixbuf_get_width(oimg) && height == gdk_pixbuf_get_height(oimg) && !force) { // image is already sized appropriately return; } gtk_image_set_from_pixbuf(target, img); g_object_unref(img); return; }
void init_mood_dialog(struct mood_dialog *s_diag) { GtkTreeIter empty_iter; GdkPixbuf *empty_pixbuf; GtkWidget *empty_image; const gchar *empty_mood; gchar *empty_path; PurpleMood *mood = get_global_moods(); if(!s_diag->global_moods) s_diag->global_moods = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); /* add empty mood to mood list */ empty_mood = ""; empty_path = get_mood_icon_path(empty_mood); empty_image = gtk_image_new_from_file(empty_path); empty_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(empty_image)); g_free(empty_path); gtk_list_store_append(s_diag->list_store, &empty_iter); gtk_list_store_set(s_diag->list_store, &empty_iter, MOODICON_COLUMN, empty_pixbuf, MOOD_COLUMN, _("None"), -1); g_hash_table_insert(s_diag->global_moods, (gpointer)_("None"), (gpointer)empty_mood); for(; mood->mood ; mood++) { if(!mood->mood || !mood->description) continue; GtkTreeIter iter; GtkWidget *image; GdkPixbuf *pixbuf; gchar *path = get_mood_icon_path(mood->mood); g_hash_table_insert(s_diag->global_moods, (gpointer)_(mood->description), (gpointer)mood->mood); image = gtk_image_new_from_file(path); pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); g_free(path); gtk_list_store_append(s_diag->list_store, &iter); gtk_list_store_set(s_diag->list_store, &iter, MOODICON_COLUMN, pixbuf, MOOD_COLUMN, _(mood->description), -1); } }
static void about_dialog(GtkWidget *w, gpointer data) { const char *logo_property = NULL; GdkPixbuf *logo = NULL; if (need_icon) { #if defined __linux__ || defined __APPLE__ GtkWidget *image = gtk_image_new_from_file("subsurface.svg"); #elif defined WIN32 GtkWidget *image = gtk_image_new_from_file("subsurface.ico"); #endif if (image) { logo = gtk_image_get_pixbuf(GTK_IMAGE(image)); logo_property = "logo"; } } gtk_show_about_dialog(NULL, "program-name", "SubSurface", "comments", "Half-arsed divelog software in C", "license", "GPLv2", "version", VERSION_STRING, "copyright", "Linus Torvalds 2011", "logo-icon-name", "subsurface", /* Must be last: */ logo_property, logo, NULL); }
int fill_stats(ImageInfo *ii) { int i, j; const int w = 12; // width of the little "scale" image unsigned char *histogram_scale_data = MALLOC(sizeof(unsigned char)*256*w*3); for (i=0; i<256; ++i) { for (j=0; j<w*3; ++j) { histogram_scale_data[j+i*w*3] = (unsigned char)i; } } GdkPixbuf *pb = gdk_pixbuf_new_from_data(histogram_scale_data, GDK_COLORSPACE_RGB, FALSE, 8, w, 256, w*3, destroy_pb_data, NULL); GtkWidget *img = get_widget_checked("histogram_scale_image"); GdkPixbuf *old_pb = gtk_image_get_pixbuf(GTK_IMAGE(img)); if (old_pb) g_object_unref(old_pb); gtk_image_set_from_pixbuf(GTK_IMAGE(img), pb); fill_stats_label(ii); pop_hist(ii); disable_map_tabs(ii); return TRUE; }
void _select(GtkWidget *eventbox,gint R,gint V,gint B) { GdkPixbuf *pixbuf; gint w,h; guint rowstride, n_channels,x,y,col; guchar *pixels, *p; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE((GtkWidget*)(gtk_container_get_children(GTK_CONTAINER(eventbox))->data))); w = gdk_pixbuf_get_width(pixbuf); h = gdk_pixbuf_get_height(pixbuf); rowstride = gdk_pixbuf_get_rowstride(pixbuf); pixels = gdk_pixbuf_get_pixels(pixbuf); n_channels = gdk_pixbuf_get_n_channels(pixbuf); for(x=0;x<w;x++) { for(y=0;y<h;y++) { p = pixels + y * rowstride + x * n_channels; //col = 0.29*p[0] + 0.7*p[1] + 0.11*p[2]; p[0]*=R; p[1]*=V; p[2]*=B; } } gtk_image_set_from_pixbuf(GTK_IMAGE((GtkWidget*)(gtk_container_get_children(GTK_CONTAINER(eventbox))->data)),pixbuf); }
void on_reactlist_start(struct s_gui_data *gui_data) { gtk_action_set_label(gui_data->action_startPause, "Stop"); gtk_status_icon_set_from_pixbuf(gui_data->systrayIcon, gtk_image_get_pixbuf(gui_data->image_started)); gtk_image_set_from_icon_name(gui_data->image_startStop, ICON_NAME_STOP, GTK_ICON_SIZE_BUTTON); start_reading_event_log(gui_data); }
static gboolean button_press_callback (GtkWidget *event_box, GdkEventButton *event, gpointer data) { gint ev_width, ev_height, im_width, im_height; GdkWindow *ev_w = gtk_widget_get_parent_window(event_box); ev_width = gdk_window_get_width(ev_w); ev_height = gdk_window_get_height(ev_w); GdkPixbuf *pix = gtk_image_get_pixbuf(data); if (!pix) return TRUE; im_width = gdk_pixbuf_get_width(pix); im_height = gdk_pixbuf_get_height(pix); pic_button_x1 = event->x - (ev_width - im_width)/2; pic_button_y1 = event->y - (ev_height - im_height)/2; pic_button_x2 = pic_button_x1; pic_button_y2 = pic_button_y1; pic_button_drag = TRUE; return TRUE; }
static void pidgin_mini_dialog_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { PidginMiniDialog *self = PIDGIN_MINI_DIALOG(object); PidginMiniDialogPrivate *priv = PIDGIN_MINI_DIALOG_GET_PRIVATE(self); switch (property_id) { case PROP_TITLE: g_value_set_string(value, gtk_label_get_text(priv->title)); break; case PROP_DESCRIPTION: g_value_set_string(value, gtk_label_get_text(priv->desc)); break; case PROP_ICON_NAME: { gchar *icon_name = NULL; GtkIconSize size; gtk_image_get_stock(priv->icon, &icon_name, &size); g_value_set_string(value, icon_name); break; } case PROP_CUSTOM_ICON: g_value_set_object(value, gtk_image_get_pixbuf(priv->icon)); break; case PROP_ENABLE_DESCRIPTION_MARKUP: g_value_set_boolean(value, priv->enable_description_markup); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static GdkPixbuf * get_image_pixbuf (GtkImage *image) { const gchar *icon_name; GtkIconSize size; GtkIconTheme *icon_theme; int width; switch (gtk_image_get_storage_type (image)) { case GTK_IMAGE_PIXBUF: return g_object_ref (gtk_image_get_pixbuf (image)); case GTK_IMAGE_ICON_NAME: gtk_image_get_icon_name (image, &icon_name, &size); icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (image))); gtk_icon_size_lookup (size, &width, NULL); return gtk_icon_theme_load_icon (icon_theme, icon_name, width, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); default: g_warning ("Image storage type %d not handled", gtk_image_get_storage_type (image)); return NULL; } }
void cb_open (GtkWidget *p_widget) { GtkWidget *p_dialog; p_dialog = gtk_file_chooser_dialog_new ("Image selection", NULL, GTK_FILE_CHOOSER_ACTION_OPEN, ("_Cancel"), GTK_RESPONSE_CANCEL, ("_Open"), GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run (GTK_DIALOG (p_dialog)) == GTK_RESPONSE_ACCEPT) { //file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (p_dialog)); file_name = g_file_get_path(gtk_file_chooser_get_file(GTK_FILE_CHOOSER(p_dialog))); if(pImage) gtk_widget_destroy(pImage); GdkPixbuf *pBuf = gdk_pixbuf_new_from_file_at_scale (file_name,500,330,TRUE,NULL); pImage = gtk_image_new_from_pixbuf(pBuf); g_object_unref (pBuf); //permet de centrer l'image GdkPixbuf *pBufFcd = gtk_image_get_pixbuf (GTK_IMAGE(pImage)); int w = gdk_pixbuf_get_width(pBufFcd); int h = gdk_pixbuf_get_height(pBufFcd); gtk_layout_put(GTK_LAYOUT(layout), pImage, 273-(w/2), 196-(h/2)); gtk_widget_show_all(pImage); //g_free(file_name), file_name=NULL; } gtk_widget_destroy (p_dialog); (void)p_widget; }
void chat_init(void) { warn_if_fail(win_main != NULL); /* wskazniki do tego co zwraca create_pixmap() mozna stracic, bo i tak sa potrzebne przez caly program */ typing_off_pixbuf = gtk_image_get_pixbuf( GTK_IMAGE(create_pixmap(NULL, "glen/typing-off.png"))); typing_on_pixbuf = gtk_image_get_pixbuf( GTK_IMAGE(create_pixmap(NULL, "glen/typing-on.png"))); blink_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(create_pixmap(NULL, "glen/blink.png"))); tooltips = gtk_tooltips_new(); g_assert(tooltips != NULL); }
static void dnd_hints_realized_cb(GtkWidget *window, GtkWidget *pix) { GdkPixbuf *pixbuf; cairo_surface_t *surface; cairo_region_t *region; cairo_t *cr; pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(pix)); surface = cairo_image_surface_create(CAIRO_FORMAT_A1, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); cr = cairo_create(surface); gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); cairo_paint(cr); cairo_destroy(cr); region = gdk_cairo_region_create_from_surface(surface); gtk_widget_shape_combine_region(window, region); cairo_region_destroy(region); cairo_surface_destroy(surface); }
int main (int argc, char**argv) { #ifdef ENABLE_NLS /* Initialize the i18n stuff */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif GtkWidget *main_window; GtkWidget *icon; GtkWidget *tbo_startup; gtk_init (&argc, &argv); main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_set_size_request (main_window, 800, 500); icon = gtk_image_new_from_file (DATA_DIR "/icon.png"); gtk_window_set_icon (GTK_WINDOW (main_window), gtk_image_get_pixbuf (GTK_IMAGE (icon))); gtk_widget_destroy (icon); tbo_startup = tbo_startup_new (); gtk_container_add (GTK_CONTAINER (main_window), tbo_startup); gtk_widget_show_all (main_window); gtk_main (); return 0; }
static void rotate_cb (GtkWidget *w, gint type) { GdkPixbuf *new_pb = NULL; GdkPixbuf *pb = gtk_image_get_pixbuf (GTK_IMAGE (picture)); if (!pb) { g_printerr ("picture: can't get pixbuf\n"); return; } switch (type) { case ROTATE_LEFT: new_pb = gdk_pixbuf_rotate_simple (pb, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE); break; case ROTATE_RIGHT: new_pb = gdk_pixbuf_rotate_simple (pb, GDK_PIXBUF_ROTATE_CLOCKWISE); break; case ROTATE_FLIP_VERT: new_pb = gdk_pixbuf_flip (pb, FALSE); break; case ROTATE_FLIP_HOR: new_pb = gdk_pixbuf_flip (pb, TRUE); break; } if (new_pb) { gtk_image_set_from_pixbuf (GTK_IMAGE (picture), new_pb); g_object_unref (pb); } }
static GdkPixbuf * get_pixbuf_from_icon(SexyIconEntry *entry, SexyIconEntryPosition icon_pos) { GdkPixbuf *pixbuf = NULL; gchar *stock_id; SexyIconInfo *icon_info = &entry->priv->icons[icon_pos]; GtkIconSize size; switch (gtk_image_get_storage_type(GTK_IMAGE(icon_info->icon))) { case GTK_IMAGE_PIXBUF: pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(icon_info->icon)); g_object_ref(pixbuf); break; case GTK_IMAGE_STOCK: gtk_image_get_stock(GTK_IMAGE(icon_info->icon), &stock_id, &size); pixbuf = gtk_widget_render_icon(GTK_WIDGET(entry), stock_id, size, NULL); break; default: return NULL; } return pixbuf; }
static gboolean fb_button_enter (GtkImage *widget, GdkEventCrossing *event) { GdkPixbuf *dark, *light; int i; guint hicolor; guchar *src, *up, extra[3]; ENTER; if (gtk_image_get_storage_type(widget) != GTK_IMAGE_PIXBUF) RET(TRUE); light = g_object_get_data(G_OBJECT(widget), "light"); dark = gtk_image_get_pixbuf(widget); if (!light) { hicolor = (gint) g_object_get_data(G_OBJECT(widget), "hicolor"); light = gdk_pixbuf_add_alpha(dark, FALSE, 0, 0, 0); if (!light) RET(TRUE); src = gdk_pixbuf_get_pixels (light); for (i = 2; i >= 0; i--, hicolor >>= 8) extra[i] = hicolor & 0xFF; for (up = src + gdk_pixbuf_get_height(light) * gdk_pixbuf_get_rowstride (light); src < up; src+=4) { if (src[3] == 0) continue; for (i = 0; i < 3; i++) { if (src[i] + extra[i] >= 255) src[i] = 255; else src[i] += extra[i]; } } g_object_set_data_full (G_OBJECT(widget), "light", light, g_object_unref); }
static gboolean expose_callback (GtkWidget *event_box, GdkEventButton *, TSignalData *sigdata) { cairo_t *cr; if (sigdata->event_box != NULL) cr = gdk_cairo_create (GDK_DRAWABLE (sigdata->event_box->window)); else { cr = gdk_cairo_create (GDK_DRAWABLE (event_box->window)); sigdata->event_box = event_box; } if (sigdata->image != NULL) { GdkPixbuf *pxbf = gtk_image_get_pixbuf(GTK_IMAGE(sigdata->image)); gdk_cairo_set_source_pixbuf (cr, pxbf, 0,0); cairo_paint (cr); draw_grid(cr, sigdata->idata); } return TRUE; }
static void progressive_updated_callback (GdkPixbufLoader *loader, gint x, gint y, gint width, gint height, gpointer data) { GtkWidget *image; GdkPixbuf *pixbuf; image = GTK_WIDGET (data); /* We know the pixbuf inside the GtkImage has changed, but the image * itself doesn't know this; so give it a hint by setting the pixbuf * again. Queuing a redraw used to be sufficient, but nowadays GtkImage * uses GtkIconHelper which caches the pixbuf state and will just redraw * from the cache. */ pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (image)); g_object_ref (pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); g_object_unref (pixbuf); }
static void headerview_save_contact_pic (HeaderView *headerview, MsgInfo *msginfo) { #ifndef USE_ALT_ADDRBOOK gchar *filename = NULL; GError *error = NULL; GdkPixbuf *picture = NULL; if (!gtk_widget_get_visible(headerview->hbox)) return; if (headerview->image) { picture = gtk_image_get_pixbuf(GTK_IMAGE(headerview->image)); } filename = addrindex_get_picture_file(msginfo->from); if (!filename) return; if (!is_file_exist(filename)) { gdk_pixbuf_save(picture, filename, "png", &error, NULL); if (error) { g_warning("Failed to save image: %s", error->message); g_error_free(error); } } g_free(filename); #else /* new address book */ #endif }
extern void on_help_about_activate(void) { GtkWidget *about; GdkPixbuf *logo; const gchar *authors[] = {"Sebastien Tricaud", "Jerome Marrec", "Frederic Motte", "Alastair Porter", NULL}; const gchar *artists[] = {"Damien Cante (logos)", "Audrey Maurin (pixmaps from lilypond)", NULL}; gchar *filename; filename = get_file_from_data_dir("pixmaps/gscore.xpm"); logo = gtk_image_get_pixbuf((GtkImage *)gtk_image_new_from_file(filename)); about = gtk_about_dialog_new(); gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), "Gscore"); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), VERSION); gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), logo); gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), "Copyright (C) Sebastien Tricaud 2001-2005"); gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about), LICENSE_TEXT); gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about), "http://www.gscore.org"); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), "A musical score editor"); gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about), authors); gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(about), artists); gtk_widget_show(about); }
static void menu_item_style_set (GtkImage *image, gpointer data) { GtkWidget *widget; GdkPixbuf *pixbuf; GtkIconSize icon_size = (GtkIconSize) GPOINTER_TO_INT (data); int icon_height; gboolean is_mapped; if (!gtk_icon_size_lookup (icon_size, NULL, &icon_height)) return; pixbuf = gtk_image_get_pixbuf (image); if (!pixbuf) return; if (gdk_pixbuf_get_height (pixbuf) == icon_height) return; widget = GTK_WIDGET (image); is_mapped = gtk_widget_get_mapped (widget); if (is_mapped) gtk_widget_unmap (widget); gtk_image_set_from_pixbuf (image, NULL); if (is_mapped) gtk_widget_map (widget); }
static void radio_clicked_cb(GtkWidget *w, gpointer id) { GtkWidget *img; GdkPixbuf *pb; guint status = o2_get_status(); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)) == FALSE) return; if(g_strcasecmp(id, "1") == 0) status = TLEN_PRESENCE_AVAILABLE; else if(g_strcasecmp(id, "2") == 0) status = TLEN_PRESENCE_CHATTY; else if(g_strcasecmp(id, "3") == 0) status = TLEN_PRESENCE_DND; else if(g_strcasecmp(id, "4") == 0) status = TLEN_PRESENCE_AWAY; else if(g_strcasecmp(id, "5") == 0) status = TLEN_PRESENCE_EXT_AWAY; else if(g_strcasecmp(id, "6") == 0) status = TLEN_PRESENCE_INVISIBLE; else if(g_strcasecmp(id, "7") == 0) status = TLEN_PRESENCE_UNAVAILABLE; img = lookup_widget(win_desc, "image_status"); pb = gtk_image_get_pixbuf(GTK_IMAGE(get_status_icon(status))); gtk_image_set_from_pixbuf(GTK_IMAGE(img), pb); win_desc_status = status; }
int main( int argc, char * argv[] ) { GtkWidget * window; GdkPixbuf * battery; gtk_init( &argc, &argv ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER ); gtk_window_set_default_size( GTK_WINDOW(window), 220, 150 ); gtk_window_set_title( GTK_WINDOW(window), "Battery" ); gtk_container_set_border_width( GTK_CONTAINER(window), 15 ); gtk_widget_add_events( window, GDK_BUTTON_PRESS_MASK ); battery = gtk_image_get_pixbuf( GTK_IMAGE(gtk_image_new_from_file("battery.png")) ); gtk_window_set_icon( GTK_WINDOW(window), battery ); g_signal_connect_swapped( G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), G_OBJECT(window) ); g_signal_connect( G_OBJECT(window), "button-press-event", G_CALLBACK(show_about), (gpointer) window ); gtk_widget_show_all( window ); gtk_main(); return 0; }
static GtkWidget * clone_image_menu_size (GtkImage *image) { GtkImageType storage_type = gtk_image_get_storage_type (image); if (storage_type == GTK_IMAGE_STOCK) { gchar *stock_id; GtkWidget *widget; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; gtk_image_get_stock (image, &stock_id, NULL); widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU); G_GNUC_END_IGNORE_DEPRECATIONS; return widget; } else if (storage_type == GTK_IMAGE_ICON_NAME) { const gchar *icon_name; gtk_image_get_icon_name (image, &icon_name, NULL); return gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); } else if (storage_type == GTK_IMAGE_ICON_SET) { GtkWidget *widget; GtkIconSet *icon_set; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; gtk_image_get_icon_set (image, &icon_set, NULL); widget = gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU); G_GNUC_END_IGNORE_DEPRECATIONS; return widget; } else if (storage_type == GTK_IMAGE_GICON) { GIcon *icon; gtk_image_get_gicon (image, &icon, NULL); return gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU); } else if (storage_type == GTK_IMAGE_PIXBUF) { gint width, height; if (gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height)) { GdkPixbuf *src_pixbuf, *dest_pixbuf; GtkWidget *cloned_image; src_pixbuf = gtk_image_get_pixbuf (image); dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height, GDK_INTERP_BILINEAR); cloned_image = gtk_image_new_from_pixbuf (dest_pixbuf); g_object_unref (dest_pixbuf); return cloned_image; } } return NULL; }