Commit 9cdad54a5ab03923b781fd7343a35417b4613275

Authored by Perry Werneck
1 parent dd84d543
Exists in master and in 1 other branch develop

Adjustments in the "window title" engine.

src/include/terminal.h
... ... @@ -169,9 +169,13 @@ G_BEGIN_DECLS
169 169  
170 170 // Session
171 171 H3270 * host; /**< Related 3270 session */
172   - gchar * session_name; /**< Session name (for window title) */
173 172 gchar * remap_filename; /**< @brief XML file with remap table. */
174 173  
  174 + struct {
  175 + gchar *name; /**< @brief Session name (for window title) */
  176 + gchar *title; /**< @brief Session title (for window title) */
  177 + } session;
  178 +
175 179 // Auto disconnect
176 180 struct
177 181 {
... ...
src/include/v3270.h
... ... @@ -241,9 +241,11 @@
241 241  
242 242 LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget);
243 243 LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name);
244   -
245 244 LIB3270_EXPORT gchar * v3270_get_session_title(GtkWidget *widget);
246 245  
  246 +// LIB3270_EXPORT gchar * v3270_get_title(GtkWidget *widget);
  247 + LIB3270_EXPORT gchar * v3270_set_title(GtkWidget *widget, const gchar *title);
  248 +
247 249 LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id);
248 250 LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on);
249 251 LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype);
... ...
src/terminal/properties/get.c
... ... @@ -130,12 +130,12 @@ LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget)
130 130  
131 131 v3270 * terminal = GTK_V3270(widget);
132 132  
133   - if(terminal->session_name)
134   - return terminal->session_name;
  133 + if(terminal->session.name)
  134 + return terminal->session.name;
135 135  
136 136 char id[] = { lib3270_get_session_id(terminal->host), 0 };
137 137 if(id[0])
138   - return (terminal->session_name = g_strconcat(G_STRINGIFY(PRODUCT_NAME),":",id,NULL));
  138 + return (terminal->session.name = g_strconcat(G_STRINGIFY(PRODUCT_NAME),":",id,NULL));
139 139  
140 140 return G_STRINGIFY(PRODUCT_NAME);
141 141  
... ... @@ -145,12 +145,17 @@ LIB3270_EXPORT gchar * v3270_get_session_title(GtkWidget *widget)
145 145 {
146 146 g_return_val_if_fail(GTK_IS_V3270(widget),NULL);
147 147  
148   - const char * url = lib3270_get_url(GTK_V3270(widget)->host);
  148 + v3270 * terminal = GTK_V3270(widget);
  149 +
  150 + const gchar * title = terminal->session.title;
  151 +
  152 + if(!title)
  153 + title = lib3270_get_url(GTK_V3270(widget)->host);
149 154  
150   - if(!url)
151   - url = _( "No host defined" );
  155 + if(!title)
  156 + title = _( "No host defined" );
152 157  
153   - return g_strconcat(v3270_get_session_name(widget)," - ",url,NULL);
  158 + return g_strconcat(v3270_get_session_name(widget)," - ",title,NULL);
154 159  
155 160 }
156 161  
... ...
src/terminal/properties/set.c
... ... @@ -153,22 +153,18 @@ LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name)
153 153 g_return_if_fail(GTK_IS_V3270(widget));
154 154 g_return_if_fail(name != NULL);
155 155  
156   - if(GTK_V3270(widget)->session_name) {
  156 + if(GTK_V3270(widget)->session.name) {
157 157  
158   - debug("Old session name was \"%s\"",GTK_V3270(widget)->session_name);
159   -
160   - if(!strcmp(GTK_V3270(widget)->session_name,name)) {
  158 + if(!strcmp(GTK_V3270(widget)->session.name,name)) {
161 159 // Same session name, keep it.
162 160 return;
163 161 }
164 162  
165   - g_free(GTK_V3270(widget)->session_name);
  163 + g_free(GTK_V3270(widget)->session.name);
166 164  
167 165 }
168 166  
169   - GTK_V3270(widget)->session_name = g_strdup(name);
170   -
171   - debug("New session name is \"%s\"",GTK_V3270(widget)->session_name);
  167 + GTK_V3270(widget)->session.name = g_strdup(name);
172 168  
173 169 g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[V3270_SIGNAL_SESSION_CHANGED], 0);
174 170 g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.session_name);
... ...
src/terminal/widget.c
... ... @@ -590,10 +590,16 @@ static void v3270_destroy(GtkWidget *widget)
590 590  
591 591 v3270_clear_selection(terminal);
592 592  
593   - if(terminal->session_name)
  593 + if(terminal->session.name)
594 594 {
595   - g_free(terminal->session_name);
596   - terminal->session_name = NULL;
  595 + g_free(terminal->session.name);
  596 + terminal->session.name = NULL;
  597 + }
  598 +
  599 + if(terminal->session.title)
  600 + {
  601 + g_free(terminal->session.title);
  602 + terminal->session.title = NULL;
597 603 }
598 604  
599 605 GTK_WIDGET_CLASS(v3270_parent_class)->destroy(widget);
... ...
src/testprogram/testprogram.c
... ... @@ -44,7 +44,7 @@
44 44 /*---[ Implement ]----------------------------------------------------------------------------------*/
45 45  
46 46 static void session_changed(GtkWidget *terminal, GtkWidget *window) {
47   - gtk_window_set_title(GTK_WINDOW(window),v3270_get_session_name(terminal));
  47 + gtk_window_set_title(GTK_WINDOW(window),v3270_get_session_title(terminal));
48 48 }
49 49  
50 50 static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
... ... @@ -80,7 +80,7 @@
80 80 // v3270_trace_window_new(terminal,NULL);
81 81  
82 82 // Setup and show main window
83   - gtk_window_set_title(GTK_WINDOW(window),v3270_get_session_name(terminal));
  83 + gtk_window_set_title(GTK_WINDOW(window),v3270_get_session_title(terminal));
84 84 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
85 85 gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);
86 86 gtk_container_add(GTK_CONTAINER(window),vBox);
... ...