From 2d23cf45959b0ed3ec5a9d1c712e624f08819fc7 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Sat, 15 Sep 2012 14:43:54 +0000 Subject: [PATCH] Incluindo teste de versao gtk --- src/pw3270/dialog.c | 7 ++++++- src/pw3270/main.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c index 5783360..5f29a0c 100644 --- a/src/pw3270/dialog.c +++ b/src/pw3270/dialog.c @@ -544,6 +544,7 @@ GtkAboutDialog * dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); gchar * text = g_strdup_printf("%s-logo.png",g_get_application_name()); gchar * filename = build_data_filename(text,NULL); + gchar * info; trace("[%s]",filename); if(g_file_test(filename,G_FILE_TEST_EXISTS)) @@ -572,7 +573,9 @@ g_free(text); gtk_about_dialog_set_copyright(dialog, "Copyright © 2008 Banco do Brasil S.A." ); - gtk_about_dialog_set_comments(dialog, _( "3270 terminal emulator for GTK+" ) ); + + info = g_strdup_printf(_( "3270 terminal emulator for GTK %d.%d" ),GTK_MAJOR_VERSION,GTK_MINOR_VERSION); + gtk_about_dialog_set_comments(dialog, info ); gtk_about_dialog_set_license(dialog, gettext( license ) ); gtk_about_dialog_set_wrap_license(dialog,TRUE); @@ -586,4 +589,6 @@ gtk_widget_show_all(GTK_WIDGET(dialog)); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(GTK_WIDGET(dialog)); + + g_free(info); } diff --git a/src/pw3270/main.c b/src/pw3270/main.c index fd2c9ec..4a9bdf8 100644 --- a/src/pw3270/main.c +++ b/src/pw3270/main.c @@ -196,7 +196,6 @@ int main(int argc, char *argv[]) GOptionContext * options = g_option_context_new (_("- 3270 Emulator for Gtk")); GError * error = NULL; - g_option_context_add_main_entries(options, app_options, NULL); if(!g_option_context_parse( options, &argc, &argv, &error )) @@ -228,6 +227,36 @@ int main(int argc, char *argv[]) } } + { + const gchar *msg = gtk_check_version(GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + + if(msg) + { + // Invalid GTK version, notify user and exit + int rc; + GtkWidget * dialog = gtk_message_dialog_new( NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK_CANCEL, + _( "This program requires GTK version %d.%d.%d" ),GTK_MAJOR_VERSION,GTK_MINOR_VERSION,GTK_MICRO_VERSION ); + + + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",msg); + gtk_window_set_title(GTK_WINDOW(dialog),_( "GTK Version mismatch" )); + +#if GTK_CHECK_VERSION(2,10,0) + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); +#endif + + rc = gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + + if(rc != GTK_RESPONSE_OK) + return EINVAL; + } + + } + #if defined(WIN32) g_set_application_name(appname); #endif // WIN32 -- libgit2 0.21.2