Commit 3cf573e7f0b5ede5157af7aac2c1d4d45cbfa3ae
1 parent
75f87222
Exists in
master
and in
5 other branches
Adding version and release information on windows registry.
Showing
1 changed file
with
11 additions
and
75 deletions
Show diff stats
src/pw3270/main.c
| ... | ... | @@ -69,10 +69,6 @@ |
| 69 | 69 | GtkOSXApplication * osxapp = NULL; |
| 70 | 70 | #endif // HAVE_GTKMAC |
| 71 | 71 | |
| 72 | -#if defined( WIN32 ) | |
| 73 | - static const gchar * appname = PACKAGE_NAME; | |
| 74 | -#endif // WIN32 | |
| 75 | - | |
| 76 | 72 | #if defined( HAVE_SYSLOG ) |
| 77 | 73 | static gboolean log_to_syslog = FALSE; |
| 78 | 74 | #endif // HAVE_SYSLOG |
| ... | ... | @@ -141,49 +137,6 @@ static void toplevel_setup(GtkWindow *window) |
| 141 | 137 | g_free(name); |
| 142 | 138 | } |
| 143 | 139 | |
| 144 | -#if ! defined( WIN32 ) | |
| 145 | - | |
| 146 | -static gboolean appname(const gchar *option_name, const gchar *value, gpointer data, GError **error) | |
| 147 | -{ | |
| 148 | - g_set_application_name(value); | |
| 149 | - return TRUE; | |
| 150 | -} | |
| 151 | - | |
| 152 | -#else | |
| 153 | - | |
| 154 | -static gboolean datadir(const gchar *option_name, const gchar *value, gpointer data, GError **error) | |
| 155 | -{ | |
| 156 | - gchar * path = g_strconcat("SOFTWARE\\",appname,NULL); | |
| 157 | - HKEY hKey; | |
| 158 | - DWORD disp; | |
| 159 | - int rc; | |
| 160 | - | |
| 161 | - rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp); | |
| 162 | - SetLastError(rc); | |
| 163 | - | |
| 164 | - trace("%s=\"%s\" create=%d",path,value,rc); | |
| 165 | - | |
| 166 | - if(rc == ERROR_SUCCESS) | |
| 167 | - { | |
| 168 | - trace("%s: Value set",__FUNCTION__); | |
| 169 | - RegSetValueEx(hKey,"datadir",0,REG_SZ,(const BYTE *) value,strlen(value)+1); | |
| 170 | - RegCloseKey(hKey); | |
| 171 | - } | |
| 172 | - else | |
| 173 | - { | |
| 174 | - gchar *msg = g_win32_error_message(rc); | |
| 175 | - trace("%s failed: %s",__FUNCTION__,msg); | |
| 176 | - *error = g_error_new(ERROR_DOMAIN,EINVAL, "%s", msg); | |
| 177 | - g_free(msg); | |
| 178 | - } | |
| 179 | - | |
| 180 | - g_free(path); | |
| 181 | - | |
| 182 | - return rc == ERROR_SUCCESS; | |
| 183 | -} | |
| 184 | - | |
| 185 | -#endif // !win32 | |
| 186 | - | |
| 187 | 140 | static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer data, GError **error) |
| 188 | 141 | { |
| 189 | 142 | static const unsigned short valid[] = { 2,8,16 }; |
| ... | ... | @@ -301,12 +254,6 @@ int main(int argc, char *argv[]) |
| 301 | 254 | { |
| 302 | 255 | const GOptionEntry app_options[] = |
| 303 | 256 | { |
| 304 | -#if ! defined( WIN32 ) | |
| 305 | - { "appname", 'a', 0, G_OPTION_ARG_CALLBACK, appname, N_( "Application name" ), PACKAGE_NAME }, | |
| 306 | -#else | |
| 307 | - { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, | |
| 308 | - { "datadir", 'd', 0, G_OPTION_ARG_CALLBACK, datadir, N_( "Path to application data files" ), NULL }, | |
| 309 | -#endif // WIN32 | |
| 310 | 257 | { "session", 's', 0, G_OPTION_ARG_STRING, &session_name, N_( "Session name" ), PACKAGE_NAME }, |
| 311 | 258 | { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), host }, |
| 312 | 259 | { "colors", 'c', 0, G_OPTION_ARG_CALLBACK, optcolors, N_( "Set reported colors (8/16)" ), "16" }, |
| ... | ... | @@ -451,10 +398,6 @@ int main(int argc, char *argv[]) |
| 451 | 398 | |
| 452 | 399 | } |
| 453 | 400 | |
| 454 | -#if defined(WIN32) | |
| 455 | - g_set_application_name(appname); | |
| 456 | -#endif // WIN32 | |
| 457 | - | |
| 458 | 401 | // Just in case! |
| 459 | 402 | g_mkdir_with_parents(g_get_tmp_dir(),0777); |
| 460 | 403 | |
| ... | ... | @@ -472,14 +415,17 @@ int main(int argc, char *argv[]) |
| 472 | 415 | pw3270_load_plugins(pluginpath); |
| 473 | 416 | toplevel = pw3270_new(host,systype,syscolors); |
| 474 | 417 | |
| 475 | - if(session_name) | |
| 476 | - { | |
| 477 | - pw3270_set_session_name(toplevel,session_name); | |
| 478 | - } | |
| 479 | - else | |
| 480 | - { | |
| 481 | - pw3270_set_session_name(toplevel,g_get_application_name()); | |
| 482 | - } | |
| 418 | + | |
| 419 | + if(!session_name) | |
| 420 | + session_name = g_get_application_name(); | |
| 421 | + | |
| 422 | + pw3270_set_session_name(toplevel,session_name); | |
| 423 | + | |
| 424 | +#if defined(_WIN32) && defined(ENABLE_WINDOWS_REGISTRY) | |
| 425 | + pw3270_set_string(toplevel,"app","version",PACKAGE_VERSION); | |
| 426 | + pw3270_set_string(toplevel,"app","release",G_STRINGIFY(PACKAGE_RELEASE)); | |
| 427 | + pw3270_set_string(toplevel,"app","sessionName",session_name); | |
| 428 | +#endif // _WIN32 && ENABLE_WINDOWS_REGISTRY | |
| 483 | 429 | |
| 484 | 430 | if(toggleset) |
| 485 | 431 | { |
| ... | ... | @@ -489,7 +435,6 @@ int main(int argc, char *argv[]) |
| 489 | 435 | for(f=0;str[f];f++) |
| 490 | 436 | pw3270_set_toggle_by_name(toplevel,str[f],TRUE); |
| 491 | 437 | |
| 492 | - | |
| 493 | 438 | g_strfreev(str); |
| 494 | 439 | } |
| 495 | 440 | |
| ... | ... | @@ -519,15 +464,6 @@ int main(int argc, char *argv[]) |
| 519 | 464 | |
| 520 | 465 | v3270_set_auto_disconnect(pw3270_get_terminal_widget(toplevel),timer); |
| 521 | 466 | |
| 522 | - /* | |
| 523 | - pw3270_start_plugins(toplevel); | |
| 524 | - gtk_window_present(GTK_WINDOW(toplevel)); | |
| 525 | - | |
| 526 | -#ifdef HAVE_GTKMAC | |
| 527 | - gtk_osxapplication_ready(osxapp); | |
| 528 | -#endif // HAVE_GTKMAC | |
| 529 | - */ | |
| 530 | - | |
| 531 | 467 | g_idle_add((GSourceFunc) startup, toplevel); |
| 532 | 468 | |
| 533 | 469 | gtk_main(); | ... | ... |