Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

src/main/generic-options.c

Go to the documentation of this file.
00001 /*
00002  * "$Id: generic-options.c,v 1.7 2004/05/07 19:20:30 rleigh Exp $"
00003  *
00004  *   Copyright 2003 Robert Krawitz (rlk@alum.mit.edu)
00005  *
00006  *   This program is free software; you can redistribute it and/or modify it
00007  *   under the terms of the GNU General Public License as published by the Free
00008  *   Software Foundation; either version 2 of the License, or (at your option)
00009  *   any later version.
00010  *
00011  *   This program is distributed in the hope that it will be useful, but
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  *   for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with this program; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024 #include <gimp-print/gimp-print.h>
00025 #include "gimp-print-internal.h"
00026 #include <gimp-print/gimp-print-intl-internal.h>
00027 #include "generic-options.h"
00028 #include <string.h>
00029 #include <limits.h>
00030 
00031 static const stpi_quality_t standard_qualities[] =
00032 {
00033   { "FastEconomy", N_("Fast Economy"), 0 },
00034   { "Economy",     N_("Economy"),      1 },
00035   { "Draft",       N_("Draft"),        3 },
00036   { "Standard",    N_("Standard"),     5 },
00037   { "High",        N_("High"),         6 },
00038   { "Photo",       N_("Photo"),        7 },
00039   { "HighPhoto",   N_("Super Photo"),  8 },
00040   { "UltraPhoto",  N_("Ultra Photo"),  9 },
00041   { "Best",        N_("Best"),        10 },
00042 };
00043 
00044 static const stpi_image_type_t standard_image_types[] =
00045 {
00046   { "Text",         N_("Text") },
00047   { "Graphics",     N_("Graphics") },
00048   { "TextGraphics", N_("Mixed Text and Graphics") },
00049   { "Photo",        N_("Photograph") },
00050   { "LineArt",      N_("Line Art") },
00051 };
00052 
00053 static const stpi_job_mode_t standard_job_modes[] =
00054 {
00055   { "Page",         N_("Page") },
00056   { "Job",          N_("Job") },
00057 };
00058 
00059 static const stp_parameter_t the_parameters[] =
00060 {
00061   {
00062     "Quality", N_("Print Quality"), N_("Basic Output Adjustment"),
00063     N_("Print Quality"),
00064     STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE,
00065     STP_PARAMETER_LEVEL_BASIC, 1, 1, -1, 0, 0
00066   },
00067   {
00068     "ImageType", N_("Image Type"), N_("Basic Image Adjustment"),
00069     N_("Type of image being printed"),
00070     STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_OUTPUT,
00071     STP_PARAMETER_LEVEL_BASIC, 1, 1, -1, 0, 0
00072   },
00073   {
00074     "JobMode", N_("Job Mode"), N_("Job Mode"),
00075     N_("Job vs. page mode"),
00076     STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE,
00077     STP_PARAMETER_LEVEL_BASIC, 1, 1, -1, 0, 0
00078   },
00079   {
00080     "PageNumber", N_("Page Number"), N_("Job Mode"),
00081     N_("Page number"),
00082     STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_CORE,
00083     STP_PARAMETER_LEVEL_BASIC, 0, 1, -1, 1, 0
00084   },
00085 };
00086 
00087 static const int the_parameter_count =
00088 sizeof(the_parameters) / sizeof(const stp_parameter_t);
00089 
00090 int
00091 stpi_get_qualities_count(void)
00092 {
00093   return sizeof(standard_qualities) / sizeof(stpi_quality_t);
00094 }
00095 
00096 const stpi_quality_t *
00097 stpi_get_quality_by_index(int idx)
00098 {
00099   if (idx < 0 || idx >= stpi_get_qualities_count())
00100     return NULL;
00101   else
00102     return &(standard_qualities[idx]);
00103 }
00104 
00105 const stpi_quality_t *
00106 stpi_get_quality_by_name(const char *quality)
00107 {
00108   int i;
00109   if (!quality)
00110     return NULL;
00111   for (i = 0; i < stpi_get_qualities_count(); i++)
00112     {
00113       const stpi_quality_t *qual = stpi_get_quality_by_index(i);
00114       if (strcmp(quality, qual->name) == 0)
00115         return qual;
00116     }
00117   return NULL;
00118 }
00119 
00120 int
00121 stpi_get_image_types_count(void)
00122 {
00123   return sizeof(standard_image_types) / sizeof(stpi_image_type_t);
00124 }
00125 
00126 const stpi_image_type_t *
00127 stpi_get_image_type_by_index(int idx)
00128 {
00129   if (idx < 0 || idx >= stpi_get_image_types_count())
00130     return NULL;
00131   else
00132     return &(standard_image_types[idx]);
00133 }
00134 
00135 const stpi_image_type_t *
00136 stpi_get_image_type_by_name(const char *image_type)
00137 {
00138   int i;
00139   if (!image_type)
00140     return NULL;
00141   for (i = 0; i < stpi_get_image_types_count(); i++)
00142     {
00143       const stpi_image_type_t *itype = stpi_get_image_type_by_index(i);
00144       if (strcmp(image_type, itype->name) == 0)
00145         return itype;
00146     }
00147   return NULL;
00148 }
00149 
00150 int
00151 stpi_get_job_modes_count(void)
00152 {
00153   return sizeof(standard_job_modes) / sizeof(stpi_job_mode_t);
00154 }
00155 
00156 const stpi_job_mode_t *
00157 stpi_get_job_mode_by_index(int idx)
00158 {
00159   if (idx < 0 || idx >= stpi_get_job_modes_count())
00160     return NULL;
00161   else
00162     return &(standard_job_modes[idx]);
00163 }
00164 
00165 const stpi_job_mode_t *
00166 stpi_get_job_mode_by_name(const char *job_mode)
00167 {
00168   int i;
00169   if (!job_mode)
00170     return NULL;
00171   for (i = 0; i < stpi_get_job_modes_count(); i++)
00172     {
00173       const stpi_job_mode_t *itype = stpi_get_job_mode_by_index(i);
00174       if (strcmp(job_mode, itype->name) == 0)
00175         return itype;
00176     }
00177   return NULL;
00178 }
00179 
00180 stp_parameter_list_t
00181 stp_list_generic_parameters(const stp_vars_t *v)
00182 {
00183   stp_parameter_list_t *ret = stp_parameter_list_create();
00184   int i;
00185   for (i = 0; i < the_parameter_count; i++)
00186     stp_parameter_list_add_param(ret, &(the_parameters[i]));
00187   return ret;
00188 }
00189 
00190 void
00191 stpi_describe_generic_parameter(const stp_vars_t *v, const char *name,
00192                                 stp_parameter_t *description)
00193 {
00194   int           i;
00195   description->p_type = STP_PARAMETER_TYPE_INVALID;
00196   if (name == NULL)
00197     return;
00198 
00199   for (i = 0; i < the_parameter_count; i++)
00200     if (strcmp(name, the_parameters[i].name) == 0)
00201       {
00202         stp_fill_parameter_settings(description, &(the_parameters[i]));
00203         break;
00204       }
00205 
00206   description->deflt.str = NULL;
00207 
00208   if (strcmp(name, "Quality") == 0)
00209     {
00210 #if 0
00211       description->bounds.str = stp_string_list_create();
00212       stp_string_list_add_string(description->bounds.str, "None",
00213                                  _("Manual Control"));
00214       for (i = 0; i < stpi_get_qualities_count(); i++)
00215         {
00216           const stpi_quality_t *qual = stpi_get_quality_by_index(i);
00217           stp_string_list_add_string(description->bounds.str, qual->name,
00218                                      qual->text);
00219         }
00220       description->deflt.str = "Standard";
00221 #else
00222       description->bounds.str = NULL;
00223       description->p_type = STP_PARAMETER_TYPE_INVALID;
00224 #endif
00225     }
00226   else if (strcmp(name, "ImageType") == 0)
00227     {
00228       description->bounds.str = stp_string_list_create();
00229       stp_string_list_add_string(description->bounds.str, "None",
00230                                  _("Manual Control"));
00231       for (i = 0; i < stpi_get_image_types_count(); i++)
00232         {
00233           const stpi_image_type_t *itype = stpi_get_image_type_by_index(i);
00234           stp_string_list_add_string(description->bounds.str, itype->name,
00235                                      itype->text);
00236         }
00237       description->deflt.str = "TextGraphics";
00238     }
00239   else if (strcmp(name, "JobMode") == 0)
00240     {
00241       description->bounds.str = stp_string_list_create();
00242       for (i = 0; i < stpi_get_job_modes_count(); i++)
00243         {
00244           const stpi_job_mode_t *itype = stpi_get_job_mode_by_index(i);
00245           stp_string_list_add_string(description->bounds.str, itype->name,
00246                                      itype->text);
00247         }
00248       description->deflt.str = "Page";
00249     }
00250   else if (strcmp(name, "PageNumber") == 0)
00251     {
00252       description->deflt.integer = 0;
00253       description->bounds.integer.lower = 0;
00254       description->bounds.integer.upper = INT_MAX;
00255     }
00256 }
00257 

Generated on Wed Aug 25 07:56:14 2004 for libgimpprint API Reference by doxygen 1.3.6