Commit f4244f19114a442209a1ac2db8569e3dcd0c3fbf
1 parent
3d11a714
Exists in
master
and in
5 other branches
Incluindo opção para troca do nome da aplicação e atualização da barra de título
Showing
4 changed files
with
45 additions
and
27 deletions
Show diff stats
src/gtk/main.c
@@ -107,11 +107,46 @@ static int initialize(void) | @@ -107,11 +107,46 @@ static int initialize(void) | ||
107 | 107 | ||
108 | int main(int argc, char *argv[]) | 108 | int main(int argc, char *argv[]) |
109 | { | 109 | { |
110 | - int rc = 0; | 110 | + static const gchar * appname = PACKAGE_NAME; |
111 | + int rc = 0; | ||
111 | 112 | ||
112 | - g_set_application_name(PACKAGE_NAME); | 113 | + // Process command-line options |
114 | + { | ||
115 | + static const GOptionEntry app_options[] = | ||
116 | + { | ||
117 | + { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, | ||
118 | + | ||
119 | + { NULL } | ||
120 | + }; | ||
121 | + | ||
122 | + GOptionContext * options = g_option_context_new (_("- 3270 Emulator for Gtk")); | ||
123 | + GError * error = NULL; | ||
124 | + | ||
125 | + g_option_context_add_main_entries(options, app_options, NULL); | ||
126 | + | ||
127 | + gtk_init(&argc, &argv); | ||
128 | + | ||
129 | + if(!g_option_context_parse( options, &argc, &argv, &error )) | ||
130 | + { | ||
131 | + GtkWidget *dialog = gtk_message_dialog_new( NULL, | ||
132 | + GTK_DIALOG_DESTROY_WITH_PARENT, | ||
133 | + GTK_MESSAGE_ERROR, | ||
134 | + GTK_BUTTONS_CANCEL, | ||
135 | + "%s", _( "Option parsing failed." )); | ||
136 | + | ||
137 | + gtk_window_set_title(GTK_WINDOW(dialog),_( "Parse error" )); | ||
138 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", error->message); | ||
139 | + | ||
140 | + gtk_dialog_run(GTK_DIALOG (dialog)); | ||
141 | + gtk_widget_destroy(dialog); | ||
142 | + | ||
143 | + g_error_free(error); | ||
144 | + | ||
145 | + return -1; | ||
146 | + } | ||
147 | + } | ||
113 | 148 | ||
114 | - gtk_init(&argc, &argv); | 149 | + g_set_application_name(appname); |
115 | 150 | ||
116 | rc = initialize(); | 151 | rc = initialize(); |
117 | if(!rc) | 152 | if(!rc) |
src/gtk/mainwindow.c
@@ -122,33 +122,15 @@ | @@ -122,33 +122,15 @@ | ||
122 | gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE); | 122 | gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE); |
123 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],FALSE); | 123 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],FALSE); |
124 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],TRUE); | 124 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],TRUE); |
125 | + gtk_window_set_title(GTK_WINDOW(gtk_widget_get_toplevel(widget)),g_get_application_name()); | ||
125 | } | 126 | } |
126 | 127 | ||
127 | -/* | ||
128 | -#ifndef WIN32 | ||
129 | - static void clipboard_text_check(GtkClipboard *clipboard, const gchar *text, GtkActionGroup **group) | ||
130 | - { | ||
131 | - trace("%s called with text=%p",__FUNCTION__,text); | ||
132 | - gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],text != NULL); | ||
133 | - } | ||
134 | -#endif | ||
135 | -*/ | ||
136 | - | ||
137 | - static void connected(GtkWidget *widget, GtkActionGroup **group) | 128 | + static void connected(GtkWidget *widget, const gchar *host, GtkActionGroup **group) |
138 | { | 129 | { |
130 | + gtk_window_set_title(GTK_WINDOW(gtk_widget_get_toplevel(widget)),host); | ||
139 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE); | 131 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE); |
140 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE); | 132 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE); |
141 | gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE); | 133 | gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE); |
142 | - | ||
143 | -/* | ||
144 | -#ifdef WIN32 | ||
145 | - gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE); | ||
146 | -#else | ||
147 | - gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE); | ||
148 | - gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) clipboard_text_check,(gpointer) group); | ||
149 | -#endif | ||
150 | -*/ | ||
151 | - | ||
152 | } | 134 | } |
153 | 135 | ||
154 | static void update_config(GtkWidget *widget, const gchar *name, const gchar *value) | 136 | static void update_config(GtkWidget *widget, const gchar *name, const gchar *value) |
src/gtk/v3270/genmarshal
@@ -2,6 +2,7 @@ VOID:VOID | @@ -2,6 +2,7 @@ VOID:VOID | ||
2 | VOID:VOID,ENUM,BOOL,POINTER | 2 | VOID:VOID,ENUM,BOOL,POINTER |
3 | VOID:VOID,ENUM | 3 | VOID:VOID,ENUM |
4 | VOID:VOID,POINTER | 4 | VOID:VOID,POINTER |
5 | +VOID:POINTER | ||
5 | VOID:VOID,POINTER,POINTER | 6 | VOID:VOID,POINTER,POINTER |
6 | VOID:VOID,UINT,POINTER | 7 | VOID:VOID,UINT,POINTER |
7 | BOOL:VOID,UINT,ENUM | 8 | BOOL:VOID,UINT,ENUM |
src/gtk/v3270/widget.c
@@ -318,8 +318,8 @@ static void v3270_class_init(v3270Class *klass) | @@ -318,8 +318,8 @@ static void v3270_class_init(v3270Class *klass) | ||
318 | G_SIGNAL_RUN_FIRST, | 318 | G_SIGNAL_RUN_FIRST, |
319 | 0, | 319 | 0, |
320 | NULL, NULL, | 320 | NULL, NULL, |
321 | - pw3270_VOID__VOID, | ||
322 | - G_TYPE_NONE, 0); | 321 | + pw3270_VOID__POINTER, |
322 | + G_TYPE_NONE, 1, G_TYPE_STRING); | ||
323 | 323 | ||
324 | v3270_widget_signal[SIGNAL_DISCONNECTED] = | 324 | v3270_widget_signal[SIGNAL_DISCONNECTED] = |
325 | g_signal_new( "disconnected", | 325 | g_signal_new( "disconnected", |
@@ -524,7 +524,7 @@ static void update_connect(H3270 *session, unsigned char connected) | @@ -524,7 +524,7 @@ static void update_connect(H3270 *session, unsigned char connected) | ||
524 | if(connected) | 524 | if(connected) |
525 | { | 525 | { |
526 | widget->cursor.show |= 2; | 526 | widget->cursor.show |= 2; |
527 | - g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0); | 527 | + g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, session->full_current_host); |
528 | } | 528 | } |
529 | else | 529 | else |
530 | { | 530 | { |