Example #1
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkPageSetup_gtk_1page_1setup_1set_1orientation
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _orientation
)
{
	GtkPageSetup* self;
	GtkPageOrientation orientation;

	// convert parameter self
	self = (GtkPageSetup*) _self;

	// convert parameter orientation
	orientation = (GtkPageOrientation) _orientation;

	// call function
	gtk_page_setup_set_orientation(self, orientation);

	// cleanup parameter self

	// cleanup parameter orientation
}
Example #2
0
static VALUE
rg_set_orientation(VALUE self, VALUE orientation)
{
    gtk_page_setup_set_orientation(_SELF(self), 
                                   RVAL2GTKPAGEORIENTATION(orientation));
    return self;
}
static void
photos_print_operation_constructed (GObject *object)
{
  PhotosPrintOperation *self = PHOTOS_PRINT_OPERATION (object);
  GeglRectangle bbox;
  GtkPageSetup *page_setup;
  gchar *name;

  G_OBJECT_CLASS (photos_print_operation_parent_class)->constructed (object);

  page_setup = gtk_page_setup_new ();
  gtk_print_operation_set_default_page_setup (GTK_PRINT_OPERATION (self), page_setup);

  bbox = gegl_node_get_bounding_box (self->node);
  if (bbox.height >= bbox.width)
    gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
  else
    gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);

  g_object_unref (page_setup);

  name = g_strdup (photos_base_item_get_name (self->item));
  if (name == NULL || name[0] == '\0')
    {
      GFile *file;
      const gchar *uri;
      gchar *basename;

      uri = photos_base_item_get_uri (self->item);
      file = g_file_new_for_uri (uri);
      basename = g_file_get_basename (file);

      if (g_utf8_validate (basename, -1, NULL))
        name = g_strdup (basename);
      else
        name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);

      g_free (basename);
      g_object_unref (file);
    }

  gtk_print_operation_set_job_name (GTK_PRINT_OPERATION (self), name);
  g_free (name);
}
Example #4
0
/*! \brief Create a default page setup for a schematic page.
 * \par Function Description
 * Creates and returns a new #GtkPageSetup for \a page, taking into
 * account the requested \a paper_size_name.  If \a paper_size_name is
 * NULL, the system default paper size is used. The \a orientation may
 * be LANDSCAPE, PORTRAIT or AUTOLAYOUT.  If \a AUTOLAYOUT is chosen,
 * the page orientation that best fits the page contents is chosen.
 *
 * \param toplevel A #TOPLEVEL structure.
 * \param page     The #PAGE to generate a page setup for.
 * \param paper_size_name   The name of the paper size to use.
 * \param orientation       The paper orientation to use.
 *
 * \returns A newly-created page setup.
 */
