Commit d5add747c9752092f15bfb868b72e5337e051386

Authored by perry.werneck@gmail.com
1 parent c5b4e64a

Salvando configuracao de pagina no registry windows

pw3270.svg 0 → 100644
... ... @@ -0,0 +1,155 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<!-- Created with Inkscape (http://www.inkscape.org/) -->
  3 +
  4 +<svg
  5 + xmlns:dc="http://purl.org/dc/elements/1.1/"
  6 + xmlns:cc="http://creativecommons.org/ns#"
  7 + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  8 + xmlns:svg="http://www.w3.org/2000/svg"
  9 + xmlns="http://www.w3.org/2000/svg"
  10 + xmlns:xlink="http://www.w3.org/1999/xlink"
  11 + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  12 + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  13 + width="256"
  14 + height="256"
  15 + id="svg2685"
  16 + sodipodi:version="0.32"
  17 + inkscape:version="0.48.1 r9760"
  18 + sodipodi:docname="pw3270.svg"
  19 + inkscape:output_extension="org.inkscape.output.svg.inkscape"
  20 + inkscape:export-filename="/home/perry/Project/3270/v4/image/icon.png"
  21 + inkscape:export-xdpi="90"
  22 + inkscape:export-ydpi="90"
  23 + version="1.1">
  24 + <defs
  25 + id="defs2687">
  26 + <linearGradient
  27 + id="linearGradient3687">
  28 + <stop
  29 + style="stop-color:#ffffff;stop-opacity:1;"
  30 + offset="0"
  31 + id="stop3689" />
  32 + <stop
  33 + style="stop-color:#000000;stop-opacity:1;"
  34 + offset="1"
  35 + id="stop3691" />
  36 + </linearGradient>
  37 + <radialGradient
  38 + inkscape:collect="always"
  39 + xlink:href="#linearGradient3687"
  40 + id="radialGradient2560"
  41 + gradientUnits="userSpaceOnUse"
  42 + gradientTransform="matrix(-1.2214651,1.3481449,-1.1114864,-1.0070438,1777.1401,13.255979)"
  43 + cx="593.03772"
  44 + cy="437.90591"
  45 + fx="593.03772"
  46 + fy="437.90591"
  47 + r="19.115074" />
  48 + <inkscape:perspective
  49 + sodipodi:type="inkscape:persp3d"
  50 + inkscape:vp_x="0 : 32 : 1"
  51 + inkscape:vp_y="0 : 1000 : 0"
  52 + inkscape:vp_z="64 : 32 : 1"
  53 + inkscape:persp3d-origin="32 : 21.333333 : 1"
  54 + id="perspective2693" />
  55 + </defs>
  56 + <sodipodi:namedview
  57 + id="base"
  58 + pagecolor="#ffffff"
  59 + bordercolor="#666666"
  60 + borderopacity="1.0"
  61 + inkscape:pageopacity="0.0"
  62 + inkscape:pageshadow="2"
  63 + inkscape:zoom="0.97227183"
  64 + inkscape:cx="-138.53895"
  65 + inkscape:cy="32"
  66 + inkscape:current-layer="layer1"
  67 + showgrid="true"
  68 + inkscape:document-units="px"
  69 + inkscape:grid-bbox="true"
  70 + inkscape:window-width="1366"
  71 + inkscape:window-height="744"
  72 + inkscape:window-x="0"
  73 + inkscape:window-y="24"
  74 + inkscape:window-maximized="1" />
  75 + <metadata
  76 + id="metadata2690">
  77 + <rdf:RDF>
  78 + <cc:Work
  79 + rdf:about="">
  80 + <dc:format>image/svg+xml</dc:format>
  81 + <dc:type
  82 + rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
  83 + </cc:Work>
  84 + </rdf:RDF>
  85 + </metadata>
  86 + <g
  87 + id="layer1"
  88 + inkscape:label="Layer 1"
  89 + inkscape:groupmode="layer"
  90 + transform="translate(0,192)">
  91 + <g
  92 + id="g3348"
  93 + transform="matrix(5.1775834,0,0,5.1775834,-2744.6594,-2068.6398)"
  94 + inkscape:export-filename="/home/perry/Desktop/g3484.png"
  95 + inkscape:export-xdpi="750"
  96 + inkscape:export-ydpi="750">
  97 + <path
  98 + inkscape:export-ydpi="750"
  99 + inkscape:export-xdpi="750"
  100 + inkscape:export-filename="/home/perry/Desktop/path4684.png"
  101 + sodipodi:nodetypes="ccccc"
  102 + id="path3877"
  103 + d="m 571.75652,365.09989 c -12.28362,1.49404 -24.71615,1.60564 -36.92919,3.70417 1.15828,9.37275 0.97923,23.2044 1.63094,30.14689 11.55053,-1.50408 27.01785,-2.59907 38.36698,-5.35307 -0.036,-8.87303 -1.02762,-19.15 -3.06873,-28.49799 z"
  104 + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#cccccc;stroke-width:2.20000005;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
  105 + inkscape:connector-curvature="0" />
  106 + <path
  107 + inkscape:export-ydpi="750"
  108 + inkscape:export-xdpi="750"
  109 + inkscape:export-filename="/home/perry/Desktop/path4684.png"
  110 + sodipodi:nodetypes="cccccccccccccccc"
  111 + id="path3879"
  112 + d="m 558.70672,398.73456 c -3.79163,0.10309 -7.64598,0.11185 -11.30721,1.27926 -2.13143,0.66011 -4.04568,2.24121 -4.70985,4.42348 -0.0967,1.1177 0.76001,2.18842 1.46457,3.02352 2.25351,2.29719 5.65545,2.82771 8.73539,2.89271 4.42579,0.006 8.86831,-0.8458 12.96682,-2.52003 1.55025,-0.88162 3.33996,-2.06142 3.56963,-3.9936 -0.59735,-2.25901 -2.87075,-3.51224 -4.96561,-4.11636 -1.84964,-0.54894 -3.83129,-0.95601 -5.75374,-0.98898 z m 0.0446,1.40178 c 2.78739,0.0968 5.75567,0.21409 8.11548,1.83476 0.87991,0.58405 1.95351,1.77677 1.15706,2.83974 -0.76499,1.1501 -2.05182,1.80199 -3.22326,2.45978 -3.23561,1.57133 -6.96349,1.61384 -10.45172,1.06373 -9.12914,-0.40554 -4.60594,-6.64603 1.06647,-7.80087 1.09861,-0.25448 2.19774,-0.40573 3.33597,-0.39714 z"
  113 + style="fill:#b6b6b6;fill-opacity:1;fill-rule:evenodd;stroke:none"
  114 + inkscape:connector-curvature="0" />
  115 + <g
  116 + transform="matrix(0.8126522,0,0,1,135.51705,-68.411175)"
  117 + id="g3881">
  118 + <path
  119 + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:50.90000153;stroke-opacity:1;stroke-dasharray:3, 3;stroke-dashoffset:0"
  120 + d="m 496.23743,451.70467 c 37.88072,-3.53554 37.62819,-3.53554 37.62819,-3.53554"
  121 + id="path3883"
  122 + inkscape:connector-curvature="0" />
  123 + <path
  124 + style="font-size:9.27298832px;font-style:normal;font-weight:bold;fill:#00ff00;fill-opacity:1;stroke:#00ff00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans Bold"
  125 + d="m 496.41233,442.38795 2.69056,-0.26631 c 0.80001,-0.0792 1.40822,0.0667 1.82464,0.43776 0.41931,0.36749 0.61951,0.93195 0.60062,1.69338 -0.019,0.76469 -0.24833,1.37492 -0.68806,1.83067 -0.43685,0.45224 -1.05527,0.71795 -1.85529,0.79713 l -1.06948,0.10586 -0.0627,2.52833 -1.62108,0.16046 0.18082,-7.28728 m 1.58729,1.20133 -0.0505,2.03536 0.89685,-0.0888 c 0.31439,-0.0311 0.55938,-0.14299 0.73498,-0.33567 0.17566,-0.19591 0.26753,-0.45656 0.27561,-0.78196 0.008,-0.3254 -0.0713,-0.56748 -0.23819,-0.72626 -0.16688,-0.15875 -0.4075,-0.22257 -0.7219,-0.19147 l -0.89684,0.0888 m 4.19384,-1.77354 1.5537,-0.15378 0.95492,5.18832 1.20932,-5.40254 1.56212,-0.15461 0.9465,5.18915 1.21774,-5.40337 1.54107,-0.15253 -1.66294,7.43397 -1.8695,0.18504 -1.00361,-5.42695 -1.2659,5.65159 -1.86949,0.18504 -1.31393,-7.13933 m 13.19263,2.04406 c 0.4207,0.085 0.73663,0.27442 0.94775,0.56837 0.214,0.29044 0.31498,0.67808 0.30296,1.16291 -0.0179,0.72239 -0.27018,1.29593 -0.75673,1.72062 -0.48649,0.42144 -1.18728,0.67745 -2.10238,0.76803 -0.32281,0.0319 -0.64626,0.0331 -0.97034,0.004 -0.32136,-0.0266 -0.63914,-0.0844 -0.95336,-0.17343 l 0.036,-1.44965 c 0.29879,0.14571 0.59584,0.2494 0.89113,0.31106 0.29817,0.0581 0.59182,0.0729 0.88095,0.0443 0.42948,-0.0425 0.76005,-0.16124 0.99169,-0.35622 0.23446,-0.19524 0.35568,-0.45393 0.36368,-0.77608 0.008,-0.3319 -0.10345,-0.57079 -0.33503,-0.71665 -0.22872,-0.1494 -0.57184,-0.20145 -1.02939,-0.15618 l -0.64842,0.0642 0.03,-1.21047 0.68211,-0.0675 c 0.40702,-0.0403 0.712,-0.1435 0.91493,-0.30966 0.20302,-0.16941 0.30828,-0.40542 0.31579,-0.70805 0.007,-0.27983 -0.0845,-0.48663 -0.27442,-0.62041 -0.18989,-0.13376 -0.46168,-0.18313 -0.81537,-0.14814 -0.26105,0.0258 -0.52577,0.0861 -0.79413,0.18086 -0.26837,0.0947 -0.53613,0.22186 -0.80331,0.38138 l 0.0341,-1.37642 c 0.32259,-0.1358 0.64172,-0.2453 0.95741,-0.32848 0.31568,-0.0832 0.6251,-0.13977 0.92826,-0.16979 0.81685,-0.0808 1.42351,0.0149 1.81998,0.28729 0.39934,0.26884 0.59127,0.71565 0.57577,1.3404 -0.0106,0.42629 -0.1161,0.78567 -0.31657,1.07816 -0.20039,0.28927 -0.49143,0.50796 -0.87312,0.6561 m 4.39998,2.10611 2.76635,-0.27381 -0.0343,1.3813 -4.56848,0.45219 0.0343,-1.38131 2.35302,-2.57489 c 0.21024,-0.23504 0.36703,-0.45992 0.47036,-0.67465 0.10334,-0.21472 0.15774,-0.43272 0.16324,-0.65399 0.008,-0.34167 -0.0844,-0.60676 -0.27848,-0.7953 -0.19133,-0.1888 -0.45121,-0.26694 -0.77963,-0.23445 -0.25263,0.025 -0.5307,0.11584 -0.8342,0.27247 -0.30343,0.15338 -0.62944,0.37068 -0.97804,0.65186 l 0.0397,-1.60096 c 0.36838,-0.17603 0.73172,-0.31748 1.08999,-0.42437 0.35835,-0.11012 0.70876,-0.18212 1.05122,-0.21603 0.75228,-0.0745 1.33139,0.0597 1.73731,0.40259 0.40872,0.34257 0.60456,0.85715 0.58752,1.54373 -0.01,0.397 -0.10747,0.77671 -0.29287,1.13912 -0.18533,0.35918 -0.56865,0.8548 -1.14996,1.48687 l -1.37709,1.49963 m 4.23502,-6.31064 4.7369,-0.46886 -0.0263,1.05916 -2.60509,6.47067 -1.57897,0.15629 2.46658,-6.13561 -3.02741,0.29965 0.0343,-1.3813 m 9.29515,2.70736 c 0.0226,-0.91111 -0.0359,-1.54479 -0.17544,-1.90102 -0.13669,-0.35974 -0.37906,-0.5224 -0.72714,-0.48796 -0.34807,0.0345 -0.60114,0.24616 -0.75919,0.63508 -0.15799,0.38568 -0.24828,1.03408 -0.27088,1.94519 -0.0229,0.92088 0.0354,1.56268 0.17484,1.92541 0.1394,0.36274 0.38314,0.52689 0.73122,0.49243 0.34526,-0.0342 0.59696,-0.24736 0.75511,-0.63954 0.15814,-0.39219 0.24863,-1.04872 0.27148,-1.96959 m 1.62071,-0.14581 c -0.03,1.20722 -0.27765,2.16172 -0.74308,2.86347 -0.46537,0.6985 -1.11069,1.0886 -1.93596,1.17029 -0.82807,0.082 -1.45856,-0.18186 -1.89146,-0.79146 -0.43282,-0.61284 -0.63425,-1.52288 -0.6043,-2.73011 0.03,-1.21048 0.27773,-2.16496 0.74309,-2.86347 0.46544,-0.70176 1.1122,-1.09361 1.94028,-1.17559 0.82527,-0.0817 1.45431,0.18391 1.88714,0.79676 0.43289,0.6096 0.63432,1.51963 0.60429,2.73011"
  126 + id="path3885"
  127 + inkscape:connector-curvature="0" />
  128 + <path
  129 + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:50.90000153;stroke-opacity:1;stroke-dasharray:3, 3;stroke-dashoffset:0"
  130 + d="m 498.4652,453.42295 c 37.88072,-3.53554 37.62819,-3.53554 37.62819,-3.53554"
  131 + id="path3887"
  132 + inkscape:connector-curvature="0" />
  133 + <path
  134 + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:50.90000153;stroke-opacity:1;stroke-dasharray:3, 3;stroke-dashoffset:0"
  135 + d="m 496.77866,455.87356 c 37.88072,-3.53554 37.62819,-3.53554 37.62819,-3.53554"
  136 + id="path3889"
  137 + inkscape:connector-curvature="0" />
  138 + <path
  139 + style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:50.90000153;stroke-opacity:1;stroke-dasharray:3, 3;stroke-dashoffset:0"
  140 + d="m 499.54207,457.86404 c 37.88072,-3.53554 37.62819,-3.53554 37.62819,-3.53554"
  141 + id="path3891"
  142 + inkscape:connector-curvature="0" />
  143 + </g>
  144 + <path
  145 + inkscape:export-ydpi="750"
  146 + inkscape:export-xdpi="750"
  147 + inkscape:export-filename="/home/perry/Desktop/path4684.png"
  148 + sodipodi:nodetypes="ccccc"
  149 + id="path3893"
  150 + d="m 571.18683,366.21059 c -11.74072,1.38257 -23.62379,1.48585 -35.29705,3.42783 1.10709,8.67351 0.93595,21.47328 1.55887,27.89784 11.04002,-1.39187 25.82375,-2.40517 36.67128,-4.95371 -0.0344,-8.21108 -0.9822,-17.72136 -2.9331,-26.37196 z"
  151 + style="opacity:0.43404254;fill:url(#radialGradient2560);fill-opacity:1;fill-rule:evenodd;stroke:#cccccc;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
  152 + inkscape:connector-curvature="0" />
  153 + </g>
  154 + </g>
  155 +</svg>
... ...
src/gtk/common/config.c
... ... @@ -566,11 +566,20 @@ gchar * build_data_filename(const gchar *first_element, ...)
566 566 }
567 567  
568 568 #ifdef WIN_REGISTRY_ENABLED
569   -HKEY get_registry_handle(const gchar *first_element,REGSAM samDesired)
  569 +gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired)
