static gchar * xfce_image_list_dialog_list_save_as (XfceImageListDialog *a, gchar const *fname_default) { /* TODO default ? */ XfceFileChooser *fc; XfceFileFilter *filt1; XfceFileFilter *filt2; gint rc; gchar *fname; fname = NULL; TRACE ("list_save_as"); fc = XFCE_FILE_CHOOSER (xfce_file_chooser_new ("Background List - Save as", GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (a))), XFCE_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL )); xfce_file_chooser_set_select_multiple (fc, FALSE); xfce_file_chooser_set_current_name (fc, ".imglist"); /*xfce_file_chooser_set_default_extension .imglist */ filt1 = xfce_file_filter_new (); xfce_file_filter_set_name (filt1, _("Image File List")); xfce_file_filter_add_mime_type (filt1, "application/x-xfce-image-file-list"); xfce_file_filter_add_pattern (filt1, "*.imglist"); xfce_file_chooser_add_filter (fc, filt1); filt2 = xfce_file_filter_new (); xfce_file_filter_set_name (filt2, _("All Files")); xfce_file_chooser_add_filter (fc, filt2); rc = gtk_dialog_run (GTK_DIALOG (fc)); if (rc == GTK_RESPONSE_OK) { fname = xfce_file_chooser_get_filename (fc); gtk_widget_destroy (GTK_WIDGET (fc)); return fname; } return NULL; }
static void mailwatch_iconbtn_clicked_cb(GtkWidget *w, gpointer user_data) { Control *c = user_data; XfceMailwatchPlugin *mwp = c->data; gint icon_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "mailwatch-icontype")); GtkWidget *chooser, *toplevel; g_return_if_fail(icon_type == 1 || icon_type == 2); toplevel = gtk_widget_get_toplevel(w); chooser = xfce_file_chooser_dialog_new(_("Select Icon"), GTK_WINDOW(toplevel), XFCE_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { gchar *filename = xfce_file_chooser_get_filename(XFCE_FILE_CHOOSER(chooser)); if(filename) { switch(icon_type) { case 1: { GtkWidget *vbox, *img, *lbl; g_free(mwp->normal_icon); mwp->normal_icon = filename; mailwatch_set_size(c, settings.size); gtk_container_remove(GTK_CONTAINER(w), gtk_bin_get_child(GTK_BIN(w))); vbox = gtk_vbox_new(FALSE, BORDER/2); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(w), vbox); img = gtk_image_new_from_pixbuf(mwp->pix_normal); gtk_widget_show(img); gtk_box_pack_start(GTK_BOX(vbox), img, TRUE, TRUE, 0); lbl = gtk_label_new_with_mnemonic(_("_Normal")); gtk_widget_show(lbl); gtk_box_pack_start(GTK_BOX(vbox), lbl, FALSE, FALSE, 0); } break; case 2: { GtkWidget *vbox, *img, *lbl; g_free(mwp->new_mail_icon); mwp->new_mail_icon = filename; mailwatch_set_size(c, settings.size); gtk_container_remove(GTK_CONTAINER(w), gtk_bin_get_child(GTK_BIN(w))); vbox = gtk_vbox_new(FALSE, BORDER/2); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(w), vbox); img = gtk_image_new_from_pixbuf(mwp->pix_newmail); gtk_widget_show(img); gtk_box_pack_start(GTK_BOX(vbox), img, TRUE, TRUE, 0); lbl = gtk_label_new_with_mnemonic(_("Ne_w mail")); gtk_widget_show(lbl); gtk_box_pack_start(GTK_BOX(vbox), lbl, FALSE, FALSE, 0); } break; } } } gtk_widget_destroy(chooser); }
static void button_clicked(GtkWidget * button, ScreenshotData * sd) { GdkPixbuf * screenshot; GdkPixbuf * thumbnail; GdkWindow * window; GdkNativeWindow nwindow; gint delay; gint width; gint height; gchar * filename = NULL; gchar * basename = NULL; gchar * curdir = NULL; if (sd->whole_screen) { window = gdk_get_default_root_window(); } else { if (delay = sd->window_delay) { g_timeout_add(1000, delay_callback, &delay); gtk_main(); } nwindow = select_window(gdk_screen_get_default()); if (nwindow) { window = gdk_window_foreign_new(nwindow); } else { window = gdk_get_default_root_window(); } } gdk_drawable_get_size(window, &width, &height); if (delay = sd->screenshot_delay) { g_timeout_add(1000, delay_callback, &delay); gtk_main(); } screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL, 0, 0, 0, 0, width, height); thumbnail = gdk_pixbuf_scale_simple (screenshot, width/5, height/5, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf (GTK_IMAGE (sd->preview), thumbnail); g_object_unref (thumbnail); filename = generate_filename_for_uri (xfce_file_chooser_get_current_folder(XFCE_FILE_CHOOSER (sd->chooser))); if (sd->ask_for_file && filename) { gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (sd->chooser), filename); if (gtk_dialog_run (GTK_DIALOG (sd->chooser)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(sd->chooser)); } gtk_widget_hide (GTK_WIDGET (sd->chooser)); } else { /* sd->counter++; basename = g_strdup_printf ("Screenshot-%d.png", sd->counter); filename = g_build_filename (sd->screenshots_dir, basename, NULL); curdir = g_get_current_dir(); filename = g_build_filename (curdir, basename, NULL); g_free(basename); */ } if (filename) { gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL); g_free (filename); } }