static GtkPageSetup *
x_print_default_page_setup (TOPLEVEL *toplevel, PAGE *page)
{
  GtkPageSetup *setup = gtk_page_setup_new ();
  GtkPaperSize *papersize;
  int status, wx_min, wy_min, wx_max, wy_max;
  EdaConfig *cfg;
  gchar *paper, *orientation;

  /* Get configuration values */
  cfg =         eda_config_get_context_for_path (s_page_get_filename (page));
  paper =       eda_config_get_string (cfg, CFG_GROUP_PRINTING,
                                       CFG_KEY_PRINTING_PAPER, NULL);
  orientation = eda_config_get_string (cfg, CFG_GROUP_PRINTING,
                                       CFG_KEY_PRINTING_ORIENTATION, NULL);

  /* If the paper size is valid, set it up with default margins. */
  papersize = gtk_paper_size_new (paper);
  if (papersize != NULL) {
    gtk_page_setup_set_paper_size_and_default_margins (setup, papersize);
  }

  if (g_strcmp0 (orientation, "landscape") == 0) {
    gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
  } else if (g_strcmp0 (orientation, "portrait") == 0) {
    gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT);
  } else if (orientation == NULL
             || g_strcmp0 (orientation, "auto") == 0) {
    /* Automatically choose the orientation that fits best */
    status = world_get_object_glist_bounds (toplevel, s_page_objects (page),
                                            &wx_min, &wy_min, &wx_max, &wy_max);
    if (!status || (wx_max - wx_min) > (wy_max - wy_min)) {
      /* Default to landscape */
      gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
    } else {
      gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT);
    }
  }

  g_free (paper);
  g_free (orientation);
  return setup;
}
Example #5
0
File: print.c Project: pwmt/zathura
static void
cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation),
                            GtkPrintContext* UNUSED(context), gint page_number,
                            GtkPageSetup* setup, zathura_t* zathura)
{
  if (zathura == NULL || zathura->document == NULL) {
    return;
  }

  zathura_page_t* page = zathura_document_get_page(zathura->document, page_number);
  double width  = zathura_page_get_width(page);
  double height = zathura_page_get_height(page);

  if (width > height) {
    gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
  } else {
    gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_PORTRAIT);
  }
}
NS_IMETHODIMP
nsPrintSettingsGTK::SetOrientation(int32_t aOrientation)
{
    GtkPageOrientation gtkOrient;
    if (aOrientation == kLandscapeOrientation)
        gtkOrient = GTK_PAGE_ORIENTATION_LANDSCAPE;
    else
        gtkOrient = GTK_PAGE_ORIENTATION_PORTRAIT;

    gtk_print_settings_set_orientation(mPrintSettings, gtkOrient);
    gtk_page_setup_set_orientation(mPageSetup, gtkOrient);
    return NS_OK;
}
Example #7
0
static void
request_page_setup (GtkPrintOperation *operation,
		    GtkPrintContext *context,
		    int page_nr,
		    GtkPageSetup *setup)
{
  /* Make the second page landscape mode a5 */
  if (page_nr == 1)
    {
      GtkPaperSize *a5_size = gtk_paper_size_new ("iso_a5");
      
      gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
      gtk_page_setup_set_paper_size (setup, a5_size);
      gtk_paper_size_free (a5_size);
    }
}
Example #8
0
void
calendar_begin_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
	GUI *appGUI = (GUI *) user_data;

	GtkPageSetup *setup;

	if (config.cal_print_page_orientation == LANDSCAPE) {
		setup = gtk_page_setup_new ();
		gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
		gtk_print_operation_set_default_page_setup (operation, setup);
		g_object_unref (setup);
	}

	appGUI->print_lines_per_page = 1;
	appGUI->print_nlines = 1;
	appGUI->print_npages = 1;
	gtk_print_operation_set_n_pages (operation, appGUI->print_npages);
}
Example #9
0
GtkPrintOperation *
biorhythm_print_operation_new (BiorhythmChart *chart)
{
	GtkPrintOperation *print;
	GtkPageSetup *page_setup;

	print = gtk_print_operation_new ();
	gtk_print_operation_set_n_pages (print, 1);
	gtk_print_operation_set_job_name (print, "Print Biorhythm");
	gtk_print_operation_set_embed_page_setup (print, FALSE);

	page_setup = gtk_page_setup_new ();
	gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
	gtk_print_operation_set_default_page_setup (print, page_setup);

	g_signal_connect (print, "draw_page", G_CALLBACK (biorhythm_print_draw_page), chart);

	return print;
}
Example #10
0
/* Dia has it's own thing */
static void
_dia_to_gtk_page_setup (const DiagramData *data, GtkPageSetup *setup)
{
  GtkPaperSize *paper_size;
  const double points_per_cm = 28.346457;
  const PaperInfo *paper = &(data->paper);
  int index = find_paper (paper->name);
  if (index < 0)
    index = get_default_paper ();
  paper_size = gtk_paper_size_new_from_ppd (
		 paper->name, paper->name, 
                 get_paper_pswidth (index) * points_per_cm, 
		 get_paper_psheight (index) * points_per_cm);

  gtk_page_setup_set_orientation (setup, data->paper.is_portrait ?
    GTK_PAGE_ORIENTATION_PORTRAIT : GTK_PAGE_ORIENTATION_LANDSCAPE);
  gtk_page_setup_set_paper_size (setup, paper_size);

  gtk_page_setup_set_left_margin (setup, data->paper.lmargin * 10, GTK_UNIT_MM);
  gtk_page_setup_set_top_margin (setup, data->paper.tmargin * 10, GTK_UNIT_MM);
  gtk_page_setup_set_right_margin (setup, data->paper.rmargin * 10, GTK_UNIT_MM);
  gtk_page_setup_set_bottom_margin (setup, data->paper.bmargin * 10, GTK_UNIT_MM);
  
}
Example #11
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;
}
Example #12
0
void XAP_UnixDialog_Print::setupPrint()
{
	double blockMrgnLeft, blockMrgnRight, mrgnTop, mrgnBottom, mrgnLeft, mrgnRight = 0.;
	double width, height;
	bool portrait;

	m_pView = static_cast<FV_View*>(m_pFrame->getCurrentView());
	m_pPO = gtk_print_operation_new();
	//
	// Set filename if it's not present already
	//
    std::string sURI = m_pView->getDocument()->getPrintFilename();
	
	if(sURI.empty())
	{
        const std::string & filename = m_pView->getDocument()->getFilename();
        if(!filename.empty()) {
            sURI = filename;
            UT_addOrReplacePathSuffix(sURI, ".pdf");
        }
	}
    if(!sURI.empty()) {
        GtkPrintSettings * pSettings =  gtk_print_settings_new();
        gtk_print_settings_set(pSettings,
                               GTK_PRINT_SETTINGS_OUTPUT_URI,
                               sURI.c_str() );
        gtk_print_operation_set_print_settings(m_pPO,pSettings);
        g_object_unref(pSettings);
    }

	s_getPageMargins(m_pView, blockMrgnLeft, blockMrgnRight, mrgnLeft, mrgnRight,  mrgnTop, mrgnBottom);

	portrait = m_pView->getPageSize().isPortrait();
		
	width = m_pView->getPageSize().Width (DIM_MM);
	height = m_pView->getPageSize().Height (DIM_MM);
	
	m_pPageSetup = gtk_page_setup_new();

	const char * pszName = m_pView->getPageSize().getPredefinedName();
	bool isPredefined = false;
	const char * pszGtkName = NULL;
	if(pszName == NULL)
    {
	}
	else if(g_ascii_strcasecmp(pszName,"Custom") == 0)
	{
	}
	else if(g_ascii_strcasecmp(pszName,"A0") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a0";
	}
	else if(g_ascii_strcasecmp(pszName,"A1") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a1";
	}
	else if(g_ascii_strcasecmp(pszName,"A2") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a2";
	}
	else if(g_ascii_strcasecmp(pszName,"A3") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a3";
	}
	else if(g_ascii_strcasecmp(pszName,"A4") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a4";
	}
	else if(g_ascii_strcasecmp(pszName,"A5") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a5";
	}
	else if(g_ascii_strcasecmp(pszName,"A6") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a6";
	}
	else if(g_ascii_strcasecmp(pszName,"A7") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a7";
	}
	else if(g_ascii_strcasecmp(pszName,"A8") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a8";
	}
	else if(g_ascii_strcasecmp(pszName,"A9") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_a9";
	}
	else if(g_ascii_strcasecmp(pszName,"B0") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b0";
	}
	else if(g_ascii_strcasecmp(pszName,"B1") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b1";
	}
	else if(g_ascii_strcasecmp(pszName,"B2") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b2";
	}
	else if(g_ascii_strcasecmp(pszName,"B3") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b3";
	}
	else if(g_ascii_strcasecmp(pszName,"B4") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b4";
	}
	else if(g_ascii_strcasecmp(pszName,"B4") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b4";
	}
	else if(g_ascii_strcasecmp(pszName,"B5") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b5";
	}
	else if(g_ascii_strcasecmp(pszName,"B6") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b6";
	}
	else if(g_ascii_strcasecmp(pszName,"B7") == 0)
	{
		isPredefined = true;
		pszGtkName = "iso_b7";
	}
	else if(g_ascii_strcasecmp(pszName,"Legal") == 0)
	{
		isPredefined = true;
		pszGtkName = "na_legal";
	}
	else if(g_ascii_strcasecmp(pszName,"Letter") == 0)
	{
		isPredefined = true;
		pszGtkName = "na_letter";
	}
	if(isPredefined)
	{
		m_pGtkPageSize = gtk_paper_size_new(static_cast<const gchar *>(pszGtkName));
	}
	else
	{
        /*
         * Width() and Height() will return the paper size as shown in the UI.
         * Gtk wants the real paper size, however, and will swap the two
         * itself when we specify the orientation.
         */
        m_pGtkPageSize = gtk_paper_size_new_custom("custom",
                                                   "custom",
                                                   portrait ? width : height,
                                                   portrait ? height : width,
                                                   GTK_UNIT_MM);
	}
	//
	// Set the Page Size
	//
	gtk_page_setup_set_paper_size(m_pPageSetup,m_pGtkPageSize);
	//
	// Set the margins
	//
	gtk_page_setup_set_top_margin(m_pPageSetup,mrgnTop,GTK_UNIT_INCH);
	gtk_page_setup_set_bottom_margin(m_pPageSetup,mrgnBottom,GTK_UNIT_INCH);
	gtk_page_setup_set_left_margin(m_pPageSetup,mrgnLeft,GTK_UNIT_INCH);
	gtk_page_setup_set_right_margin(m_pPageSetup,mrgnRight,GTK_UNIT_INCH);
	//
	// Set orientation
	//
	if(	portrait)
		gtk_page_setup_set_orientation(m_pPageSetup,GTK_PAGE_ORIENTATION_PORTRAIT);
	else
		gtk_page_setup_set_orientation(m_pPageSetup,GTK_PAGE_ORIENTATION_LANDSCAPE);
	gtk_print_operation_set_default_page_setup(m_pPO,m_pPageSetup);
	gtk_print_operation_set_use_full_page (m_pPO, true);
	m_pDL = m_pView->getLayout();
	m_iCurrentPage = m_pDL->findPage(m_pView->getCurrentPage());
	m_iNumberPages = (gint) m_pDL->countPages();
	gtk_print_operation_set_current_page(m_pPO,m_iCurrentPage);

	g_signal_connect (m_pPO, "begin_print", G_CALLBACK (s_Begin_Print), this);
	g_signal_connect (m_pPO, "draw_page", G_CALLBACK (s_Print_Page), this);
}
Example #13
0
void
CmOutputPrinter(int select_file, int show_dialog)
{
  GtkPrintOperation *print;
  GtkPrintOperationResult res;
  char buf[MESSAGE_BUF_SIZE];
  struct objlist *graobj, *g2wobj;
  int id, g2wid, g2woid, opt;
  N_VALUE *g2winst;
  GError *error;
  struct print_obj pobj;
  GtkPaperSize *paper_size;
  GtkPageSetup *page_setup;

  if (Menulock || Globallock)
    return;

  if (select_file && ! SetFileHidden())
    return;

  FileAutoScale();
  AdjustAxis();

  graobj = chkobject("gra");
  if (graobj == NULL)
    return;

  g2wobj = chkobject("gra2gtkprint");
  if (g2wobj == NULL)
    return;

  g2wid = newobj(g2wobj);
  if (g2wid < 0)
    return;

  putobj(g2wobj, "use_opacity", g2wid, &Menulocal.use_opacity);

  g2winst = chkobjinst(g2wobj, g2wid);
  _getobj(g2wobj, "oid", g2winst, &g2woid);
  id = newobj(graobj);
  init_graobj(graobj, id, "gra2gtkprint", g2woid);

  print = gtk_print_operation_new();
  gtk_print_operation_set_n_pages(print, 1);
#if GTK_CHECK_VERSION(2, 18, 0)
  gtk_print_operation_set_has_selection(print, FALSE);
  gtk_print_operation_set_support_selection(print, FALSE);
  gtk_print_operation_set_embed_page_setup(print, FALSE);
#endif
  gtk_print_operation_set_use_full_page(print, TRUE);

  if (PrintSettings == NULL)
    PrintSettings = gtk_print_settings_new();

  if (Menulocal.PaperId == PAPER_ID_CUSTOM) {
    paper_size = gtk_paper_size_new_custom(Menulocal.PaperName,
					   Menulocal.PaperName,
					   Menulocal.PaperWidth / 100.0,
					   Menulocal.PaperHeight / 100.0,
					   GTK_UNIT_MM);
  } else {
    paper_size = gtk_paper_size_new(Menulocal.PaperName);
  }

  page_setup = gtk_page_setup_new();
  gtk_page_setup_set_paper_size(page_setup, paper_size);
  if (Menulocal.PaperLandscape) {
    gtk_page_setup_set_orientation(page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
  } else {
    gtk_page_setup_set_orientation(page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
  }

  gtk_print_operation_set_default_page_setup(print, page_setup);
  gtk_print_operation_set_print_settings(print, PrintSettings);

  pobj.graobj = graobj;
  pobj.id = id;
  pobj.g2wobj = g2wobj;
  pobj.g2winst = g2winst;
  g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), &pobj);

  switch (show_dialog) {
  case PRINT_SHOW_DIALOG_NONE:
    opt = GTK_PRINT_OPERATION_ACTION_PRINT;
    break;
  case PRINT_SHOW_DIALOG_PREVIEW:
    opt = GTK_PRINT_OPERATION_ACTION_PREVIEW;
    break;
  case PRINT_SHOW_DIALOG_DIALOG:
    opt = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
    break;
  default:
    opt = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
  }

  res = gtk_print_operation_run(print, opt, GTK_WINDOW(TopLevel), &error);

  if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
    snprintf(buf, sizeof(buf), _("Printing error: %s"), error->message);
    message_box(NULL, buf, _("Print"), RESPONS_ERROR);
    g_error_free(error);
  } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
    if (PrintSettings)
      g_object_unref(PrintSettings);
    PrintSettings = g_object_ref(gtk_print_operation_get_print_settings(print));
  }
  g_object_unref(print);

  delobj(graobj, id);
  delobj(g2wobj, g2wid);

  if (select_file && NgraphApp.FileWin.data.data) {
    FileWinUpdate(NgraphApp.FileWin.data.data, TRUE);
  }
}