570 570 {
571   - #warning Implementar
  571 + gboolean ret;
  572 + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group);
  573 + DWORD disp;
  574 +
  575 + if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,samDesired,NULL,hKey,&disp) == ERROR_SUCCESS)
  576 + ret = TRUE;
  577 + else
  578 + ret = FALSE;
572 579  
573   - return 0;
  580 + g_free(path);
  581 +
  582 + return ret;
574 583 }
575 584 #else
576 585 GKeyFile * get_application_keyfile(void)
... ...
src/gtk/main.c
... ... @@ -81,19 +81,17 @@ static int initialize(void)
81 81 {
82 82 // Invalid GTK version, notify user
83 83 int rc;
  84 +
84 85 GtkWidget *dialog = gtk_message_dialog_new( NULL,
85 86 GTK_DIALOG_DESTROY_WITH_PARENT,
86 87 GTK_MESSAGE_WARNING,
87 88 GTK_BUTTONS_OK_CANCEL,
88   - _( "This program requires GTK version %d.%d.%d" ),GTK_MAJOR_VERSION,GTK_MINOR_VERSION,GTK_MICRO_VERSION );
  89 + _( "%s requires GTK version %d.%d.%d" ),PACKAGE_NAME,GTK_MAJOR_VERSION,GTK_MINOR_VERSION,GTK_MICRO_VERSION );
