Пример #1
0
static GtkWidget *
mail_printer_create_custom_widget_cb (GtkPrintOperation *operation,
                                      AsyncContext *async_context)
{
    EMailDisplay *display;
    EMailPartList *part_list;
    EMailPart *part;
    GtkWidget *widget;

    gtk_print_operation_set_custom_tab_label (operation, _("Headers"));

    display = E_MAIL_DISPLAY (async_context->web_view);
    part_list = e_mail_display_get_part_list (display);

    /* FIXME Hard-coding the part ID works for now but could easily
     *       break silently.  Need a less brittle way of extracting
     *       specific parts by either MIME type or GType. */
    part = e_mail_part_list_ref_part (part_list, ".message.headers");

    widget = e_mail_print_config_headers_new (E_MAIL_PART_HEADERS (part));

    g_object_unref (part);

    return widget;
}
Пример #2
0
static GtkWidget *
create_custom_widget (GtkPrintOperation *operation,
		      PrintData *data)
{
  GtkWidget *vbox, *hbox, *font, *label;

  gtk_print_operation_set_custom_tab_label (operation, "Other");
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new ("Font:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  
  font = gtk_font_button_new_with_font  (data->font);
  gtk_box_pack_start (GTK_BOX (hbox), font, FALSE, FALSE, 0);
  gtk_widget_show (font);
  data->font_button = font;

  return vbox;
}
Пример #3
0
Файл: print.c Проект: gdt/viking
void a_print(VikWindow *vw, VikViewport *vvp)
{
  /* TODO: make print_settings non-static when saving_settings_to_file is
   * implemented. Keep it static for now to retain settings for each
   * viking session
   */
  static GtkPrintSettings *print_settings = NULL;

  GtkPrintOperation *print_oper;
  GtkPrintOperationResult res;
  PrintData data;

  print_oper = gtk_print_operation_new ();

  data.num_pages     = 1;
  data.vw            = vw;
  data.vvp           = vvp;
  data.offset_x      = 0;
  data.offset_y      = 0;
  data.center        = VIK_PRINT_CENTER_BOTH;
  data.use_full_page = FALSE;
  data.operation     = print_oper;

  data.xmpp          = vik_viewport_get_xmpp(vvp);
  data.ympp          = vik_viewport_get_ympp(vvp);
  data.width         = vik_viewport_get_width(vvp);
  data.height        = vik_viewport_get_height(vvp);

  data.xres = data.yres = 230;   /* FIXME */

  if (print_settings != NULL) 
    gtk_print_operation_set_print_settings (print_oper, print_settings);

  g_signal_connect (print_oper, "begin_print", G_CALLBACK (begin_print), &data);
  g_signal_connect (print_oper, "draw_page", G_CALLBACK (draw_page), &data);
  g_signal_connect (print_oper, "end-print", G_CALLBACK (end_print), &data);
  g_signal_connect (print_oper, "create-custom-widget", G_CALLBACK (create_custom_widget_cb), &data);

  gtk_print_operation_set_custom_tab_label (print_oper, _("Image Settings"));

  res = gtk_print_operation_run (print_oper,
                                 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                 GTK_WINDOW (vw), NULL);

  if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
    if (print_settings != NULL)
      g_object_unref (print_settings);
    print_settings = g_object_ref (gtk_print_operation_get_print_settings (print_oper));
  }

  g_object_unref (print_oper);
}
Пример #4
0
static GObject *
print_job_create_custom_widget(GtkPrintOperation *operation,
			       gpointer           user_data)
{
	PlannerPrintJob *job;
	PlannerPrintJobPriv *priv;

	job = (PlannerPrintJob *)user_data;
	priv = job->priv;

	gtk_print_operation_set_custom_tab_label(operation, _("Select views"));

	return G_OBJECT(print_dialog_create_page (NULL, NULL, priv->views));
}
static void
photos_print_operation_init (PhotosPrintOperation *self)
{
  GtkPrintSettings *settings;

  self->unit = GTK_UNIT_INCH;
  self->left_margin = 0.0;
  self->top_margin = 0.0;
  self->scale_factor = 100.0;

  settings = gtk_print_settings_new ();
  gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (self), settings);
  g_object_unref (settings);

  gtk_print_operation_set_custom_tab_label (GTK_PRINT_OPERATION (self), _("Image Settings"));
  gtk_print_operation_set_embed_page_setup (GTK_PRINT_OPERATION (self), TRUE);
  gtk_print_operation_set_n_pages (GTK_PRINT_OPERATION (self), 1);
}
Пример #6
0
Print::Print(SPDocument *doc, SPItem *base) :
    _doc (doc),
    _base (base)
{
    g_assert (_doc);
    g_assert (_base);

    _printop = gtk_print_operation_new ();

    // set up dialog title, based on document name
    gchar *jobname = _doc->name ? _doc->name : _("SVG Document");
    Glib::ustring title = _("Print");
    title += " ";
    title += jobname;
    gtk_print_operation_set_job_name (_printop, title.c_str());

    // set up paper size to match the document size
    gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS);
    GtkPageSetup *page_setup = gtk_page_setup_new();
    gdouble doc_width = sp_document_width(_doc) * PT_PER_PX;
    gdouble doc_height = sp_document_height(_doc) * PT_PER_PX;
    GtkPaperSize *paper_size = gtk_paper_size_new_custom("custom", "custom",
                                doc_width, doc_height, GTK_UNIT_POINTS);
    gtk_page_setup_set_paper_size (page_setup, paper_size);
