From: Jim Evins Date: Fri, 3 Jan 2003 05:22:30 +0000 (+0000) Subject: Added support for "Other" page sizes. Template sheets with a page size of "Other... X-Git-Tag: glabels-2_3_0~652 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2a1ec544be08cf7cf5e0d1c801627d73aa0b5424;p=glabels Added support for "Other" page sizes. Template sheets with a page size of "Other" should also have the height and width properties set. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@236 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 305982ee..d44661c9 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -383,9 +383,8 @@ static PrintInfo * print_info_new (GnomePrintMaster *master, glLabel *label) { - PrintInfo *pi = g_new0 (PrintInfo, 1); - glTemplate *template; - const GnomePrintPaper *paper = NULL; + PrintInfo *pi = g_new0 (PrintInfo, 1); + glTemplate *template; gl_debug (DEBUG_PRINT, "START"); @@ -404,34 +403,31 @@ print_info_new (GnomePrintMaster *master, gl_debug (DEBUG_PRINT, "setting page size = \"%s\"", template->page_size); - - /* Currently cannot set page size directly from name, */ - /* since we must set Ids not Names and there is no */ - /* way to do the reverse lookup of Id from Name. */ - /* Sometimes they are the same, but not always */ - /* (e.g. for the name "US Letter" id="USLetter" */ - /* So we use the "Custom" Id. */ - paper = gnome_print_paper_get_by_name (template->page_size); + /* Currently cannot set page size directly from name, */ + /* since we must set Ids not Names and there is no */ + /* way to do the reverse lookup of Id from Name. */ + /* Sometimes they are the same, but not always */ + /* (e.g. for the name "US Letter" id="USLetter" */ + /* So we always use the "Custom" Id. */ gnome_print_config_set (pi->config, GNOME_PRINT_KEY_PAPER_SIZE, "Custom"); gnome_print_config_set_length (pi->config, GNOME_PRINT_KEY_PAPER_WIDTH, - paper->width, + template->page_width, GNOME_PRINT_PS_UNIT); gnome_print_config_set_length (pi->config, GNOME_PRINT_KEY_PAPER_HEIGHT, - paper->height, + template->page_height, GNOME_PRINT_PS_UNIT); } else { g_warning ("Cannot determine correct page size."); - paper = gnome_print_paper_get_by_name (GL_PRINT_DEFAULT_PAPER); gnome_print_config_set (pi->config, GNOME_PRINT_KEY_PAPER_SIZE, GL_PRINT_DEFAULT_PAPER); } - pi->page_width = paper->width; - pi->page_height = paper->height; + pi->page_width = template->page_width; + pi->page_height = template->page_height; pi->template = template; pi->label_rotate_flag = gl_label_get_rotate_flag (label); diff --git a/glabels2/src/template.c b/glabels2/src/template.c index 29045b1a..8a784c2d 100644 --- a/glabels2/src/template.c +++ b/glabels2/src/template.c @@ -51,61 +51,61 @@ static GList *templates = NULL; /*===========================================*/ /* Local function prototypes */ /*===========================================*/ -static glTemplate *template_full_page (const gchar *page_size); +static glTemplate *template_full_page (const gchar *page_size); static GList *read_templates (void); static gchar *get_home_data_dir (void); -static GList *read_template_files_from_dir (GList *templates, - const gchar *dirname); -static GList *read_templates_from_file (GList *templates, - gchar *xml_filename); - -static void xml_parse_label (xmlNodePtr label_node, - glTemplate *template); -static void xml_parse_layout (xmlNodePtr layout_node, - glTemplate *template); -static void xml_parse_markup (xmlNodePtr markup_node, - glTemplate *template); -static void xml_parse_alias (xmlNodePtr alias_node, - glTemplate *template); - -static void xml_add_label (const glTemplate *template, - xmlNodePtr root, - xmlNsPtr ns); -static void xml_add_layout (glTemplateLayout *layout, - xmlNodePtr root, - xmlNsPtr ns); +static GList *read_template_files_from_dir (GList *templates, + const gchar *dirname); +static GList *read_templates_from_file (GList *templates, + gchar *xml_filename); + +static void xml_parse_label (xmlNodePtr label_node, + glTemplate *template); +static void xml_parse_layout (xmlNodePtr layout_node, + glTemplate *template); +static void xml_parse_markup (xmlNodePtr markup_node, + glTemplate *template); +static void xml_parse_alias (xmlNodePtr alias_node, + glTemplate *template); + +static void xml_add_label (const glTemplate *template, + xmlNodePtr root, + xmlNsPtr ns); +static void xml_add_layout (glTemplateLayout *layout, + xmlNodePtr root, + xmlNsPtr ns); static void xml_add_markup_margin (glTemplateMarkupMargin *margin, - xmlNodePtr root, - xmlNsPtr ns); -static void xml_add_markup_line (glTemplateMarkupLine *line, - xmlNodePtr root, - xmlNsPtr ns); -static void xml_add_alias (gchar *name, - xmlNodePtr root, - xmlNsPtr ns); - -static gint compare_origins (gconstpointer a, - gconstpointer b, - gpointer user_data); - -static glTemplateLayout *layout_new (gdouble nx, - gdouble ny, - gdouble x0, - gdouble y0, - gdouble dx, - gdouble dy); -static glTemplateLayout *layout_dup (glTemplateLayout *orig_layout); -static void layout_free (glTemplateLayout **layout); - -static glTemplateMarkup *markup_margin_new (gdouble size); -static glTemplateMarkup *markup_line_new (gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2); -static glTemplateMarkup *markup_dup (glTemplateMarkup *orig_markup); -static void markup_free (glTemplateMarkup **markup); + xmlNodePtr root, + xmlNsPtr ns); +static void xml_add_markup_line (glTemplateMarkupLine *line, + xmlNodePtr root, + xmlNsPtr ns); +static void xml_add_alias (gchar *name, + xmlNodePtr root, + xmlNsPtr ns); + +static gint compare_origins (gconstpointer a, + gconstpointer b, + gpointer user_data); + +static glTemplateLayout *layout_new (gdouble nx, + gdouble ny, + gdouble x0, + gdouble y0, + gdouble dx, + gdouble dy); +static glTemplateLayout *layout_dup (glTemplateLayout *orig_layout); +static void layout_free (glTemplateLayout **layout); + +static glTemplateMarkup *markup_margin_new (gdouble size); +static glTemplateMarkup *markup_line_new (gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2); +static glTemplateMarkup *markup_dup (glTemplateMarkup *orig_markup); +static void markup_free (glTemplateMarkup **markup); /*****************************************************************************/ /* Initialize module. */ @@ -121,8 +121,10 @@ gl_template_init (void) page_sizes = gl_template_get_page_size_list (); for ( p=page_sizes; p != NULL; p=p->next ) { - templates = g_list_append (templates, - template_full_page (p->data)); + if ( g_strcasecmp(p->data, "Other") != 0 ) { + templates = g_list_append (templates, + template_full_page (p->data)); + } } gl_template_free_page_size_list (&page_sizes); @@ -135,8 +137,8 @@ gl_template_init (void) GList * gl_template_get_page_size_list (void) { - GList *names = NULL; - GList *p, *paper_list; + GList *names = NULL; + GList *p, *paper_list; GnomePrintPaper *paper; gl_debug (DEBUG_TEMPLATE, "START"); @@ -149,6 +151,8 @@ gl_template_get_page_size_list (void) } } + names = g_list_append (names, g_strdup ("Other")); + gl_debug (DEBUG_TEMPLATE, "END"); return names; } @@ -157,7 +161,7 @@ gl_template_get_page_size_list (void) /* Free a list of page size names. */ /*****************************************************************************/ void -gl_template_free_page_size_list (GList ** names) +gl_template_free_page_size_list (GList **names) { GList *p_name; @@ -178,12 +182,12 @@ gl_template_free_page_size_list (GList ** names) /* Get a list of valid template names for given page size */ /*****************************************************************************/ GList * -gl_template_get_name_list (const gchar * page_size) +gl_template_get_name_list (const gchar *page_size) { - GList *p_tmplt, *p_name; + GList *p_tmplt, *p_name; glTemplate *template; - gchar *str; - GList *names = NULL; + gchar *str; + GList *names = NULL; gl_debug (DEBUG_TEMPLATE, "START"); @@ -212,7 +216,7 @@ gl_template_get_name_list (const gchar * page_size) /* Free a list of template names. */ /*****************************************************************************/ void -gl_template_free_name_list (GList ** names) +gl_template_free_name_list (GList **names) { GList *p_name; @@ -233,11 +237,11 @@ gl_template_free_name_list (GList ** names) /* Return a template structure from a name. */ /*****************************************************************************/ glTemplate * -gl_template_from_name (const gchar * name) +gl_template_from_name (const gchar *name) { - GList *p_tmplt, *p_name; - glTemplate *template; - gchar **split_name; + GList *p_tmplt, *p_name; + glTemplate *template; + gchar **split_name; gl_debug (DEBUG_TEMPLATE, "START"); @@ -287,6 +291,8 @@ glTemplate *gl_template_dup (const glTemplate *orig_template) } template->description = g_strdup (orig_template->description); template->page_size = g_strdup (orig_template->page_size); + template->page_width = orig_template->page_width; + template->page_height = orig_template->page_height; template->label = orig_template->label; @@ -361,7 +367,7 @@ static glTemplate * template_full_page (const gchar *page_size) { const GnomePrintPaper *paper; - glTemplate *template; + glTemplate *template; paper = gnome_print_paper_get_by_name (page_size); if ( paper == NULL ) { @@ -374,6 +380,8 @@ template_full_page (const gchar *page_size) g_strdup_printf(_("Generic %s full page"), page_size)); template->page_size = g_strdup(page_size); + template->page_width = paper->width; + template->page_height = paper->height; template->description = g_strdup(FULL_PAGE); template->label.style = GL_TEMPLATE_STYLE_RECT; @@ -439,13 +447,13 @@ get_home_data_dir (void) /* PRIVATE. Read all template files from given directory. Append to list. */ /*--------------------------------------------------------------------------*/ static GList * -read_template_files_from_dir (GList * templates, - const gchar * dirname) +read_template_files_from_dir (GList *templates, + const gchar *dirname) { - GDir *dp; + GDir *dp; const gchar *filename, *extension; - gchar *full_filename = NULL; - GError *gerror = NULL; + gchar *full_filename = NULL; + GError *gerror = NULL; gl_debug (DEBUG_TEMPLATE, "START"); @@ -490,11 +498,11 @@ read_template_files_from_dir (GList * templates, /* PRIVATE. Read templates from template file. */ /*--------------------------------------------------------------------------*/ static GList * -read_templates_from_file (GList * templates, - gchar * xml_filename) +read_templates_from_file (GList *templates, + gchar *xml_filename) { - xmlDocPtr doc; - xmlNodePtr root, node; + xmlDocPtr doc; + xmlNodePtr root, node; glTemplate *template; gl_debug (DEBUG_TEMPLATE, "START"); @@ -546,8 +554,9 @@ read_templates_from_file (GList * templates, glTemplate * gl_template_xml_parse_sheet (xmlNodePtr sheet_node) { - glTemplate *template; - xmlNodePtr node; + glTemplate *template; + xmlNodePtr node; + const GnomePrintPaper *paper; gl_debug (DEBUG_TEMPLATE, "START"); @@ -559,9 +568,23 @@ gl_template_xml_parse_sheet (xmlNodePtr sheet_node) template->page_size = xmlGetProp (sheet_node, "size"); if ( strcmp (template->page_size,"US-Letter") == 0 ) { - /* Compatibility with old pre-1.0 template files.*/ template->page_size = "US Letter"; } + if (g_strcasecmp (template->page_size, "Other") == 0) { + template->page_width = + g_strtod (xmlGetProp (sheet_node, "width"), NULL); + template->page_height = + g_strtod (xmlGetProp (sheet_node, "height"), NULL); + } else { + paper = gnome_print_paper_get_by_name (template->page_size); + if (paper != NULL) { + template->page_width = paper->width; + template->page_height = paper->height; + } else { + g_warning (_("Unknown page size \"%s\""), template->page_size); + } + } + template->description = xmlGetProp (sheet_node, "description"); for (node = sheet_node->xmlChildrenNode; node != NULL; @@ -586,8 +609,8 @@ gl_template_xml_parse_sheet (xmlNodePtr sheet_node) /* PRIVATE. Parse XML Sheet->Label Node. */ /*--------------------------------------------------------------------------*/ static void -xml_parse_label (xmlNodePtr label_node, - glTemplate * template) +xml_parse_label (xmlNodePtr label_node, + glTemplate *template) { xmlNodePtr node; gchar *style; @@ -663,11 +686,11 @@ xml_parse_label (xmlNodePtr label_node, /* PRIVATE. Parse XML Sheet->Label->Layout Node. */ /*--------------------------------------------------------------------------*/ static void -xml_parse_layout (xmlNodePtr layout_node, - glTemplate * template) +xml_parse_layout (xmlNodePtr layout_node, + glTemplate *template) { - gint nx, ny; - gdouble x0, y0, dx, dy; + gint nx, ny; + gdouble x0, y0, dx, dy; xmlNodePtr node; gl_debug (DEBUG_TEMPLATE, "START"); @@ -697,13 +720,13 @@ xml_parse_layout (xmlNodePtr layout_node, /* PRIVATE. Parse XML Sheet->Label->Markup Node. */ /*--------------------------------------------------------------------------*/ static void -xml_parse_markup (xmlNodePtr markup_node, - glTemplate * template) +xml_parse_markup (xmlNodePtr markup_node, + glTemplate *template) { - gchar *type; - gdouble size; - gdouble x1, y1, x2, y2; - xmlNodePtr node; + gchar *type; + gdouble size; + gdouble x1, y1, x2, y2; + xmlNodePtr node; gl_debug (DEBUG_TEMPLATE, "START"); @@ -737,8 +760,8 @@ xml_parse_markup (xmlNodePtr markup_node, /* PRIVATE. Parse XML Sheet->Alias Node. */ /*--------------------------------------------------------------------------*/ static void -xml_parse_alias (xmlNodePtr alias_node, - glTemplate * template) +xml_parse_alias (xmlNodePtr alias_node, + glTemplate *template) { gl_debug (DEBUG_TEMPLATE, "START"); @@ -752,19 +775,32 @@ xml_parse_alias (xmlNodePtr alias_node, /* Add XML Template Node */ /****************************************************************************/ void -gl_template_xml_add_sheet (const glTemplate * template, - xmlNodePtr root, - xmlNsPtr ns) +gl_template_xml_add_sheet (const glTemplate *template, + xmlNodePtr root, + xmlNsPtr ns) { - xmlNodePtr node; - GList *p; + xmlNodePtr node; + GList *p; + gchar *string; gl_debug (DEBUG_TEMPLATE, "START"); node = xmlNewChild (root, ns, "Sheet", NULL); xmlSetProp (node, "name", template->name->data); + xmlSetProp (node, "size", template->page_size); + if (g_strcasecmp (template->page_size, "Other") == 0) { + + string = g_strdup_printf ("%g", template->page_width); + xmlSetProp (node, "width", string); + g_free (string); + + string = g_strdup_printf ("%g", template->page_height); + xmlSetProp (node, "height", string); + g_free (string); + } + xmlSetProp (node, "description", template->description); xml_add_label (template, node, ns); @@ -781,12 +817,12 @@ gl_template_xml_add_sheet (const glTemplate * template, /*--------------------------------------------------------------------------*/ static void xml_add_label (const glTemplate *template, - xmlNodePtr root, - xmlNsPtr ns) + xmlNodePtr root, + xmlNsPtr ns) { - xmlNodePtr node; - gchar *string; - GList *p; + xmlNodePtr node; + gchar *string; + GList *p; glTemplateMarkup *markup; glTemplateLayout *layout; @@ -869,11 +905,11 @@ xml_add_label (const glTemplate *template, /*--------------------------------------------------------------------------*/ static void xml_add_layout (glTemplateLayout *layout, - xmlNodePtr root, - xmlNsPtr ns) + xmlNodePtr root, + xmlNsPtr ns) { - xmlNodePtr node; - gchar *string; + xmlNodePtr node; + gchar *string; gl_debug (DEBUG_TEMPLATE, "START"); @@ -905,11 +941,11 @@ xml_add_layout (glTemplateLayout *layout, /*--------------------------------------------------------------------------*/ static void xml_add_markup_margin (glTemplateMarkupMargin *margin, - xmlNodePtr root, - xmlNsPtr ns) + xmlNodePtr root, + xmlNsPtr ns) { - xmlNodePtr node; - gchar *string; + xmlNodePtr node; + gchar *string; gl_debug (DEBUG_TEMPLATE, "START"); @@ -928,11 +964,11 @@ xml_add_markup_margin (glTemplateMarkupMargin *margin, /*--------------------------------------------------------------------------*/ static void xml_add_markup_line (glTemplateMarkupLine *line, - xmlNodePtr root, - xmlNsPtr ns) + xmlNodePtr root, + xmlNsPtr ns) { - xmlNodePtr node; - gchar *string; + xmlNodePtr node; + gchar *string; gl_debug (DEBUG_TEMPLATE, "START"); @@ -959,9 +995,9 @@ xml_add_markup_line (glTemplateMarkupLine *line, /* PRIVATE. Add XML Sheet->Alias Node. */ /*--------------------------------------------------------------------------*/ static void -xml_add_alias (gchar *name, - xmlNodePtr root, - xmlNsPtr ns) +xml_add_alias (gchar *name, + xmlNodePtr root, + xmlNsPtr ns) { xmlNodePtr node; @@ -979,10 +1015,10 @@ xml_add_alias (gchar *name, gchar * gl_template_get_label_size_desc (const glTemplate *template) { - glPrefsUnits units; - const gchar *units_string; - gdouble units_per_point; - gchar *string = NULL; + glPrefsUnits units; + const gchar *units_string; + gdouble units_per_point; + gchar *string = NULL; units = gl_prefs_get_units (); units_string = gl_prefs_get_units_string (); @@ -1083,8 +1119,8 @@ gl_template_get_label_size (const glTemplate *template, gint gl_template_get_n_labels (const glTemplate *template) { - gint n_labels = 0; - GList *p; + gint n_labels = 0; + GList *p; glTemplateLayout *layout; for ( p=template->label.any.layouts; p != NULL; p=p->next ) { @@ -1102,9 +1138,9 @@ gl_template_get_n_labels (const glTemplate *template) glTemplateOrigin * gl_template_get_origins (const glTemplate *template) { - gint i_label, n_labels, ix, iy; + gint i_label, n_labels, ix, iy; glTemplateOrigin *origins; - GList *p; + GList *p; glTemplateLayout *layout; n_labels = gl_template_get_n_labels (template); @@ -1134,7 +1170,7 @@ gl_template_get_origins (const glTemplate *template) static gint compare_origins (gconstpointer a, gconstpointer b, - gpointer user_data) + gpointer user_data) { const glTemplateOrigin *a_origin = a, *b_origin = b; @@ -1159,9 +1195,9 @@ compare_origins (gconstpointer a, gchar * gl_template_get_layout_desc (const glTemplate *template) { - gint n_labels; + gint n_labels; glTemplateLayout *layout; - gchar *string; + gchar *string; n_labels = gl_template_get_n_labels (template); diff --git a/glabels2/src/template.h b/glabels2/src/template.h index 6006ea83..d9e596a0 100644 --- a/glabels2/src/template.h +++ b/glabels2/src/template.h @@ -120,6 +120,8 @@ typedef struct { GList *name; gchar *description; gchar *page_size; + gdouble page_width; + gdouble page_height; glTemplateLabel label; diff --git a/glabels2/src/wdgt-media-select.c b/glabels2/src/wdgt-media-select.c index c3e455d4..0ef77192 100644 --- a/glabels2/src/wdgt-media-select.c +++ b/glabels2/src/wdgt-media-select.c @@ -58,19 +58,19 @@ static gint wdgt_media_select_signals[LAST_SIGNAL] = { 0 }; /* Local function prototypes */ /*===========================================*/ -static void gl_wdgt_media_select_class_init (glWdgtMediaSelectClass * class); -static void gl_wdgt_media_select_instance_init (glWdgtMediaSelect * media_select); -static void gl_wdgt_media_select_finalize (GObject * object); +static void gl_wdgt_media_select_class_init (glWdgtMediaSelectClass *class); +static void gl_wdgt_media_select_instance_init (glWdgtMediaSelect *media_select); +static void gl_wdgt_media_select_finalize (GObject *object); -static void gl_wdgt_media_select_construct (glWdgtMediaSelect * media_select); +static void gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select); -static void page_size_entry_changed_cb (GtkEntry * entry, - gpointer user_data); -static void template_entry_changed_cb (GtkEntry * entry, - gpointer user_data); +static void page_size_entry_changed_cb (GtkEntry *entry, + gpointer user_data); +static void template_entry_changed_cb (GtkEntry *entry, + gpointer user_data); -static void details_update (glWdgtMediaSelect * media_select, - gchar * name); +static void details_update (glWdgtMediaSelect *media_select, + gchar *name); /****************************************************************************/ /* Boilerplate Object stuff. */ @@ -103,7 +103,7 @@ gl_wdgt_media_select_get_type (void) } static void -gl_wdgt_media_select_class_init (glWdgtMediaSelectClass * class) +gl_wdgt_media_select_class_init (glWdgtMediaSelectClass *class) { GObjectClass *object_class; @@ -128,7 +128,7 @@ gl_wdgt_media_select_class_init (glWdgtMediaSelectClass * class) } static void -gl_wdgt_media_select_instance_init (glWdgtMediaSelect * media_select) +gl_wdgt_media_select_instance_init (glWdgtMediaSelect *media_select) { gl_debug (DEBUG_MEDIA_SELECT, "START"); @@ -146,7 +146,7 @@ gl_wdgt_media_select_instance_init (glWdgtMediaSelect * media_select) } static void -gl_wdgt_media_select_finalize (GObject * object) +gl_wdgt_media_select_finalize (GObject *object) { glWdgtMediaSelect *media_select; glWdgtMediaSelectClass *class; @@ -183,13 +183,13 @@ gl_wdgt_media_select_new (void) /* PRIVATE. Construct composite widget. */ /*--------------------------------------------------------------------------*/ static void -gl_wdgt_media_select_construct (glWdgtMediaSelect * media_select) +gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) { - GtkWidget *whbox, *wvbox, *wcombo, *wvbox1, *whbox1, *wlabel; + GtkWidget *whbox, *wvbox, *wcombo, *wvbox1, *whbox1, *wlabel; GtkSizeGroup *label_size_group; - gchar *name; - GList *template_names, *page_sizes = NULL; - const gchar *page_size; + gchar *name; + GList *template_names, *page_sizes = NULL; + const gchar *page_size; gl_debug (DEBUG_MEDIA_SELECT, "START"); @@ -324,12 +324,12 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect * media_select) /* PRIVATE. modify widget due to change in selection */ /*--------------------------------------------------------------------------*/ static void -page_size_entry_changed_cb (GtkEntry * entry, - gpointer user_data) +page_size_entry_changed_cb (GtkEntry *entry, + gpointer user_data) { glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data); - gchar *page_size; - GList *template_names; + gchar *page_size; + GList *template_names; gl_debug (DEBUG_MEDIA_SELECT, "START"); @@ -339,6 +339,9 @@ page_size_entry_changed_cb (GtkEntry * entry, if ( strlen(page_size) ) { gl_debug (DEBUG_MEDIA_SELECT, "page_size = \"%s\"", page_size); template_names = gl_template_get_name_list (page_size); + if (template_names == NULL) { + template_names = g_list_append (template_names, g_strdup("")); + } gtk_combo_set_popdown_strings (GTK_COMBO (media_select->template_combo), template_names); gtk_entry_set_text (GTK_ENTRY (media_select->template_entry), @@ -354,8 +357,8 @@ page_size_entry_changed_cb (GtkEntry * entry, /* PRIVATE. modify widget due to change in selection */ /*--------------------------------------------------------------------------*/ static void -template_entry_changed_cb (GtkEntry * entry, - gpointer user_data) +template_entry_changed_cb (GtkEntry *entry, + gpointer user_data) { glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data); gchar *name; @@ -386,8 +389,8 @@ template_entry_changed_cb (GtkEntry * entry, /* PRIVATE. update "details" widgets from new template. */ /*--------------------------------------------------------------------------*/ static void -details_update (glWdgtMediaSelect * media_select, - gchar * name) +details_update (glWdgtMediaSelect *media_select, + gchar *name) { glTemplate *template; gchar *text; @@ -427,7 +430,7 @@ details_update (glWdgtMediaSelect * media_select, /* query selected label template name. */ /****************************************************************************/ gchar * -gl_wdgt_media_select_get_name (glWdgtMediaSelect * media_select) +gl_wdgt_media_select_get_name (glWdgtMediaSelect *media_select) { gl_debug (DEBUG_MEDIA_SELECT, ""); return @@ -439,8 +442,8 @@ gl_wdgt_media_select_get_name (glWdgtMediaSelect * media_select) /* set selected label template name. */ /****************************************************************************/ void -gl_wdgt_media_select_set_name (glWdgtMediaSelect * media_select, - gchar * name) +gl_wdgt_media_select_set_name (glWdgtMediaSelect *media_select, + gchar *name) { gint pos; @@ -466,7 +469,7 @@ gl_wdgt_media_select_set_name (glWdgtMediaSelect * media_select, /* query selected label template page size. */ /****************************************************************************/ gchar * -gl_wdgt_media_select_get_page_size (glWdgtMediaSelect * media_select) +gl_wdgt_media_select_get_page_size (glWdgtMediaSelect *media_select) { gl_debug (DEBUG_MEDIA_SELECT, ""); @@ -479,8 +482,8 @@ gl_wdgt_media_select_get_page_size (glWdgtMediaSelect * media_select) /* set selected label template page size. */ /****************************************************************************/ void -gl_wdgt_media_select_set_page_size (glWdgtMediaSelect * media_select, - gchar * page_size) +gl_wdgt_media_select_set_page_size (glWdgtMediaSelect *media_select, + gchar *page_size) { gint pos; diff --git a/glabels2/src/wdgt-media-select.h b/glabels2/src/wdgt-media-select.h index ffba0005..122fede2 100644 --- a/glabels2/src/wdgt-media-select.h +++ b/glabels2/src/wdgt-media-select.h @@ -26,6 +26,8 @@ #include #include "hig.h" +G_BEGIN_DECLS + #define GL_TYPE_WDGT_MEDIA_SELECT (gl_wdgt_media_select_get_type ()) #define GL_WDGT_MEDIA_SELECT(obj) \ (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_MEDIA_SELECT, glWdgtMediaSelect )) @@ -60,18 +62,20 @@ struct _glWdgtMediaSelectClass { void (*changed) (glWdgtMediaSelect * media_select, gpointer user_data); }; -extern guint gl_wdgt_media_select_get_type (void); +guint gl_wdgt_media_select_get_type (void); + +GtkWidget *gl_wdgt_media_select_new (void); -extern GtkWidget *gl_wdgt_media_select_new (void); +gchar *gl_wdgt_media_select_get_name (glWdgtMediaSelect *media_select); -extern gchar *gl_wdgt_media_select_get_name (glWdgtMediaSelect * media_select); +void gl_wdgt_media_select_set_name (glWdgtMediaSelect *media_select, + gchar *name); -extern void gl_wdgt_media_select_set_name (glWdgtMediaSelect * media_select, - gchar * name); +gchar *gl_wdgt_media_select_get_page_size (glWdgtMediaSelect *media_select); -extern gchar *gl_wdgt_media_select_get_page_size (glWdgtMediaSelect * media_select); +void gl_wdgt_media_select_set_page_size (glWdgtMediaSelect *media_select, + gchar *page_size); -extern void gl_wdgt_media_select_set_page_size (glWdgtMediaSelect * media_select, - gchar * page_size); +G_END_DECLS #endif diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 900ad50d..48a6e04e 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -261,38 +261,37 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, /****************************************************************************/ /* Set label for mini-preview to determine geometry. */ /****************************************************************************/ -void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview * preview, - gchar *name) +void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, + gchar *name) { glTemplate *template; - gchar *page_size; - const GnomePrintPaper *paper = NULL; - gdouble paper_width, paper_height; - gdouble canvas_scale; - gdouble w, h; - gdouble shadow_x, shadow_y; + gchar *page_size; + gdouble canvas_scale; + gdouble w, h; + gdouble shadow_x, shadow_y; gl_debug (DEBUG_MINI_PREVIEW, "START"); /* Fetch template */ template = gl_template_from_name (name); + gl_debug (DEBUG_MINI_PREVIEW, "page_size = %s, page_width = %g, page_height = %g", + template->page_size, template->page_width, template->page_height); + /* get paper size and set scale */ - paper = gnome_print_paper_get_by_name (template->page_size); - paper_width = paper->width; - paper_height = paper->height; w = preview->width - 4 - 2*SHADOW_X_OFFSET; h = preview->height - 4 - 2*SHADOW_Y_OFFSET; - if ( (w/paper_width) > (h/paper_height) ) { - canvas_scale = h / paper_height; + if ( (w/template->page_width) > (h/template->page_height) ) { + canvas_scale = h / template->page_height; } else { - canvas_scale = w / paper_width; + canvas_scale = w / template->page_width; } gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (preview->canvas), canvas_scale); #if 0 gnome_canvas_set_scroll_region (GNOME_CANVAS (preview->canvas), - 0.0, 0.0, paper_width, paper_height); + 0.0, 0.0, + template->page_width, template->page_height); #else gnome_canvas_set_scroll_region (GNOME_CANVAS (preview->canvas), 0.0, 0.0, @@ -306,14 +305,14 @@ void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview * preview, gnome_canvas_item_set (preview->shadow_item, "x1", shadow_x, "y1", shadow_y, - "x2", shadow_x + paper_width, - "y2", shadow_y + paper_height, + "x2", shadow_x + template->page_width, + "y2", shadow_y + template->page_height, NULL); /* update paper outline */ gnome_canvas_item_set (preview->paper_item, - "x2", paper_width, - "y2", paper_height, + "x2", template->page_width, + "y2", template->page_height, NULL); /* update label items */ @@ -340,15 +339,9 @@ mini_outline_list_new (GnomeCanvas *canvas, gint i, n_labels; glTemplateOrigin *origins; gdouble x1, y1, x2, y2, w, h; - const GnomePrintPaper *paper = NULL; - gdouble paper_height; gl_debug (DEBUG_MINI_PREVIEW, "START"); - /* get paper height */ - paper = gnome_print_paper_get_by_name (template->page_size); - paper_height = paper->height; - group = gnome_canvas_root (canvas); /* draw mini label outlines */ diff --git a/glabels2/src/wdgt-mini-preview.h b/glabels2/src/wdgt-mini-preview.h index db40ba01..29c22cf8 100644 --- a/glabels2/src/wdgt-mini-preview.h +++ b/glabels2/src/wdgt-mini-preview.h @@ -26,6 +26,8 @@ #include #include "label.h" +G_BEGIN_DECLS + #define GL_TYPE_WDGT_MINI_PREVIEW (gl_wdgt_mini_preview_get_type ()) #define GL_WDGT_MINI_PREVIEW(obj) \ (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_MINI_PREVIEW, glWdgtMiniPreview )) @@ -66,15 +68,17 @@ struct _glWdgtMiniPreviewClass { gpointer user_data); }; -extern guint gl_wdgt_mini_preview_get_type (void); +guint gl_wdgt_mini_preview_get_type (void); -extern GtkWidget *gl_wdgt_mini_preview_new (gint height, gint width); +GtkWidget *gl_wdgt_mini_preview_new (gint height, + gint width); -extern void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview * preview, - gchar * name); +void gl_wdgt_mini_preview_set_label (glWdgtMiniPreview *preview, + gchar *name); -extern void gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview * preview, - gint first_label, - gint last_label); +void gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview *preview, + gint first_label, + gint last_label); +G_END_DECLS #endif