89 90  
90 91  
91 92 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",msg);
92 93 gtk_window_set_title(GTK_WINDOW(dialog),_( "GTK Version mismatch" ));
93   -
94   -#if GTK_CHECK_VERSION(2,10,0)
95 94 gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE);
96   -#endif
97 95  
98 96 rc = gtk_dialog_run(GTK_DIALOG (dialog));
99 97 gtk_widget_destroy(dialog);
... ... @@ -147,14 +145,13 @@ int main(int argc, char *argv[])
147 145 }
148 146  
149 147 g_set_application_name(appname);
  148 + lib3270_set_popup_handler(popup_handler);
150 149  
151 150 rc = initialize();
152 151 if(!rc)
153 152 {
154 153 configuration_init();
155 154  
156   - lib3270_set_popup_handler(popup_handler);
157   -
158 155 toplevel = create_main_window();
159 156  
160 157 if(toplevel)
... ...
src/gtk/print.c
... ... @@ -131,11 +131,98 @@
131 131 }
132 132 }
133 133  
  134 +#ifdef WIN32
  135 +
  136 +#define save_string(h,k,v) save_settings(k,v,h)
  137 +
  138 +static void save_settings(const gchar *key, const gchar *value, HKEY hKey)
  139 +{
  140 + RegSetValueEx(hKey,key,0,REG_SZ,(const BYTE *) value,strlen(value)+1);
  141 +}
  142 +
  143 +static void save_double(HKEY hKey, const gchar *key, gdouble value)
  144 +{
  145 + // Reference: http://git.gnome.org/browse/glib/tree/glib/gkeyfile.c
  146 + gchar result[G_ASCII_DTOSTR_BUF_SIZE];
  147 + g_ascii_dtostr (result, sizeof (result), value);
  148 + save_settings(key,result,hKey);
  149 +}
  150 +
  151 +
  152 +/*
  153 + * From: http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c
  154 + * something like this should really be in gobject!
  155 + *
  156 + * I Agree!! (Perry Werneck)
  157 + *
  158 + */
  159 +static gchar * enum_to_string(GType type, guint enum_value)
  160 +{
  161 + GEnumClass *enum_class;
  162 + GEnumValue *value;
  163 + gchar *retval = NULL;
  164 +
  165 + enum_class = g_type_class_ref (type);
  166 +
  167 + value = g_enum_get_value(enum_class, enum_value);
  168 + if (value)
  169 + retval = g_strdup (value->value_nick);
  170 +
  171 + g_type_class_unref (enum_class);
  172 +
  173 + return retval;
  174 +}
  175 +
  176 +#endif // WIN32
  177 +