#ifndef WIN32
    gtk_print_operation_set_default_page_setup (_printop, page_setup);
#endif
    gtk_print_operation_set_use_full_page (_printop, TRUE);

    // set up signals
    _workaround._doc = _doc;
    _workaround._base = _base;
    _workaround._tab = &_tab;
    g_signal_connect (_printop, "create-custom-widget", G_CALLBACK (create_custom_widget), _tab.gobj());
    g_signal_connect (_printop, "begin-print", G_CALLBACK (begin_print), NULL);
    g_signal_connect (_printop, "draw-page", G_CALLBACK (draw_page), &_workaround);

    // build custom preferences tab
    gtk_print_operation_set_custom_tab_label (_printop, _("Rendering"));
}
Пример #7
0
GtkPrintOperation *
xviewer_print_operation_new (XviewerImage *image,
                             GtkPrintSettings *print_settings,
                             GtkPageSetup *page_setup)
{
    GtkPrintOperation *print;
    XviewerPrintData *data;
    gint width, height;

    xviewer_debug (DEBUG_PRINTING);

    print = gtk_print_operation_new ();

    data = g_slice_new0 (XviewerPrintData);

    data->left_margin = 0;
    data->top_margin = 0;
    data->scale_factor = 100;
    data->image = g_object_ref (image);
    data->unit = GTK_UNIT_INCH;

    xviewer_image_get_size (image, &width, &height);

    if (page_setup == NULL)
        page_setup = gtk_page_setup_new ();

    if (height >= width) {
        gtk_page_setup_set_orientation (page_setup,
                                        GTK_PAGE_ORIENTATION_PORTRAIT);
    } else {
        gtk_page_setup_set_orientation (page_setup,
                                        GTK_PAGE_ORIENTATION_LANDSCAPE);
    }

    gtk_print_operation_set_print_settings (print, print_settings);
    gtk_print_operation_set_default_page_setup (print,
            page_setup);
    gtk_print_operation_set_n_pages (print, 1);
    gtk_print_operation_set_job_name (print,
                                      xviewer_image_get_caption (image));
    gtk_print_operation_set_embed_page_setup (print, TRUE);

    g_signal_connect (print, "draw_page",
                      G_CALLBACK (xviewer_print_draw_page),
                      data);
    g_signal_connect (print, "create-custom-widget",
                      G_CALLBACK (xviewer_print_create_custom_widget),
                      data);
    g_signal_connect (print, "custom-widget-apply",
                      G_CALLBACK (xviewer_print_custom_widget_apply),
                      data);
    g_signal_connect (print, "end-print",
                      G_CALLBACK (xviewer_print_end_print),
                      data);
    g_signal_connect (print, "update-custom-widget",
                      G_CALLBACK (xviewer_print_image_setup_update),
                      data);

    gtk_print_operation_set_custom_tab_label (print, _("Image Settings"));

    return print;
}
Пример #8
0
static GimpPDBStatusType
print_image (gint32     image_ID,
             gboolean   interactive,
             GError   **error)
{
  GtkPrintOperation       *operation;
  GtkPrintOperationResult  result;
  gchar                   *temp_proc;
  gint32                   layer;
  PrintData                data;

  /*  create a print layer from the projection  */
  layer = gimp_layer_new_from_visible (image_ID, image_ID, PRINT_PROC_NAME);

  operation = gtk_print_operation_new ();

  gtk_print_operation_set_n_pages (operation, 1);
  print_operation_set_name (operation, image_ID);

  print_page_setup_load (operation, image_ID);

  /* fill in the PrintData struct */
  data.image_id      = image_ID;
  data.drawable_id   = layer;
  data.unit          = gimp_get_default_unit ();
  data.image_unit    = gimp_image_get_unit (image_ID);
  data.offset_x      = 0;
  data.offset_y      = 0;
  data.center        = CENTER_BOTH;
  data.use_full_page = FALSE;
  data.operation     = operation;

  gimp_image_get_resolution (image_ID, &data.xres, &data.yres);

  print_settings_load (&data);

  gtk_print_operation_set_unit (operation, GTK_UNIT_PIXEL);

  g_signal_connect (operation, "begin-print",
                    G_CALLBACK (begin_print),
                    &data);
  g_signal_connect (operation, "draw-page",
                    G_CALLBACK (draw_page),
                    &data);
  g_signal_connect (operation, "end-print",
                    G_CALLBACK (end_print),
                    &image_ID);

  print_operation = operation;
  temp_proc = print_temp_proc_install (image_ID);
  gimp_extension_enable ();

  if (interactive)
    {
      gimp_ui_init (PLUG_IN_BINARY, FALSE);

      g_signal_connect_swapped (operation, "end-print",
                                G_CALLBACK (print_settings_save),
                                &data);

      g_signal_connect (operation, "create-custom-widget",
                        G_CALLBACK (create_custom_widget),
                        &data);

      gtk_print_operation_set_custom_tab_label (operation, _("Image Settings"));

      result = gtk_print_operation_run (operation,
                                        GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                        NULL, error);
    }
  else
    {
      result = gtk_print_operation_run (operation,
                                        GTK_PRINT_OPERATION_ACTION_PRINT,
                                        NULL, error);
    }

  gimp_uninstall_temp_proc (temp_proc);
  g_free (temp_proc);
  print_operation = NULL;

  g_object_unref (operation);

  if (gimp_drawable_is_valid (layer))
    gimp_drawable_delete (layer);

  switch (result)
    {
    case GTK_PRINT_OPERATION_RESULT_APPLY:
    case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
      return GIMP_PDB_SUCCESS;

    case GTK_PRINT_OPERATION_RESULT_CANCEL:
      return GIMP_PDB_CANCEL;

    case GTK_PRINT_OPERATION_RESULT_ERROR:
      return GIMP_PDB_EXECUTION_ERROR;
    }

  return GIMP_PDB_EXECUTION_ERROR;
}
Пример #9
0
 int PrintText(const char *name, gchar *text)
 {
	GKeyFile			*conf	= GetConf();
 	GtkPrintOperation	*prt;
 	const gchar		*font;
	GtkPageSetup 		*page_setup = NULL;
	GtkPrintSettings 	*print_settings = NULL;

 	if(!text)
		return -EINVAL;

 	prt = gtk_print_operation_new();

 	if(!prt)
 		return -1;

	// Set job parameters
	g_object_set_data_full(G_OBJECT(prt),"3270Text",g_strsplit(g_strchomp(text),"\n",-1),(void (*)(gpointer)) g_strfreev);

	// Set print
	font = GetString("Print","Font","");
	if(!*font)
		font = GetString("Terminal","Font","Courier");

	g_object_set_data_full(G_OBJECT(prt),"3270FontName",g_strdup(font),g_free);

	// Configure print operation
	gtk_print_operation_set_job_name(prt,name);
	gtk_print_operation_set_allow_async(prt,0);
	gtk_print_operation_set_show_progress(prt,1);

	gtk_print_operation_set_custom_tab_label(prt,_( "Font" ));
	g_signal_connect(prt, "begin-print",    		G_CALLBACK(begin_print), 			0);
    g_signal_connect(prt, "draw-page",      		G_CALLBACK(draw_page),   			0);
#ifdef HAVE_PRINT_FONT_DIALOG
	g_signal_connect(prt, "create-custom-widget",   G_CALLBACK(create_custom_widget),	0);
	g_signal_connect(prt, "custom-widget-apply",   	G_CALLBACK(custom_widget_apply),	0);
#endif
    g_signal_connect(prt, "done",      				G_CALLBACK(print_done),	 			0);

	if(conf)
	{
#if GTK_CHECK_VERSION(2,12,0)
		gchar *ptr = g_key_file_get_string(conf,"Print Settings","output-uri",NULL);
		if(ptr)
		{
			gchar *uri = NULL;

			switch(*(ptr++))
			{
			case '$':
				if(g_str_has_prefix(ptr,"home/"))
					uri = g_strdup_printf("file:///%s/%s",g_get_home_dir(),ptr+5);
#if GTK_CHECK_VERSION(2,14,0)
				else if(g_str_has_prefix(ptr,"documents/"))
					uri = g_strdup_printf("file:///%s/%s",g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS),ptr+10);
				else if(g_str_has_prefix(ptr,"desktop/"))
					uri = g_strdup_printf("file:///%s/%s",g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP),ptr+8);
#endif
				break;

			case '~':
				uri = g_strdup_printf("file:///%s/%s",g_get_home_dir(),ptr);
				break;

			}

			if(uri)
			{
				g_key_file_set_string(conf,"Print Settings","output-uri",uri);
				g_free(uri);
			}
		}

		print_settings = gtk_print_settings_new_from_key_file(conf,NULL,NULL);
		page_setup = gtk_page_setup_new_from_key_file(conf,NULL,NULL);

		if(!page_setup)
			page_setup = gtk_page_setup_new();

