/*! \brief Export a print-style PDF file of the current page. * \par Function Description * Exports the current page as a PDF file to \a filename. The * export is carried out using a normal paper size and margins, as if * printing. * * \param w_current A #GschemToplevel structure. * \param filename The filename for generated PDF. * * \returns TRUE if the operation was successful. */ gboolean x_print_export_pdf_page (GschemToplevel *w_current, const gchar *filename) { PAGE *page; cairo_surface_t *surface; cairo_status_t status; cairo_t *cr; GtkPageSetup *setup; double width, height; EdaConfig *cfg; gboolean is_color; page = w_current->toplevel->page_current; setup = x_print_default_page_setup (w_current->toplevel, page ); width = gtk_page_setup_get_paper_width (setup, GTK_UNIT_POINTS); height = gtk_page_setup_get_paper_height (setup, GTK_UNIT_POINTS); surface = cairo_pdf_surface_create (filename, width, height); cr = cairo_create (surface); cairo_translate (cr, gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS), gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS)); width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); /* Find out if colour printing is enabled */ cfg = eda_config_get_context_for_path (s_page_get_filename (page)); is_color = !eda_config_get_boolean (cfg, CFG_GROUP_PRINTING, CFG_KEY_PRINTING_MONOCHROME, NULL); x_print_draw_page (w_current->toplevel, page, cr, NULL, width, height, is_color, FALSE); cairo_destroy (cr); cairo_surface_finish (surface); status = cairo_surface_status (surface); if (status != CAIRO_STATUS_SUCCESS) { g_warning (_("Failed to write PDF to '%s': %s\n"), filename, cairo_status_to_string (status)); return FALSE; } g_object_unref (setup); cairo_surface_destroy (surface); return TRUE; }
/*! \par Function Description * * Initialize widgets management. * Call this before any other functions from this file. * This function reads the value of "use-docks" configuration * setting in "schematic.gui" group, which determines * if widgets will be shown in docks (if true) or as * dialog boxes (if false). * * Configuration setting description: * key: use-docks * group: schematic.gui * type: boolean * default value: true * * \return TRUE if use-docks option is set to true, FALSE otherwise. */ void x_widgets_init() { gchar* cwd = g_get_current_dir(); EdaConfig* cfg = eda_config_get_context_for_path (cwd); g_free (cwd); if (cfg != NULL) { GError* err = NULL; gboolean val = eda_config_get_boolean (cfg, "schematic.gui", "use-docks", &err); if (err == NULL) { g_x_widgets_use_docks = val; } g_clear_error (&err); } }
/*! Drawing callback for use with GtkPrintOperation. */ static void draw_page__print_operation (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, gpointer user_data) { GschemToplevel *w_current = (GschemToplevel *) user_data; PAGE *page; cairo_t *cr; PangoContext *pc; double width, height; EdaConfig *cfg; gboolean is_color; /* Find the page data */ g_return_if_fail (page_nr != 1); page = w_current->toplevel->page_current; g_return_if_fail (page != NULL); /* Get cairo & pango contexts */ cr = gtk_print_context_get_cairo_context (context); pc = gtk_print_context_create_pango_context (context); width = gtk_print_context_get_width (context); height = gtk_print_context_get_height (context); /* Find out if colour printing is enabled */ cfg = eda_config_get_context_for_path (s_page_get_filename (page)); is_color = !eda_config_get_boolean (cfg, CFG_GROUP_PRINTING, CFG_KEY_PRINTING_MONOCHROME, NULL); x_print_draw_page (w_current->toplevel, page, cr, pc, width, height, is_color, FALSE); /* Clean up */ g_object_unref (pc); }
/* Initialise settings from config store. */ static void export_config (void) { EdaConfig *cfg = eda_config_get_context_for_file (NULL); gchar *str; gdouble *lst; gdouble dval; gdouble bval; gsize n; GError *err = NULL; /* Parse orientation */ str = eda_config_get_string (cfg, "export", "layout", NULL); export_parse_layout (str); /* Don't care if it works */ g_free (str); /* Parse paper size */ str = eda_config_get_string (cfg, "export", "paper", NULL); export_parse_paper (str); g_free (str); /* Parse specific size setting -- always in points */ if (eda_config_has_key (cfg, "export", "size", NULL)) { lst = eda_config_get_double_list (cfg, "export", "size", &n, NULL); if (lst != NULL) { if (n >= 2) { memcpy (settings.size, lst, 2*sizeof(gdouble)); } g_free (lst); } /* Since a specific size was provided, ditch the paper size * setting */ if (settings.paper != NULL) { gtk_paper_size_free (settings.paper); settings.paper = NULL; } } /* Parse margins -- always in points */ lst = eda_config_get_double_list (cfg, "export", "margins", &n, NULL); if (lst != NULL) { if (n >= 4) { /* In the config file all four sides must be specified */ memcpy (settings.margins, lst, 4*sizeof(gdouble)); } g_free (lst); } /* Parse alignment */ lst = eda_config_get_double_list (cfg, "export", "align", &n, NULL); if (lst != NULL) { if (n >= 2) { /* Both halign and valign must be specified */ memcpy (settings.align, lst, 2*sizeof(gdouble)); } g_free (lst); } /* Parse dpi */ dval = eda_config_get_double (cfg, "export", "dpi", &err); if (err == NULL) { settings.dpi = dval; } else { g_clear_error (&err); } bval = eda_config_get_boolean (cfg, "export", "monochrome", &err); if (err == NULL) { settings.color = !bval; } else { g_clear_error (&err); } str = eda_config_get_string (cfg, "export", "font", NULL); if (str != NULL) { g_free (settings.font); settings.font = str; } }
void s_traverse_sheet (TOPLEVEL * pr_current, const GList *obj_list, char *hierarchy_tag) { NETLIST *netlist; char *temp; SCM scm_uref; char *temp_uref; gboolean is_hierarchy = TRUE; const GList *iter; GError *err = NULL; EdaConfig *cfg; cfg = eda_config_get_context_for_file (NULL); is_hierarchy = eda_config_get_boolean (cfg, "gnetlist", "traverse-hierarchy", &err); if (err != NULL) { is_hierarchy = TRUE; g_clear_error (&err); } if (verbose_mode) { printf("- Starting internal netlist creation\n"); } for (iter = obj_list; iter != NULL; iter = g_list_next (iter)) { OBJECT *o_current = iter->data; netlist = s_netlist_return_tail(netlist_head); if (o_current->type == OBJ_PLACEHOLDER) { printf(_("WARNING: Found a placeholder/missing component, are you missing a symbol file? [%s]\n"), o_current->complex_basename); } if (o_current->type == OBJ_COMPLEX) { gboolean is_graphical = FALSE; #if DEBUG printf("starting NEW component\n\n"); #endif verbose_print(" C"); /* look for special tag */ temp = o_attrib_search_object_attribs_by_name (o_current, "graphical", 0); if (g_strcmp0 (temp, "1") == 0) { /* traverse graphical elements, but adding them to the graphical netlist */ netlist = s_netlist_return_tail(graphical_netlist_head); is_graphical = TRUE; } g_free (temp); netlist = s_netlist_add(netlist); netlist->nlid = o_current->sid; scm_uref = g_scm_c_get_uref(pr_current, o_current); if (scm_is_string( scm_uref )) { temp_uref = scm_to_utf8_string (scm_uref); netlist->component_uref = s_hierarchy_create_uref(pr_current, temp_uref, hierarchy_tag); g_free(temp_uref); } else { if (hierarchy_tag) { netlist->component_uref = g_strdup (hierarchy_tag); } else { netlist->component_uref = NULL; } } if (hierarchy_tag) { netlist->hierarchy_tag = g_strdup (hierarchy_tag); } netlist->object_ptr = o_current; if (!netlist->component_uref) { /* search of net attribute */ /* maybe symbol is not a component */ /* but a power / gnd symbol */ temp = o_attrib_search_object_attribs_by_name (o_current, "net", 0); /* nope net attribute not found */ if ( (!temp) && (!is_graphical) ) { fprintf(stderr, _("Could not find refdes on component and could not find any special attributes!\n")); netlist->component_uref = g_strdup("U?"); } else { #if DEBUG printf("yeah... found a power symbol\n"); #endif /* it's a power or some other special symbol */ netlist->component_uref = NULL; g_free(temp); } } netlist->cpins = s_traverse_component(pr_current, o_current, hierarchy_tag); /* here is where you deal with the */ /* net attribute */ s_netattrib_handle(pr_current, o_current, netlist, hierarchy_tag); /* now you need to traverse any underlying schematics */ if (is_hierarchy) { s_hierarchy_traverse(pr_current, o_current, netlist); } } } verbose_done(); }
/*! \brief Initialize GschemBottomWidget instance * * \param [in,out] view the gschem page view */ static void gschem_bottom_widget_init (GschemBottomWidget *widget) { GtkWidget *separator; g_return_if_fail (widget != NULL); widget->left_button_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->left_button_label, _("Left mouse button")); gtk_misc_set_padding (GTK_MISC (widget->left_button_label), LABEL_XPAD, LABEL_YPAD); widget->middle_button_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->middle_button_label, _("Middle mouse button")); gtk_misc_set_padding (GTK_MISC (widget->middle_button_label), LABEL_XPAD, LABEL_YPAD); widget->right_button_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->right_button_label, _("Right mouse button")); gtk_misc_set_padding (GTK_MISC (widget->right_button_label), LABEL_XPAD, LABEL_YPAD); /* default values for configuration settings: */ gboolean show_mouse_indicators = TRUE; gboolean show_rubber_band_indicator = FALSE; gboolean show_magnetic_net_indicator = FALSE; gdk_color_parse ("black", &widget->status_inactive_color); gdk_color_parse ("green", &widget->status_active_color); widget->status_bold_font = FALSE; gchar* cwd = g_get_current_dir(); EdaConfig* cfg = eda_config_get_context_for_path (cwd); g_free (cwd); if (cfg != NULL) { GError* err = NULL; gboolean val = FALSE; /* mouse indicators: */ val = eda_config_get_boolean (cfg, "schematic.status-bar", "show-mouse-buttons", &err); if (err == NULL) show_mouse_indicators = val; g_clear_error (&err); /* net rubber band indicator: */ val = eda_config_get_boolean (cfg, "schematic.status-bar", "show-rubber-band", &err); if (err == NULL) show_rubber_band_indicator = val; g_clear_error (&err); /* magnetic net indicator: */ val = eda_config_get_boolean (cfg, "schematic.status-bar", "show-magnetic-net", &err); if (err == NULL) show_magnetic_net_indicator = val; g_clear_error (&err); /* status line active color: */ gchar* color = eda_config_get_string (cfg, "schematic.status-bar", "status-active-color", &err); if (color != NULL) { gdk_color_parse (color, &widget->status_active_color); g_free (color); } g_clear_error (&err); /* status line bold font: */ val = eda_config_get_boolean (cfg, "schematic.status-bar", "status-bold-font", &err); if (err == NULL) widget->status_bold_font = val; g_clear_error (&err); } if (show_mouse_indicators) { gtk_box_pack_start (GTK_BOX (widget), widget->left_button_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (widget), gtk_vseparator_new(), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (widget), widget->middle_button_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (widget), gtk_vseparator_new(), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (widget), widget->right_button_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (widget), gtk_vseparator_new(), FALSE, FALSE, 0); } widget->grid_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->grid_label, _("(Snap size, Grid size)")); gtk_misc_set_padding (GTK_MISC (widget->grid_label), LABEL_XPAD, LABEL_YPAD); gtk_box_pack_start (GTK_BOX (widget), widget->grid_label, FALSE, FALSE, 0); separator = gtk_vseparator_new (); gtk_box_pack_start (GTK_BOX (widget), separator, FALSE, FALSE, 0); widget->rubber_band_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->rubber_band_label, _("Net rubber band mode")); gtk_misc_set_padding (GTK_MISC (widget->rubber_band_label), LABEL_XPAD, LABEL_YPAD); if (show_rubber_band_indicator) { gtk_box_pack_start (GTK_BOX (widget), widget->rubber_band_label, FALSE, FALSE, 0); } separator = gtk_vseparator_new (); gtk_box_pack_start (GTK_BOX (widget), separator, FALSE, FALSE, 0); widget->magnetic_net_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->magnetic_net_label, _("Magnetic net mode")); gtk_misc_set_padding (GTK_MISC (widget->magnetic_net_label), LABEL_XPAD, LABEL_YPAD); if (show_magnetic_net_indicator) { gtk_box_pack_start (GTK_BOX (widget), widget->magnetic_net_label, FALSE, FALSE, 0); } widget->status_label = gtk_label_new (NULL); gtk_widget_set_tooltip_text (widget->status_label, _("Current action mode")); gtk_misc_set_padding (GTK_MISC (widget->status_label), LABEL_XPAD, LABEL_YPAD); gtk_box_pack_end (GTK_BOX (widget), widget->status_label, FALSE, FALSE, 0); separator = gtk_vseparator_new (); gtk_box_pack_start (GTK_BOX (widget), separator, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "notify::grid-mode", G_CALLBACK (update_grid_label), NULL); g_signal_connect (G_OBJECT (widget), "notify::grid-size", G_CALLBACK (update_grid_label), NULL); g_signal_connect (G_OBJECT (widget), "notify::snap-mode", G_CALLBACK (update_grid_label), NULL); g_signal_connect (G_OBJECT (widget), "notify::snap-size", G_CALLBACK (update_grid_label), NULL); g_signal_connect (G_OBJECT (widget), "notify::net-rubber-band-mode", G_CALLBACK (update_rubber_band_label), NULL); g_signal_connect (G_OBJECT (widget), "notify::magnetic-net-mode", G_CALLBACK (update_magnetic_net_label), NULL); }