134 178 static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, PRINT_INFO *info)
135 179 {
136 180 #ifdef WIN32
137 181  
138   - #warning Implementar
  182 + HKEY registry;
  183 +
  184 + if(get_registry_handle("print",&registry,KEY_SET_VALUE))
  185 + {
  186 + HKEY hKey;
  187 + DWORD disp;
  188 +
  189 + if(RegCreateKeyEx(registry,"settings",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
  190 + {
  191 + gtk_print_settings_foreach( gtk_print_operation_get_print_settings(prt),
  192 + (GtkPrintSettingsFunc) save_settings,
  193 + hKey );
  194 + RegCloseKey(hKey);
  195 + }
  196 +
  197 + if(RegCreateKeyEx(registry,"pagesetup",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
  198 + {
  199 + HKEY hPaperSize;
  200 + GtkPageSetup * setup = gtk_print_operation_get_default_page_setup(prt);
  201 + gchar * orientation = enum_to_string(GTK_TYPE_PAGE_ORIENTATION,gtk_page_setup_get_orientation(setup));
  202 +
  203 + // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c
  204 + save_double(hKey, "MarginTop", gtk_page_setup_get_top_margin(setup, GTK_UNIT_MM));
  205 + save_double(hKey, "MarginBottom", gtk_page_setup_get_bottom_margin(setup, GTK_UNIT_MM));
  206 + save_double(hKey, "MarginLeft", gtk_page_setup_get_left_margin(setup, GTK_UNIT_MM));
  207 + save_double(hKey, "MarginRight", gtk_page_setup_get_right_margin(setup, GTK_UNIT_MM));
  208 + save_string(hKey, "Orientation", orientation);
  209 +
  210 + g_free (orientation);
  211 +
  212 + if(RegCreateKeyEx(hKey,"papersize",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hPaperSize,&disp) == ERROR_SUCCESS)
  213 + {
  214 + GtkPaperSize *paper_size = gtk_page_setup_get_paper_size (setup);
  215 + if(paper_size)
  216 + {
  217 + #warning Implement it
  218 + }
  219 + RegCloseKey(hPaperSize);
  220 + }
  221 + RegCloseKey(hKey);
  222 + }
  223 +
  224 + RegCloseKey(registry);
  225 + }
139 226  
140 227 #else
141 228 GKeyFile * conf = get_application_keyfile();
... ...