#else // GTK_CHECK_VERSION(2,12,0)
		print_settings = gtk_print_settings_new();
		if(print_settings)
		{
			gchar 				**list;
			int 				f;

			list = g_key_file_get_keys(conf,"PrintSettings",NULL,NULL);
			if(list)
			{
				for(f=0;list[f];f++)
					gtk_print_settings_set(print_settings,list[f],g_key_file_get_string(conf,"PrintSettings",list[f],NULL));
				g_strfreev(list);
			}
		}
		page_setup = gtk_page_setup_new();
#endif
	}
	else
	{
		page_setup = gtk_page_setup_new();
		gtk_print_operation_set_print_settings(prt,gtk_print_settings_new());
	}

	Trace("page_setup: %p print_settings: %p",page_setup,print_settings);
	gtk_print_operation_set_print_settings(prt,print_settings);
	gtk_print_operation_set_default_page_setup(prt,page_setup);


	// Run Print dialog
	gtk_print_operation_run(prt,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(topwindow),NULL);

    g_object_unref(prt);

    return 0;
 }
Пример #10
0
static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer user_data)
{	/* copied from interface.c */
	GtkWidget *page;
	GtkWidget *frame33;
	GtkWidget *alignment36;
	GtkWidget *vbox30;
	GtkWidget *hbox10;
	GtkWidget *label203;
	PrintWidgets *w = user_data;

	gtk_print_operation_set_custom_tab_label(operation, _("Document Setup"));

	page = gtk_vbox_new(FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(page), 5);

	w->check_print_linenumbers = gtk_check_button_new_with_mnemonic(_("Print line numbers"));
	gtk_box_pack_start(GTK_BOX(page), w->check_print_linenumbers, FALSE, FALSE, 0);
	gtk_widget_set_tooltip_text(w->check_print_linenumbers, _("Add line numbers to the printed page"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_linenumbers), printing_prefs.print_line_numbers);

	w->check_print_pagenumbers = gtk_check_button_new_with_mnemonic(_("Print page numbers"));
	gtk_box_pack_start(GTK_BOX(page), w->check_print_pagenumbers, FALSE, FALSE, 0);
	gtk_widget_set_tooltip_text(w->check_print_pagenumbers, _("Add page numbers at the bottom of each page. It takes 2 lines of the page."));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pagenumbers), printing_prefs.print_page_numbers);

	w->check_print_pageheader = gtk_check_button_new_with_mnemonic(_("Print page header"));
	gtk_box_pack_start(GTK_BOX(page), w->check_print_pageheader, FALSE, FALSE, 0);
	gtk_widget_set_tooltip_text(w->check_print_pageheader, _("Add a little header to every page containing the page number, the filename and the current date (see below). It takes 3 lines of the page."));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pageheader), printing_prefs.print_page_header);
	g_signal_connect(w->check_print_pageheader, "toggled", G_CALLBACK(on_page_header_toggled), w);

	frame33 = gtk_frame_new(NULL);
	gtk_box_pack_start(GTK_BOX(page), frame33, FALSE, FALSE, 0);
	gtk_frame_set_label_align(GTK_FRAME(frame33), 0, 0);
	gtk_frame_set_shadow_type(GTK_FRAME(frame33), GTK_SHADOW_NONE);

	alignment36 = gtk_alignment_new(0, 0.5, 1, 1);
	gtk_container_add(GTK_CONTAINER(frame33), alignment36);
	gtk_alignment_set_padding(GTK_ALIGNMENT(alignment36), 0, 0, 12, 0);

	vbox30 = gtk_vbox_new(FALSE, 1);
	gtk_container_add(GTK_CONTAINER(alignment36), vbox30);

	w->check_print_basename = gtk_check_button_new_with_mnemonic(_("Use the basename of the printed file"));
	gtk_box_pack_start(GTK_BOX(vbox30), w->check_print_basename, FALSE, FALSE, 0);
	gtk_widget_set_tooltip_text(w->check_print_basename, _("Print only the basename(without the path) of the printed file"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_basename), printing_prefs.page_header_basename);

	hbox10 = gtk_hbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox30), hbox10, TRUE, TRUE, 0);

	label203 = gtk_label_new(_("Date format:"));
	gtk_box_pack_start(GTK_BOX(hbox10), label203, FALSE, FALSE, 0);

	w->entry_print_dateformat = gtk_entry_new();
	ui_entry_add_clear_icon(GTK_ENTRY(w->entry_print_dateformat));
	gtk_box_pack_start(GTK_BOX(hbox10), w->entry_print_dateformat, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(w->entry_print_dateformat, _("Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function."));
	gtk_entry_set_text(GTK_ENTRY(w->entry_print_dateformat), printing_prefs.page_header_datefmt);

	on_page_header_toggled(GTK_TOGGLE_BUTTON(w->check_print_pageheader), w);
	gtk_widget_show_all(page);
	return page;
}