Bug Summary

File:terminal-window.c
Warning:line 3526, column 9
Branch condition evaluates to a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name terminal-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib/llvm-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I .. -D TERMINAL_COMPILATION -D TERMINAL_RESOURCES_PATH_PREFIX="/org/cafe/terminal" -D TERM_DATADIR="/usr/share" -D TERM_LOCALEDIR="/usr/share/locale" -D TERM_PKGDATADIR="/usr/share/cafe-terminal" -D TERM_HELPDIR="/usr/share/help" -D SN_API_NOT_YET_FROZEN -D CDK_MULTIHEAD_SAFE -D G_DISABLE_SINGLE_INCLUDES -D PANGO_DISABLE_SINGLE_INCLUDES -D ATK_DISABLE_SINGLE_INCLUDES -D CDK_DISABLE_SINGLE_INCLUDES -D CDK_PIXBUF_DISABLE_SINGLE_INCLUDES -D CTK_DISABLE_SINGLE_INCLUDES -D EGG_SM_CLIENT_BACKEND_XSMP -I /usr/local/include/bte-2.91 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/ctk-3.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/dconf -I /usr/include/uuid -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2026-01-27-081422-19377-1 -x c terminal-window.c
1/*
2 * Copyright © 2001 Havoc Pennington
3 * Copyright © 2002 Red Hat, Inc.
4 * Copyright © 2007, 2008, 2009 Christian Persch
5 *
6 * Cafe-terminal is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Cafe-terminal is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <config.h>
21
22#include <string.h>
23#include <stdlib.h>
24#include <ctk/ctk.h>
25#include <cdk/cdk.h>
26#ifdef CDK_WINDOWING_X11
27#include <cdk/cdkx.h>
28#endif
29#include <cdk/cdkkeysyms.h>
30
31#include "terminal-accels.h"
32#include "terminal-app.h"
33#include "terminal-debug.h"
34#include "terminal-encoding.h"
35#include "terminal-intl.h"
36#include "terminal-screen-container.h"
37#include "terminal-search-dialog.h"
38#include "terminal-tab-label.h"
39#include "terminal-tabs-menu.h"
40#include "terminal-util.h"
41#include "terminal-window.h"
42
43#ifdef ENABLE_SKEY1
44#include "skey-popup.h"
45#endif
46
47static gboolean detach_tab = FALSE(0);
48
49struct _TerminalWindowPrivate
50{
51 CtkActionGroup *action_group;
52 CtkUIManager *ui_manager;
53 guint ui_id;
54
55 CtkActionGroup *profiles_action_group;
56 guint profiles_ui_id;
57
58 CtkActionGroup *encodings_action_group;
59 guint encodings_ui_id;
60
61 TerminalTabsMenu *tabs_menu;
62
63 TerminalScreenPopupInfo *popup_info;
64 guint remove_popup_info_idle;
65
66 CtkActionGroup *new_terminal_action_group;
67 guint new_terminal_ui_id;
68
69 CtkWidget *menubar;
70 CtkWidget *notebook;
71 CtkWidget *main_vbox;
72 TerminalScreen *active_screen;
73
74 /* Size of a character cell in pixels */
75 int old_char_width;
76 int old_char_height;
77
78 /* Width and height added to the actual terminal grid by "chrome" inside
79 * what was traditionally the X11 window: menu bar, title bar,
80 * style-provided padding. This must be included when resizing the window
81 * and also included in geometry hints. */
82 int old_chrome_width;
83 int old_chrome_height;
84
85 /* Width and height of the padding around the geometry widget. */
86 int old_padding_width;
87 int old_padding_height;
88
89 void *old_geometry_widget; /* only used for pointer value as it may be freed */
90
91 CtkWidget *confirm_close_dialog;
92 CtkWidget *search_find_dialog;
93
94 guint menubar_visible : 1;
95 guint use_default_menubar_visibility : 1;
96
97 /* Compositing manager integration */
98 guint have_argb_visual : 1;
99
100 /* Used to clear stray "demands attention" flashing on our window when we
101 * unmap and map it to switch to an ARGB visual.
102 */
103 guint clear_demands_attention : 1;
104
105 guint disposed : 1;
106 guint present_on_insert : 1;
107
108 /* Workaround until ctk+ bug #535557 is fixed */
109 guint icon_title_set : 1;
110 time_t focus_time;
111
112 /* should we copy selection to clibpoard */
113 int copy_selection;
114};
115
116#define PROFILE_DATA_KEY"GT::Profile" "GT::Profile"
117
118#define FILE_NEW_TERMINAL_TAB_UI_PATH"/menubar/File/FileNewTabProfiles" "/menubar/File/FileNewTabProfiles"
119#define FILE_NEW_TERMINAL_WINDOW_UI_PATH"/menubar/File/FileNewWindowProfiles" "/menubar/File/FileNewWindowProfiles"
120#define SET_ENCODING_UI_PATH"/menubar/Terminal/TerminalSetEncoding/EncodingsPH" "/menubar/Terminal/TerminalSetEncoding/EncodingsPH"
121#define SET_ENCODING_ACTION_NAME_PREFIX"TerminalSetEncoding" "TerminalSetEncoding"
122
123#define PROFILES_UI_PATH"/menubar/Terminal/TerminalProfiles/ProfilesPH" "/menubar/Terminal/TerminalProfiles/ProfilesPH"
124#define PROFILES_POPUP_UI_PATH"/Popup/PopupTerminalProfiles/ProfilesPH" "/Popup/PopupTerminalProfiles/ProfilesPH"
125
126#define SIZE_TO_UI_PATH"/menubar/Terminal/TerminalSizeToPH" "/menubar/Terminal/TerminalSizeToPH"
127#define SIZE_TO_ACTION_NAME_PREFIX"TerminalSizeTo" "TerminalSizeTo"
128
129#define STOCK_NEW_TAB"tab-new" "tab-new"
130
131#define ENCODING_DATA_KEY"encoding" "encoding"
132
133
134static void terminal_window_dispose (GObject *object);
135static void terminal_window_finalize (GObject *object);
136static gboolean terminal_window_state_event (CtkWidget *widget,
137 CdkEventWindowState *event);
138
139static gboolean terminal_window_delete_event (CtkWidget *widget,
140 CdkEvent *event,
141 gpointer data);
142static gboolean terminal_window_focus_in_event (CtkWidget *widget,
143 CdkEventFocus *event,
144 gpointer data);
145
146static gboolean notebook_button_press_cb (CtkWidget *notebook,
147 CdkEventButton *event,
148 GSettings *settings);
149static gboolean window_key_press_cb (CtkWidget *notebook,
150 CdkEventKey *event,
151 GSettings *settings);
152static gboolean notebook_popup_menu_cb (CtkWidget *notebook,
153 TerminalWindow *window);
154static void notebook_page_selected_callback (CtkWidget *notebook,
155 CtkWidget *page,
156 guint page_num,
157 TerminalWindow *window);
158static void notebook_page_added_callback (CtkWidget *notebook,
159 CtkWidget *container,
160 guint page_num,
161 TerminalWindow *window);
162static void notebook_page_removed_callback (CtkWidget *notebook,
163 CtkWidget *container,
164 guint page_num,
165 TerminalWindow *window);
166static gboolean notebook_scroll_event_cb (CtkWidget *notebook,
167 CdkEventScroll *event,
168 TerminalWindow *window);
169
170/* Menu action callbacks */
171static void file_new_window_callback (CtkAction *action,
172 TerminalWindow *window);
173static void file_new_tab_callback (CtkAction *action,
174 TerminalWindow *window);
175static void file_new_profile_callback (CtkAction *action,
176 TerminalWindow *window);
177static void file_close_window_callback (CtkAction *action,
178 TerminalWindow *window);
179static void file_save_contents_callback (CtkAction *action,
180 TerminalWindow *window);
181static void file_close_tab_callback (CtkAction *action,
182 TerminalWindow *window);
183static void edit_copy_callback (CtkAction *action,
184 TerminalWindow *window);
185static void edit_paste_callback (CtkAction *action,
186 TerminalWindow *window);
187static void edit_select_all_callback (CtkAction *action,
188 TerminalWindow *window);
189static void edit_keybindings_callback (CtkAction *action,
190 TerminalWindow *window);
191static void edit_profiles_callback (CtkAction *action,
192 TerminalWindow *window);
193static void edit_current_profile_callback (CtkAction *action,
194 TerminalWindow *window);
195static void view_menubar_toggled_callback (CtkToggleAction *action,
196 TerminalWindow *window);
197static void view_fullscreen_toggled_callback (CtkToggleAction *action,
198 TerminalWindow *window);
199static void view_zoom_in_callback (CtkAction *action,
200 TerminalWindow *window);
201static void view_zoom_out_callback (CtkAction *action,
202 TerminalWindow *window);
203static void view_zoom_normal_callback (CtkAction *action,
204 TerminalWindow *window);
205static void search_find_callback (CtkAction *action,
206 TerminalWindow *window);
207static void search_find_next_callback (CtkAction *action,
208 TerminalWindow *window);
209static void search_find_prev_callback (CtkAction *action,
210 TerminalWindow *window);
211static void search_clear_highlight_callback (CtkAction *action,
212 TerminalWindow *window);
213static void terminal_next_or_previous_profile_cb (CtkAction *action,
214 TerminalWindow *window);
215static void terminal_set_title_callback (CtkAction *action,
216 TerminalWindow *window);
217static void terminal_add_encoding_callback (CtkAction *action,
218 TerminalWindow *window);
219static void terminal_reset_callback (CtkAction *action,
220 TerminalWindow *window);
221static void terminal_reset_clear_callback (CtkAction *action,
222 TerminalWindow *window);
223static void tabs_next_or_previous_tab_cb (CtkAction *action,
224 TerminalWindow *window);
225static void tabs_move_left_callback (CtkAction *action,
226 TerminalWindow *window);
227static void tabs_move_right_callback (CtkAction *action,
228 TerminalWindow *window);
229static void tabs_detach_tab_callback (CtkAction *action,
230 TerminalWindow *window);
231static void help_contents_callback (CtkAction *action,
232 TerminalWindow *window);
233static void help_about_callback (CtkAction *action,
234 TerminalWindow *window);
235
236static gboolean find_larger_zoom_factor (double current,
237 double *found);
238static gboolean find_smaller_zoom_factor (double current,
239 double *found);
240
241static void terminal_window_show (CtkWidget *widget);
242
243static gboolean confirm_close_window_or_tab (TerminalWindow *window,
244 TerminalScreen *screen);
245
246static void
247profile_set_callback (TerminalScreen *screen,
248 TerminalProfile *old_profile,
249 TerminalWindow *window);
250static void
251sync_screen_icon_title (TerminalScreen *screen,
252 GParamSpec *psepc,
253 TerminalWindow *window);
254
255G_DEFINE_TYPE_WITH_PRIVATE (TerminalWindow, terminal_window, CTK_TYPE_WINDOW)static void terminal_window_init (TerminalWindow *self); static
void terminal_window_class_init (TerminalWindowClass *klass)
; static GType terminal_window_get_type_once (void); static gpointer
terminal_window_parent_class = ((void*)0); static gint TerminalWindow_private_offset
; static void terminal_window_class_intern_init (gpointer klass
) { terminal_window_parent_class = g_type_class_peek_parent (
klass); if (TerminalWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &TerminalWindow_private_offset); terminal_window_class_init
((TerminalWindowClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer terminal_window_get_instance_private
(TerminalWindow *self) { return (((gpointer) ((guint8*) (self
) + (glong) (TerminalWindow_private_offset)))); } GType terminal_window_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= terminal_window_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType terminal_window_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
ctk_window_get_type ()), g_intern_static_string ("TerminalWindow"
), sizeof (TerminalWindowClass), (GClassInitFunc)(void (*)(void
)) terminal_window_class_intern_init, sizeof (TerminalWindow)
, (GInstanceInitFunc)(void (*)(void)) terminal_window_init, (
GTypeFlags) 0); { {{ TerminalWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (TerminalWindowPrivate)); };} } return
g_define_type_id; }
256
257/* Menubar mnemonics & accel settings handling */
258
259static void
260app_setting_notify_cb (TerminalApp *app,
261 GParamSpec *pspec,
262 CdkScreen *screen)
263{
264 CtkSettings *settings;
265 const char *prop_name;
266
267 if (pspec)
268 prop_name = pspec->name;
269 else
270 prop_name = NULL((void*)0);
271
272 settings = ctk_settings_get_for_screen (screen);
273
274 if (!prop_name || prop_name == I_(TERMINAL_APP_ENABLE_MNEMONICS)g_intern_static_string ("enable-mnemonics"))
275 {
276 gboolean enable_mnemonics;
277
278 g_object_get (app, TERMINAL_APP_ENABLE_MNEMONICS"enable-mnemonics", &enable_mnemonics, NULL((void*)0));
279 g_object_set (settings, "ctk-enable-mnemonics", enable_mnemonics, NULL((void*)0));
280 }
281
282 if (!prop_name || prop_name == I_(TERMINAL_APP_ENABLE_MENU_BAR_ACCEL)g_intern_static_string ("enable-menu-accels"))
283 {
284 /* const */ char *saved_menubar_accel;
285 gboolean enable_menubar_accel;
286
287 /* FIXME: Once ctk+ bug 507398 is fixed, use that to reset the property instead */
288 /* Now this is a bad hack on so many levels. */
289 saved_menubar_accel = g_object_get_data (G_OBJECT (settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((settings)), (((GType) ((20) << (2))))))))
, "GT::ctk-menu-bar-accel");
290 if (!saved_menubar_accel)
291 {
292 g_object_get (settings, "ctk-menu-bar-accel", &saved_menubar_accel, NULL((void*)0));
293 g_object_set_data_full (G_OBJECT (settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((settings)), (((GType) ((20) << (2))))))))
, "GT::ctk-menu-bar-accel",
294 saved_menubar_accel, (GDestroyNotify) g_free);
295 }
296
297 g_object_get (app, TERMINAL_APP_ENABLE_MENU_BAR_ACCEL"enable-menu-accels", &enable_menubar_accel, NULL((void*)0));
298 if (enable_menubar_accel)
299 g_object_set (settings, "ctk-menu-bar-accel", saved_menubar_accel, NULL((void*)0));
300 else
301 g_object_set (settings, "ctk-menu-bar-accel", NULL((void*)0), NULL((void*)0));
302 }
303}
304
305static void
306app_setting_notify_destroy_cb (CdkScreen *screen)
307{
308 g_signal_handlers_disconnect_by_func (terminal_app_get (),g_signal_handlers_disconnect_matched ((terminal_app_get ()), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (app_setting_notify_cb))), (
screen))
309 G_CALLBACK (app_setting_notify_cb),g_signal_handlers_disconnect_matched ((terminal_app_get ()), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (app_setting_notify_cb))), (
screen))
310 screen)g_signal_handlers_disconnect_matched ((terminal_app_get ()), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (app_setting_notify_cb))), (
screen))
;
311}
312
313/* utility functions */
314
315/*
316 Derived from XParseGeometry() in X.org
317
318 Copyright 1985, 1986, 1987, 1998 The Open Group
319
320 All Rights Reserved.
321
322 The above copyright notice and this permission notice shall be included
323 in all copies or substantial portions of the Software.
324
325 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
326 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
327 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
328 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
329 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
330 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
331 OTHER DEALINGS IN THE SOFTWARE.
332
333 Except as contained in this notice, the name of The Open Group shall
334 not be used in advertising or otherwise to promote the sale, use or
335 other dealings in this Software without prior written authorization
336 from The Open Group.
337*/
338
339/*
340 * XParseGeometry parses strings of the form
341 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
342 * width, height, xoffset, and yoffset are unsigned integers.
343 * Example: "=80x24+300-49"
344 * The equal sign is optional.
345 * It returns a bitmask that indicates which of the four values
346 * were actually found in the string. For each value found,
347 * the corresponding argument is updated; for each value
348 * not found, the corresponding argument is left unchanged.
349 */
350
351/* The following code is from Xlib, and is minimally modified, so we
352 * can track any upstream changes if required. Don’t change this
353 * code. Or if you do, put in a huge comment marking which thing
354 * changed.
355 */
356
357static int
358terminal_window_ReadInteger (char *string,
359 char **NextString)
360{
361 register int Result = 0;
362 int Sign = 1;
363
364 if (*string == '+')
365 string++;
366 else if (*string == '-')
367 {
368 string++;
369 Sign = -1;
370 }
371 for (; (*string >= '0') && (*string <= '9'); string++)
372 {
373 Result = (Result * 10) + (*string - '0');
374 }
375 *NextString = string;
376 if (Sign >= 0)
377 return (Result);
378 else
379 return (-Result);
380}
381
382/*
383 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
384 * value (x, y, width, height) was found in the parsed string.
385 */
386#define NoValue0x0000 0x0000
387#define XValue0x0001 0x0001
388#define YValue0x0002 0x0002
389#define WidthValue0x0004 0x0004
390#define HeightValue0x0008 0x0008
391#define XNegative0x0010 0x0010
392#define YNegative0x0020 0x0020
393
394static int
395terminal_window_XParseGeometry (const char *string,
396 int *x, int *y,
397 unsigned int *width,
398 unsigned int *height)
399{
400 int mask = NoValue0x0000;
401 register char *strind;
402 unsigned int tempWidth = 0, tempHeight = 0;
403 int tempX = 0, tempY = 0;
404 char *nextCharacter;
405
406 if ( (string == NULL((void*)0)) || (*string == '\0')) return(mask);
407 if (*string == '=')
408 string++; /* ignore possible '=' at beg of geometry spec */
409
410 strind = (char *)string;
411 if (*strind != '+' && *strind != '-' && *strind != 'x') {
412 tempWidth = terminal_window_ReadInteger(strind, &nextCharacter);
413 if (strind == nextCharacter)
414 return (0);
415 strind = nextCharacter;
416 mask |= WidthValue0x0004;
417 }
418
419 if (*strind == 'x' || *strind == 'X') {
420 strind++;
421 tempHeight = terminal_window_ReadInteger(strind, &nextCharacter);
422 if (strind == nextCharacter)
423 return (0);
424 strind = nextCharacter;
425 mask |= HeightValue0x0008;
426 }
427
428 if ((*strind == '+') || (*strind == '-')) {
429 if (*strind == '-') {
430 strind++;
431 tempX = -terminal_window_ReadInteger(strind, &nextCharacter);
432 if (strind == nextCharacter)
433 return (0);
434 strind = nextCharacter;
435 mask |= XNegative0x0010;
436
437 }
438 else
439 { strind++;
440 tempX = terminal_window_ReadInteger(strind, &nextCharacter);
441 if (strind == nextCharacter)
442 return(0);
443 strind = nextCharacter;
444 }
445 mask |= XValue0x0001;
446 if ((*strind == '+') || (*strind == '-')) {
447 if (*strind == '-') {
448 strind++;
449 tempY = -terminal_window_ReadInteger(strind, &nextCharacter);
450 if (strind == nextCharacter)
451 return(0);
452 strind = nextCharacter;
453 mask |= YNegative0x0020;
454
455 }
456 else
457 {
458 strind++;
459 tempY = terminal_window_ReadInteger(strind, &nextCharacter);
460 if (strind == nextCharacter)
461 return(0);
462 strind = nextCharacter;
463 }
464 mask |= YValue0x0002;
465 }
466 }
467
468 /* If strind isn't at the end of the string the it's an invalid
469 geometry specification. */
470
471 if (*strind != '\0') return (0);
472
473 if (mask & XValue0x0001)
474 *x = tempX;
475 if (mask & YValue0x0002)
476 *y = tempY;
477 if (mask & WidthValue0x0004)
478 *width = tempWidth;
479 if (mask & HeightValue0x0008)
480 *height = tempHeight;
481 return (mask);
482}
483
484static char *
485escape_underscores (const char *name)
486{
487 GString *escaped_name;
488
489 g_assert (name != NULL)do { if (name != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "terminal-window.c", 489, ((const char*) (__func__
)), "name != NULL"); } while (0)
;
490
491 /* Who'd use more that 4 underscores in a profile name... */
492 escaped_name = g_string_sized_new (strlen (name) + 4 + 1);
493
494 while (*name)
495 {
496 if (*name == '_')
497 g_string_append (escaped_name, "__")(__builtin_constant_p ("__") ? __extension__ ({ const char * const
__val = ("__"); g_string_append_len_inline (escaped_name, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (escaped_name
, "__", (gssize) -1))
;
498 else
499 g_string_append_c (escaped_name, *name)g_string_append_c_inline (escaped_name, *name);
500 name++;
501 }
502
503 return g_string_free (escaped_name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((escaped_name
), ((0))) : g_string_free_and_steal (escaped_name)) : (g_string_free
) ((escaped_name), ((0))))
;
504}
505
506static int
507find_tab_num_at_pos (CtkNotebook *notebook,
508 int screen_x,
509 int screen_y)
510{
511 CtkPositionType tab_pos;
512 int page_num = 0;
513 CtkNotebook *nb = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
;
514 CtkWidget *page;
515 CtkAllocation tab_allocation;
516
517 tab_pos = ctk_notebook_get_tab_pos (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
518
519 while ((page = ctk_notebook_get_nth_page (nb, page_num)))
520 {
521 CtkWidget *tab;
522 int max_x, max_y, x_root, y_root;
523
524 tab = ctk_notebook_get_tab_label (nb, page);
525 g_return_val_if_fail (tab != NULL, -1)do { if ((tab != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "tab != NULL"); return
(-1); } } while (0)
;
526
527 if (!ctk_widget_get_mapped (CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tab)), ((ctk_widget_get_type ()))))))
))
528 {
529 page_num++;
530 continue;
531 }
532
533 cdk_window_get_origin (ctk_widget_get_window (tab), &x_root, &y_root);
534
535 ctk_widget_get_allocation (tab, &tab_allocation);
536 max_x = x_root + tab_allocation.x + tab_allocation.width;
537 max_y = y_root + tab_allocation.y + tab_allocation.height;
538
539 if ((tab_pos == CTK_POS_TOP || tab_pos == CTK_POS_BOTTOM) && screen_x <= max_x)
540 return page_num;
541
542 if ((tab_pos == CTK_POS_LEFT || tab_pos == CTK_POS_RIGHT) && screen_y <= max_y)
543 return page_num;
544
545 page_num++;
546 }
547
548 return -1;
549}
550
551static void
552terminal_set_profile_toggled_callback (CtkToggleAction *action,
553 TerminalWindow *window)
554{
555 TerminalWindowPrivate *priv = window->priv;
556 TerminalProfile *profile;
557
558 if (!ctk_toggle_action_get_active (action))
559 return;
560
561 if (priv->active_screen == NULL((void*)0))
562 return;
563
564 profile = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, PROFILE_DATA_KEY"GT::Profile");
565 g_assert (profile)do { if (profile) ; else g_assertion_message_expr (((gchar*) 0
), "terminal-window.c", 565, ((const char*) (__func__)), "profile"
); } while (0)
;
566
567 if (_terminal_profile_get_forgotten (profile))
568 return;
569
570 g_signal_handlers_block_by_func (priv->active_screen, G_CALLBACK (profile_set_callback), window)g_signal_handlers_block_matched ((priv->active_screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (profile_set_callback))), (window))
;
571 terminal_screen_set_profile (priv->active_screen, profile);
572 g_signal_handlers_unblock_by_func (priv->active_screen, G_CALLBACK (profile_set_callback), window)g_signal_handlers_unblock_matched ((priv->active_screen), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (profile_set_callback))), (
window))
;
573}
574
575static void
576profile_visible_name_notify_cb (TerminalProfile *profile,
577 GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)),
578 CtkAction *action)
579{
580 const char *visible_name;
581 char *dot, *display_name;
582 guint num;
583
584 visible_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_VISIBLE_NAME"visible-name");
585 display_name = escape_underscores (visible_name);
586
587 dot = strchr (ctk_action_get_name (action), '.');
588 if (dot != NULL((void*)0))
589 {
590 char *free_me;
591
592 num = g_ascii_strtoll (dot + 1, NULL((void*)0), 10);
593
594 free_me = display_name;
595 if (num < 10)
596 /* Translators: This is the label of a menu item to choose a profile.
597 * _%d is used as the accelerator (with d between 1 and 9), and
598 * the %s is the name of the terminal profile.
599 */
600 display_name = g_strdup_printf (_("_%d. %s")gettext ("_%d. %s"), num, display_name);
601 else if (num < 36)
602 /* Translators: This is the label of a menu item to choose a profile.
603 * _%c is used as the accelerator (it will be a character between A and Z),
604 * and the %s is the name of the terminal profile.
605 */
606 display_name = g_strdup_printf (_("_%c. %s")gettext ("_%c. %s"), ('A' + num - 10), display_name);
607 else
608 free_me = NULL((void*)0);
609
610 g_free (free_me);
611 }
612
613 g_object_set (action, "label", display_name, NULL((void*)0));
614 g_free (display_name);
615}
616
617static void
618disconnect_profiles_from_actions_in_group (CtkActionGroup *action_group)
619{
620 GList *actions, *l;
621
622 actions = ctk_action_group_list_actions (action_group);
623 for (l = actions; l != NULL((void*)0); l = l->next)
624 {
625 GObject *action = G_OBJECT (l->data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (((GType) ((20) << (2))))))))
;
626 TerminalProfile *profile;
627
628 profile = g_object_get_data (action, PROFILE_DATA_KEY"GT::Profile");
629 if (!profile)
630 continue;
631
632 g_signal_handlers_disconnect_by_func (profile, G_CALLBACK (profile_visible_name_notify_cb), action)g_signal_handlers_disconnect_matched ((profile), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (profile_visible_name_notify_cb))), (action
))
;
633 }
634 g_list_free (actions);
635}
636
637static void
638terminal_window_update_set_profile_menu_active_profile (TerminalWindow *window)
639{
640 TerminalWindowPrivate *priv = window->priv;
641 TerminalProfile *new_active_profile;
642 GList *actions, *l;
643
644 if (!priv->profiles_action_group)
645 return;
646
647 if (!priv->active_screen)
648 return;
649
650 new_active_profile = terminal_screen_get_profile (priv->active_screen);
651
652 actions = ctk_action_group_list_actions (priv->profiles_action_group);
653 for (l = actions; l != NULL((void*)0); l = l->next)
654 {
655 GObject *action = G_OBJECT (l->data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (((GType) ((20) << (2))))))))
;
656 TerminalProfile *profile;
657
658 profile = g_object_get_data (action, PROFILE_DATA_KEY"GT::Profile");
659 if (profile != new_active_profile)
660 continue;
661
662 g_signal_handlers_block_by_func (action, G_CALLBACK (terminal_set_profile_toggled_callback), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (terminal_set_profile_toggled_callback))), (
window))
;
663 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
, TRUE(!(0)));
664 g_signal_handlers_unblock_by_func (action, G_CALLBACK (terminal_set_profile_toggled_callback), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_set_profile_toggled_callback))), (
window))
;
665
666 break;
667 }
668 g_list_free (actions);
669}
670
671static void
672terminal_window_update_set_profile_menu (TerminalWindow *window)
673{
674 TerminalWindowPrivate *priv = window->priv;
675 TerminalProfile *active_profile;
676 CtkActionGroup *action_group;
677 CtkAction *action;
678 GList *profiles, *p;
679 GSList *group;
680 guint n;
681 gboolean single_profile;
682
683 /* Remove the old UI */
684 if (priv->profiles_ui_id != 0)
685 {
686 ctk_ui_manager_remove_ui (priv->ui_manager, priv->profiles_ui_id);
687 priv->profiles_ui_id = 0;
688 }
689
690 if (priv->profiles_action_group != NULL((void*)0))
691 {
692 disconnect_profiles_from_actions_in_group (priv->profiles_action_group);
693 ctk_ui_manager_remove_action_group (priv->ui_manager,
694 priv->profiles_action_group);
695 priv->profiles_action_group = NULL((void*)0);
696 }
697
698 profiles = terminal_app_get_profile_list (terminal_app_get ());
699
700 action = ctk_action_group_get_action (priv->action_group, "TerminalProfiles");
701 single_profile = !profiles || profiles->next == NULL((void*)0); /* list length <= 1 */
702 ctk_action_set_sensitive (action, !single_profile);
703 if (profiles == NULL((void*)0))
704 return;
705
706 if (priv->active_screen)
707 active_profile = terminal_screen_get_profile (priv->active_screen);
708 else
709 active_profile = NULL((void*)0);
710
711 action_group = priv->profiles_action_group = ctk_action_group_new ("Profiles");
712 ctk_ui_manager_insert_action_group (priv->ui_manager, action_group, -1);
713 g_object_unref (action_group);
714
715 priv->profiles_ui_id = ctk_ui_manager_new_merge_id (priv->ui_manager);
716
717 group = NULL((void*)0);
718 n = 0;
719 for (p = profiles; p != NULL((void*)0); p = p->next)
720 {
721 TerminalProfile *profile = (TerminalProfile *) p->data;
722 CtkRadioAction *profile_action;
723 char name[32];
724
725 g_snprintf (name, sizeof (name), "TerminalSetProfile%u", n++);
726
727 profile_action = ctk_radio_action_new (name,
728 NULL((void*)0),
729 NULL((void*)0),
730 NULL((void*)0),
731 n);
732
733 ctk_radio_action_set_group (profile_action, group);
734 group = ctk_radio_action_get_group (profile_action);
735
736 if (profile == active_profile)
737 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (profile_action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((profile_action)), ((ctk_toggle_action_get_type ()))))))
, TRUE(!(0)));
738
739 g_object_set_data_full (G_OBJECT (profile_action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((profile_action)), (((GType) ((20) << (2))))))))
,
740 PROFILE_DATA_KEY"GT::Profile",
741 g_object_ref (profile)((__typeof__ (profile)) (g_object_ref) (profile)),
742 (GDestroyNotify) g_object_unref);
743 profile_visible_name_notify_cb (profile, NULL((void*)0), CTK_ACTION (profile_action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((profile_action)), ((ctk_action_get_type ()))))))
);
744 g_signal_connect (profile, "notify::" TERMINAL_PROFILE_VISIBLE_NAME,g_signal_connect_data ((profile), ("notify::" "visible-name")
, (((GCallback) (profile_visible_name_notify_cb))), (profile_action
), ((void*)0), (GConnectFlags) 0)
745 G_CALLBACK (profile_visible_name_notify_cb), profile_action)g_signal_connect_data ((profile), ("notify::" "visible-name")
, (((GCallback) (profile_visible_name_notify_cb))), (profile_action
), ((void*)0), (GConnectFlags) 0)
;
746 g_signal_connect (profile_action, "toggled",g_signal_connect_data ((profile_action), ("toggled"), (((GCallback
) (terminal_set_profile_toggled_callback))), (window), ((void
*)0), (GConnectFlags) 0)
747 G_CALLBACK (terminal_set_profile_toggled_callback), window)g_signal_connect_data ((profile_action), ("toggled"), (((GCallback
) (terminal_set_profile_toggled_callback))), (window), ((void
*)0), (GConnectFlags) 0)
;
748
749 ctk_action_group_add_action (action_group, CTK_ACTION (profile_action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((profile_action)), ((ctk_action_get_type ()))))))
);
750 g_object_unref (profile_action);
751
752 ctk_ui_manager_add_ui (priv->ui_manager, priv->profiles_ui_id,
753 PROFILES_UI_PATH"/menubar/Terminal/TerminalProfiles/ProfilesPH",
754 name, name,
755 CTK_UI_MANAGER_MENUITEM, FALSE(0));
756 ctk_ui_manager_add_ui (priv->ui_manager, priv->profiles_ui_id,
757 PROFILES_POPUP_UI_PATH"/Popup/PopupTerminalProfiles/ProfilesPH",
758 name, name,
759 CTK_UI_MANAGER_MENUITEM, FALSE(0));
760 }
761
762 g_list_free (profiles);
763}
764
765static void
766terminal_window_create_new_terminal_action (TerminalWindow *window,
767 TerminalProfile *profile,
768 const char *name,
769 guint num G_GNUC_UNUSED__attribute__ ((__unused__)),
770 GCallback callback)
771{
772 TerminalWindowPrivate *priv = window->priv;
773 CtkAction *action;
774
775 action = ctk_action_new (name, NULL((void*)0), NULL((void*)0), NULL((void*)0));
776
777 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
,
778 PROFILE_DATA_KEY"GT::Profile",
779 g_object_ref (profile)((__typeof__ (profile)) (g_object_ref) (profile)),
780 (GDestroyNotify) g_object_unref);
781 profile_visible_name_notify_cb (profile, NULL((void*)0), action);
782 g_signal_connect (profile, "notify::" TERMINAL_PROFILE_VISIBLE_NAME,g_signal_connect_data ((profile), ("notify::" "visible-name")
, (((GCallback) (profile_visible_name_notify_cb))), (action),
((void*)0), (GConnectFlags) 0)
783 G_CALLBACK (profile_visible_name_notify_cb), action)g_signal_connect_data ((profile), ("notify::" "visible-name")
, (((GCallback) (profile_visible_name_notify_cb))), (action),
((void*)0), (GConnectFlags) 0)
;
784 g_signal_connect (action, "activate", callback, window)g_signal_connect_data ((action), ("activate"), (callback), (window
), ((void*)0), (GConnectFlags) 0)
;
785
786 ctk_action_group_add_action (priv->new_terminal_action_group, action);
787 g_object_unref (action);
788}
789
790static void
791terminal_window_update_new_terminal_menus (TerminalWindow *window)
792{
793 TerminalWindowPrivate *priv = window->priv;
794 CtkActionGroup *action_group;
795 CtkAction *action;
796 GList *profiles, *p;
797 guint n;
798 gboolean have_single_profile;
799
800 /* Remove the old UI */
801 if (priv->new_terminal_ui_id != 0)
802 {
803 ctk_ui_manager_remove_ui (priv->ui_manager, priv->new_terminal_ui_id);
804 priv->new_terminal_ui_id = 0;
805 }
806
807 if (priv->new_terminal_action_group != NULL((void*)0))
808 {
809 disconnect_profiles_from_actions_in_group (priv->new_terminal_action_group);
810 ctk_ui_manager_remove_action_group (priv->ui_manager,
811 priv->new_terminal_action_group);
812 priv->new_terminal_action_group = NULL((void*)0);
813 }
814
815 profiles = terminal_app_get_profile_list (terminal_app_get ());
816 have_single_profile = !profiles || !profiles->next;
817
818 action = ctk_action_group_get_action (priv->action_group, "FileNewTab");
819 ctk_action_set_visible (action, have_single_profile);
820 action = ctk_action_group_get_action (priv->action_group, "FileNewWindow");
821 ctk_action_set_visible (action, have_single_profile);
822
823 if (have_single_profile)
824 {
825 g_list_free (profiles);
826 return;
827 }
828
829 /* Now build the submenus */
830
831 action_group = priv->new_terminal_action_group = ctk_action_group_new ("NewTerminal");
832 ctk_ui_manager_insert_action_group (priv->ui_manager, action_group, -1);
833 g_object_unref (action_group);
834
835 priv->new_terminal_ui_id = ctk_ui_manager_new_merge_id (priv->ui_manager);
836
837 n = 0;
838 for (p = profiles; p != NULL((void*)0); p = p->next)
839 {
840 TerminalProfile *profile = (TerminalProfile *) p->data;
841 char name[32];
842
843 g_snprintf (name, sizeof (name), "FileNewTab.%u", n);
844 terminal_window_create_new_terminal_action (window,
845 profile,
846 name,
847 n,
848 G_CALLBACK (file_new_tab_callback)((GCallback) (file_new_tab_callback)));
849
850 ctk_ui_manager_add_ui (priv->ui_manager, priv->new_terminal_ui_id,
851 FILE_NEW_TERMINAL_TAB_UI_PATH"/menubar/File/FileNewTabProfiles",
852 name, name,
853 CTK_UI_MANAGER_MENUITEM, FALSE(0));
854
855 g_snprintf (name, sizeof (name), "FileNewWindow.%u", n);
856 terminal_window_create_new_terminal_action (window,
857 profile,
858 name,
859 n,
860 G_CALLBACK (file_new_window_callback)((GCallback) (file_new_window_callback)));
861
862 ctk_ui_manager_add_ui (priv->ui_manager, priv->new_terminal_ui_id,
863 FILE_NEW_TERMINAL_WINDOW_UI_PATH"/menubar/File/FileNewWindowProfiles",
864 name, name,
865 CTK_UI_MANAGER_MENUITEM, FALSE(0));
866
867 ++n;
868 }
869
870 g_list_free (profiles);
871}
872
873static void
874terminal_set_encoding_callback (CtkToggleAction *action,
875 TerminalWindow *window)
876{
877 TerminalWindowPrivate *priv = window->priv;
878 TerminalEncoding *encoding;
879
880 if (!ctk_toggle_action_get_active (action))
881 return;
882
883 if (priv->active_screen == NULL((void*)0))
884 return;
885
886 encoding = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, ENCODING_DATA_KEY"encoding");
887 g_assert (encoding)do { if (encoding) ; else g_assertion_message_expr (((gchar*)
0), "terminal-window.c", 887, ((const char*) (__func__)), "encoding"
); } while (0)
;
888
889 bte_terminal_set_encoding (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
,
890 terminal_encoding_get_charset (encoding), NULL((void*)0));
891}
892
893static void
894terminal_window_update_encoding_menu (TerminalWindow *window)
895{
896 TerminalWindowPrivate *priv = window->priv;
897 TerminalApp *app;
898 CtkActionGroup *action_group;
899 GSList *group;
900 guint n;
901 GSList *encodings, *l;
902 const char *charset;
903 TerminalEncoding *active_encoding;
904
905 /* Remove the old UI */
906 if (priv->encodings_ui_id != 0)
907 {
908 ctk_ui_manager_remove_ui (priv->ui_manager, priv->encodings_ui_id);
909 priv->encodings_ui_id = 0;
910 }
911
912 if (priv->encodings_action_group != NULL((void*)0))
913 {
914 ctk_ui_manager_remove_action_group (priv->ui_manager,
915 priv->encodings_action_group);
916 priv->encodings_action_group = NULL((void*)0);
917 }
918
919 action_group = priv->encodings_action_group = ctk_action_group_new ("Encodings");
920 ctk_ui_manager_insert_action_group (priv->ui_manager, action_group, -1);
921 g_object_unref (action_group);
922
923 priv->encodings_ui_id = ctk_ui_manager_new_merge_id (priv->ui_manager);
924
925 if (priv->active_screen)
926 charset = bte_terminal_get_encoding (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
);
927 else
928 charset = "current";
929
930 app = terminal_app_get ();
931 active_encoding = terminal_app_ensure_encoding (app, charset);
932
933 encodings = terminal_app_get_active_encodings (app);
934
935 if (g_slist_find (encodings, active_encoding) == NULL((void*)0))
936 encodings = g_slist_append (encodings, terminal_encoding_ref (active_encoding));
937
938 group = NULL((void*)0);
939 n = 0;
940 for (l = encodings; l != NULL((void*)0); l = l->next)
941 {
942 TerminalEncoding *e = (TerminalEncoding *) l->data;
943 CtkRadioAction *encoding_action;
944 char name[128];
945 char *display_name;
946
947 g_snprintf (name, sizeof (name), SET_ENCODING_ACTION_NAME_PREFIX"TerminalSetEncoding" "%s", terminal_encoding_get_id (e));
948 display_name = g_strdup_printf ("%s (%s)", e->name, terminal_encoding_get_charset (e));
949
950 encoding_action = ctk_radio_action_new (name,
951 display_name,
952 NULL((void*)0),
953 NULL((void*)0),
954 n);
955 g_free (display_name);
956
957 ctk_radio_action_set_group (encoding_action, group);
958 group = ctk_radio_action_get_group (encoding_action);
959
960 if (charset && strcmp (terminal_encoding_get_id (e), charset) == 0)
961 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (encoding_action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((encoding_action)), ((ctk_toggle_action_get_type ()))))))
, TRUE(!(0)));
962
963 g_signal_connect (encoding_action, "toggled",g_signal_connect_data ((encoding_action), ("toggled"), (((GCallback
) (terminal_set_encoding_callback))), (window), ((void*)0), (
GConnectFlags) 0)
964 G_CALLBACK (terminal_set_encoding_callback), window)g_signal_connect_data ((encoding_action), ("toggled"), (((GCallback
) (terminal_set_encoding_callback))), (window), ((void*)0), (
GConnectFlags) 0)
;
965
966 g_object_set_data_full (G_OBJECT (encoding_action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((encoding_action)), (((GType) ((20) << (2))))))))
, ENCODING_DATA_KEY"encoding",
967 terminal_encoding_ref (e),
968 (GDestroyNotify) terminal_encoding_unref);
969
970 ctk_action_group_add_action (action_group, CTK_ACTION (encoding_action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((encoding_action)), ((ctk_action_get_type ()))))))
);
971 g_object_unref (encoding_action);
972
973 ctk_ui_manager_add_ui (priv->ui_manager, priv->encodings_ui_id,
974 SET_ENCODING_UI_PATH"/menubar/Terminal/TerminalSetEncoding/EncodingsPH",
975 name, name,
976 CTK_UI_MANAGER_MENUITEM, FALSE(0));
977 }
978
979 g_slist_foreach (encodings, (GFunc) terminal_encoding_unref, NULL((void*)0));
980 g_slist_free (encodings);
981}
982
983static void
984terminal_window_update_encoding_menu_active_encoding (TerminalWindow *window)
985{
986 TerminalWindowPrivate *priv = window->priv;
987 CtkAction *action;
988 char name[128];
989
990 if (!priv->active_screen)
991 return;
992 if (!priv->encodings_action_group)
993 return;
994
995 g_snprintf (name, sizeof (name), SET_ENCODING_ACTION_NAME_PREFIX"TerminalSetEncoding" "%s",
996 bte_terminal_get_encoding (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
));
997 action = ctk_action_group_get_action (priv->encodings_action_group, name);
998 if (!action)
999 return;
1000
1001 g_signal_handlers_block_by_func (action, G_CALLBACK (terminal_set_encoding_callback), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (terminal_set_encoding_callback))), (window)
)
;
1002 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
, TRUE(!(0)));
1003 g_signal_handlers_unblock_by_func (action, G_CALLBACK (terminal_set_encoding_callback), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_set_encoding_callback))), (window
))
;
1004}
1005
1006static void
1007terminal_size_to_cb (CtkAction *action,
1008 TerminalWindow *window)
1009{
1010 TerminalWindowPrivate *priv = window->priv;
1011 const char *name;
1012 char *end = NULL((void*)0);
1013 guint width, height;
1014
1015 if (priv->active_screen == NULL((void*)0))
1016 return;
1017
1018 name = ctk_action_get_name (action) + strlen (SIZE_TO_ACTION_NAME_PREFIX"TerminalSizeTo");
1019 width = g_ascii_strtoull (name, &end, 10);
1020 g_assert (end && *end == 'x')do { if (end && *end == 'x') ; else g_assertion_message_expr
(((gchar*) 0), "terminal-window.c", 1020, ((const char*) (__func__
)), "end && *end == 'x'"); } while (0)
;
1021 height = g_ascii_strtoull (end + 1, &end, 10);
1022 g_assert (end && *end == '\0')do { if (end && *end == '\0') ; else g_assertion_message_expr
(((gchar*) 0), "terminal-window.c", 1022, ((const char*) (__func__
)), "end && *end == '\\0'"); } while (0)
;
1023
1024 bte_terminal_set_size (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
, width, height);
1025
1026 terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
1027}
1028
1029static void
1030terminal_window_update_size_to_menu (TerminalWindow *window)
1031{
1032 static const struct
1033 {
1034 guint grid_width;
1035 guint grid_height;
1036 } predefined_sizes[] =
1037 {
1038 { 80, 24 },
1039 { 80, 43 },
1040 { 132, 24 },
1041 { 132, 43 }
1042 };
1043 TerminalWindowPrivate *priv = window->priv;
1044 guint i;
1045
1046 /* We only install this once, so there's no need for a separate action group
1047 * and any cleanup + build-new-one action here.
1048 */
1049
1050 for (i = 0; i < G_N_ELEMENTS (predefined_sizes)(sizeof (predefined_sizes) / sizeof ((predefined_sizes)[0])); ++i)
1051 {
1052 guint grid_width = predefined_sizes[i].grid_width;
1053 guint grid_height = predefined_sizes[i].grid_height;
1054 CtkAction *action;
1055 char name[40];
1056 char *display_name;
1057
1058 g_snprintf (name, sizeof (name), SIZE_TO_ACTION_NAME_PREFIX"TerminalSizeTo" "%ux%u",
1059 grid_width, grid_height);
1060
1061 /* If there are ever more than 9 of these, extend this to use A..Z as mnemonics,
1062 * like we do for the profiles menu.
1063 */
1064 display_name = g_strdup_printf ("_%u. %ux%u", i + 1, grid_width, grid_height);
1065
1066 action = ctk_action_new (name, display_name, NULL((void*)0), NULL((void*)0));
1067 g_free (display_name);
1068
1069 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
terminal_size_to_cb))), (window), ((void*)0), (GConnectFlags)
0)
1070 G_CALLBACK (terminal_size_to_cb), window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
terminal_size_to_cb))), (window), ((void*)0), (GConnectFlags)
0)
;
1071
1072 ctk_action_group_add_action (priv->action_group, action);
1073 g_object_unref (action);
1074
1075 ctk_ui_manager_add_ui (priv->ui_manager, priv->ui_id,
1076 SIZE_TO_UI_PATH"/menubar/Terminal/TerminalSizeToPH",
1077 name, name,
1078 CTK_UI_MANAGER_MENUITEM, FALSE(0));
1079 }
1080}
1081
1082/* Actions stuff */
1083
1084static void
1085terminal_window_update_copy_sensitivity (TerminalScreen *screen,
1086 TerminalWindow *window)
1087{
1088 TerminalWindowPrivate *priv = window->priv;
1089 CtkAction *action;
1090 gboolean can_copy;
1091
1092 if (screen != priv->active_screen)
1093 return;
1094
1095 can_copy = bte_terminal_get_has_selection (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
);
1096
1097 action = ctk_action_group_get_action (priv->action_group, "EditCopy");
1098 ctk_action_set_sensitive (action, can_copy);
1099
1100 if (can_copy && priv->copy_selection)
1101 bte_terminal_copy_clipboard_format (BTE_TERMINAL(screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
, BTE_FORMAT_TEXT);
1102}
1103
1104static void
1105terminal_window_update_zoom_sensitivity (TerminalWindow *window)
1106{
1107 TerminalWindowPrivate *priv = window->priv;
1108 TerminalScreen *screen;
1109 CtkAction *action;
1110 double current, zoom;
1111
1112 screen = priv->active_screen;
1113 if (screen == NULL((void*)0))
1114 return;
1115
1116 current = terminal_screen_get_font_scale (screen);
1117
1118 action = ctk_action_group_get_action (priv->action_group, "ViewZoomOut");
1119 ctk_action_set_sensitive (action, find_smaller_zoom_factor (current, &zoom));
1120 action = ctk_action_group_get_action (priv->action_group, "ViewZoomIn");
1121 ctk_action_set_sensitive (action, find_larger_zoom_factor (current, &zoom));
1122}
1123
1124static void
1125terminal_window_update_search_sensitivity (TerminalScreen *screen,
1126 TerminalWindow *window)
1127{
1128 TerminalWindowPrivate *priv = window->priv;
1129 CtkAction *action;
1130 gboolean can_search;
1131
1132 if (screen != priv->active_screen)
1133 return;
1134
1135 can_search = bte_terminal_search_get_regex (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
) != NULL((void*)0);
1136
1137 action = ctk_action_group_get_action (priv->action_group, "SearchFindNext");
1138 ctk_action_set_sensitive (action, can_search);
1139 action = ctk_action_group_get_action (priv->action_group, "SearchFindPrevious");
1140 ctk_action_set_sensitive (action, can_search);
1141 action = ctk_action_group_get_action (priv->action_group, "SearchClearHighlight");
1142 ctk_action_set_sensitive (action, can_search);
1143}
1144
1145static void
1146update_edit_menu_cb (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)),
1147 CdkAtom *targets,
1148 int n_targets,
1149 TerminalWindow *window)
1150{
1151 TerminalWindowPrivate *priv = window->priv;
1152 CtkAction *action;
1153 gboolean can_paste, can_paste_uris;
1154
1155 can_paste = targets != NULL((void*)0) && ctk_targets_include_text (targets, n_targets);
1156 can_paste_uris = targets != NULL((void*)0) && ctk_targets_include_uri (targets, n_targets);
1157
1158 action = ctk_action_group_get_action (priv->action_group, "EditPaste");
1159 ctk_action_set_sensitive (action, can_paste);
1160 action = ctk_action_group_get_action (priv->action_group, "EditPasteURIPaths");
1161 ctk_action_set_visible (action, can_paste_uris);
1162 ctk_action_set_sensitive (action, can_paste_uris);
1163
1164 /* Ref was added in ctk_clipboard_request_targets below */
1165 g_object_unref (window);
1166}
1167
1168static void
1169update_edit_menu(TerminalWindow *window)
1170{
1171 CtkClipboard *clipboard;
1172
1173 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
1174 ctk_clipboard_request_targets (clipboard,
1175 (CtkClipboardTargetsReceivedFunc) update_edit_menu_cb,
1176 g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window)));
1177}
1178
1179static void
1180screen_resize_window_cb (TerminalScreen *screen,
1181 guint width,
1182 guint height,
1183 TerminalWindow* window)
1184{
1185 TerminalWindowPrivate *priv = window->priv;
1186 BteTerminal *terminal = BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
;
1187 CtkWidget *widget = CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
;
1188
1189 /* Don't do anything if we're maximised or fullscreened */
1190 // FIXME: realized && ... instead?
1191 if (!ctk_widget_get_realized (widget) ||
1192 (cdk_window_get_state (ctk_widget_get_window (widget)) & (CDK_WINDOW_STATE_MAXIMIZED | CDK_WINDOW_STATE_FULLSCREEN)) != 0)
1193 return;
1194
1195 bte_terminal_set_size (terminal, width, height);
1196
1197 if (screen != priv->active_screen)
1198 return;
1199
1200 terminal_window_update_size (window, screen, TRUE(!(0)));
1201}
1202
1203static void
1204terminal_window_update_tabs_menu_sensitivity (TerminalWindow *window)
1205{
1206 TerminalWindowPrivate *priv = window->priv;
1207 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
1208 CtkActionGroup *action_group = priv->action_group;
1209 CtkAction *action;
1210 int num_pages, page_num;
1211 gboolean not_first, not_last;
1212
1213 if (priv->disposed)
1214 return;
1215
1216 num_pages = ctk_notebook_get_n_pages (notebook);
1217 page_num = ctk_notebook_get_current_page (notebook);
1218 not_first = page_num > 0;
1219 not_last = page_num + 1 < num_pages;
1220
1221 /* Hide the tabs menu in single-tab windows */
1222 action = ctk_action_group_get_action (action_group, "Tabs");
1223 ctk_action_set_visible (action, num_pages > 1);
1224
1225#if 1
1226 /* NOTE: We always make next/prev actions sensitive except in
1227 * single-tab windows, so the corresponding shortcut key escape code
1228 * isn't sent to the terminal. See bug #453193 and bug #138609.
1229 * This also makes tab cycling work, bug #92139.
1230 * FIXME: Find a better way to do this.
1231 */
1232 action = ctk_action_group_get_action (action_group, "TabsPrevious");
1233 ctk_action_set_sensitive (action, num_pages > 1);
1234 action = ctk_action_group_get_action (action_group, "TabsNext");
1235 ctk_action_set_sensitive (action, num_pages > 1);
1236#else
1237 /* This would be correct, but see the comment above. */
1238 action = ctk_action_group_get_action (action_group, "TabsPrevious");
1239 ctk_action_set_sensitive (action, not_first);
1240 action = ctk_action_group_get_action (action_group, "TabsNext");
1241 ctk_action_set_sensitive (action, not_last);
1242#endif
1243
1244 action = ctk_action_group_get_action (action_group, "TabsMoveLeft");
1245 ctk_action_set_sensitive (action, not_first);
1246 action = ctk_action_group_get_action (action_group, "TabsMoveRight");
1247 ctk_action_set_sensitive (action, not_last);
1248 action = ctk_action_group_get_action (action_group, "TabsDetach");
1249 ctk_action_set_sensitive (action, num_pages > 1);
1250 action = ctk_action_group_get_action (action_group, "FileCloseTab");
1251 ctk_action_set_sensitive (action, num_pages > 1);
1252}
1253
1254static void
1255update_tab_visibility (TerminalWindow *window,
1256 int change)
1257{
1258 TerminalWindowPrivate *priv = window->priv;
1259 gboolean show_tabs;
1260 guint num;
1261
1262 num = ctk_notebook_get_n_pages (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
);
1263
1264 show_tabs = (num + change) > 1;
1265 ctk_notebook_set_show_tabs (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, show_tabs);
1266}
1267
1268static CtkNotebook *
1269handle_tab_droped_on_desktop (CtkNotebook *source_notebook,
1270 CtkWidget *container G_GNUC_UNUSED__attribute__ ((__unused__)),
1271 gint x G_GNUC_UNUSED__attribute__ ((__unused__)),
1272 gint y G_GNUC_UNUSED__attribute__ ((__unused__)),
1273 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
1274{
1275 TerminalWindow *source_window;
1276 TerminalWindow *new_window;
1277 TerminalWindowPrivate *new_priv;
1278
1279 source_window = TERMINAL_WINDOW (ctk_widget_get_toplevel (CTK_WIDGET (source_notebook)))((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_toplevel (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((source_notebook)), ((ctk_widget_get_type
()))))))))), ((terminal_window_get_type ()))))))
;
1280 g_return_val_if_fail (TERMINAL_IS_WINDOW (source_window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((source_window)); GType __t = ((terminal_window_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "TERMINAL_IS_WINDOW (source_window)"
); return (((void*)0)); } } while (0)
;
1281
1282 new_window = terminal_app_new_window (terminal_app_get (),
1283 ctk_widget_get_screen (CTK_WIDGET (source_window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_window)), ((ctk_widget_get_type ()))))))
));
1284 new_priv = new_window->priv;
1285 new_priv->present_on_insert = TRUE(!(0));
1286
1287 update_tab_visibility (source_window, -1);
1288 update_tab_visibility (new_window, +1);
1289
1290 return CTK_NOTEBOOK (new_priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_priv->notebook)), ((ctk_notebook_get_type ())))))
)
;
1291}
1292
1293/* Terminal screen popup menu handling */
1294
1295static void
1296popup_open_url_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
1297 TerminalWindow *window)
1298{
1299 TerminalWindowPrivate *priv = window->priv;
1300 TerminalScreenPopupInfo *info = priv->popup_info;
1301
1302 if (info == NULL((void*)0))
1303 return;
1304
1305 terminal_util_open_url (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, info->string, info->flavour,
1306 ctk_get_current_event_time ());
1307}
1308
1309static void
1310popup_copy_url_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
1311 TerminalWindow *window)
1312{
1313 TerminalWindowPrivate *priv = window->priv;
1314 TerminalScreenPopupInfo *info = priv->popup_info;
1315 CtkClipboard *clipboard;
1316
1317 if (info == NULL((void*)0))
1318 return;
1319
1320 if (info->string == NULL((void*)0))
1321 return;
1322
1323 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
1324 ctk_clipboard_set_text (clipboard, info->string, -1);
1325}
1326
1327static void
1328popup_leave_fullscreen_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
1329 TerminalWindow *window)
1330{
1331 ctk_window_unfullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1332}
1333
1334static void
1335remove_popup_info (TerminalWindow *window)
1336{
1337 TerminalWindowPrivate *priv = window->priv;
1338
1339 if (priv->remove_popup_info_idle != 0)
1340 {
1341 g_source_remove (priv->remove_popup_info_idle);
1342 priv->remove_popup_info_idle = 0;
1343 }
1344
1345 if (priv->popup_info != NULL((void*)0))
1346 {
1347 terminal_screen_popup_info_unref (priv->popup_info);
1348 priv->popup_info = NULL((void*)0);
1349 }
1350}
1351
1352static gboolean
1353idle_remove_popup_info (TerminalWindow *window)
1354{
1355 TerminalWindowPrivate *priv = window->priv;
1356
1357 priv->remove_popup_info_idle = 0;
1358 remove_popup_info (window);
1359 return FALSE(0);
1360}
1361
1362static void
1363unset_popup_info (TerminalWindow *window)
1364{
1365 TerminalWindowPrivate *priv = window->priv;
1366
1367 /* Unref the event from idle since we still need it
1368 * from the action callbacks which will run before idle.
1369 */
1370 if (priv->remove_popup_info_idle == 0 &&
1371 priv->popup_info != NULL((void*)0))
1372 {
1373 priv->remove_popup_info_idle =
1374 g_idle_add ((GSourceFunc) idle_remove_popup_info, window);
1375 }
1376}
1377
1378static void
1379popup_menu_deactivate_callback (CtkWidget *popup,
1380 TerminalWindow *window)
1381{
1382 TerminalWindowPrivate *priv = window->priv;
1383 CtkWidget *im_menu_item;
1384
1385 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((popup), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (popup_menu_deactivate_callback))), (window
))
1386 (popup, G_CALLBACK (popup_menu_deactivate_callback), window)g_signal_handlers_disconnect_matched ((popup), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (popup_menu_deactivate_callback))), (window
))
;
1387
1388 im_menu_item = ctk_ui_manager_get_widget (priv->ui_manager,
1389 "/Popup/PopupInputMethods");
1390 ctk_menu_item_set_submenu (CTK_MENU_ITEM (im_menu_item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((im_menu_item)), ((ctk_menu_item_get_type ()))))))
, NULL((void*)0));
1391
1392 unset_popup_info (window);
1393}
1394
1395static void
1396popup_clipboard_targets_received_cb (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)),
1397 CdkAtom *targets,
1398 int n_targets,
1399 TerminalScreenPopupInfo *info)
1400{
1401 TerminalWindow *window = info->window;
1402 TerminalWindowPrivate *priv = window->priv;
1403 TerminalScreen *screen = info->screen;
1404 CtkWidget *popup_menu;
1405 CtkAction *action;
1406 gboolean can_paste, can_paste_uris, show_link, show_email_link, show_call_link, show_input_method_menu;
1407 int n_pages;
1408 CdkEvent *event;
1409 CdkSeat *seat;
1410 CdkDevice *device;
1411
1412 if (!ctk_widget_get_realized (CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
))
1413 {
1414 terminal_screen_popup_info_unref (info);
1415 return;
1416 }
1417
1418 /* Now we know that the screen is realized, we know that the window is still alive */
1419 remove_popup_info (window);
1420
1421 priv->popup_info = info; /* adopt the ref added when requesting the clipboard */
1422
1423 n_pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
);
1424
1425 can_paste = targets != NULL((void*)0) && ctk_targets_include_text (targets, n_targets);
1426 can_paste_uris = targets != NULL((void*)0) && ctk_targets_include_uri (targets, n_targets);
1427 show_link = info->string != NULL((void*)0) && (info->flavour == FLAVOR_AS_IS || info->flavour == FLAVOR_DEFAULT_TO_HTTP);
1428 show_email_link = info->string != NULL((void*)0) && info->flavour == FLAVOR_EMAIL;
1429 show_call_link = info->string != NULL((void*)0) && info->flavour == FLAVOR_VOIP_CALL;
1430
1431 action = ctk_action_group_get_action (priv->action_group, "PopupSendEmail");
1432 ctk_action_set_visible (action, show_email_link);
1433 action = ctk_action_group_get_action (priv->action_group, "PopupCopyEmailAddress");
1434 ctk_action_set_visible (action, show_email_link);
1435 action = ctk_action_group_get_action (priv->action_group, "PopupCall");
1436 ctk_action_set_visible (action, show_call_link);
1437 action = ctk_action_group_get_action (priv->action_group, "PopupCopyCallAddress");
1438 ctk_action_set_visible (action, show_call_link);
1439 action = ctk_action_group_get_action (priv->action_group, "PopupOpenLink");
1440 ctk_action_set_visible (action, show_link);
1441 action = ctk_action_group_get_action (priv->action_group, "PopupCopyLinkAddress");
1442 ctk_action_set_visible (action, show_link);
1443
1444 action = ctk_action_group_get_action (priv->action_group, "PopupCloseWindow");
1445 ctk_action_set_visible (action, n_pages <= 1);
1446 action = ctk_action_group_get_action (priv->action_group, "PopupCloseTab");
1447 ctk_action_set_visible (action, n_pages > 1);
1448
1449 action = ctk_action_group_get_action (priv->action_group, "PopupCopy");
1450 ctk_action_set_sensitive (action, bte_terminal_get_has_selection (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
));
1451 action = ctk_action_group_get_action (priv->action_group, "PopupPaste");
1452 ctk_action_set_sensitive (action, can_paste);
1453 action = ctk_action_group_get_action (priv->action_group, "PopupPasteURIPaths");
1454 ctk_action_set_visible (action, can_paste_uris);
1455
1456 g_object_get (ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
),
1457 "ctk-show-input-method-menu", &show_input_method_menu,
1458 NULL((void*)0));
1459
1460 action = ctk_action_group_get_action (priv->action_group, "PopupInputMethods");
1461 ctk_action_set_visible (action, show_input_method_menu);
1462
1463 popup_menu = ctk_ui_manager_get_widget (priv->ui_manager, "/Popup");
1464 g_signal_connect (popup_menu, "deactivate",g_signal_connect_data ((popup_menu), ("deactivate"), (((GCallback
) (popup_menu_deactivate_callback))), (window), ((void*)0), (
GConnectFlags) 0)
1465 G_CALLBACK (popup_menu_deactivate_callback), window)g_signal_connect_data ((popup_menu), ("deactivate"), (((GCallback
) (popup_menu_deactivate_callback))), (window), ((void*)0), (
GConnectFlags) 0)
;
1466
1467 /* Pseudo activation of the popup menu's action */
1468 action = ctk_action_group_get_action (priv->action_group, "Popup");
1469 ctk_action_activate (action);
1470
1471 if (info->button == 0)
1472 ctk_menu_shell_select_first (CTK_MENU_SHELL (popup_menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup_menu)), ((ctk_menu_shell_get_type ()))))))
, FALSE(0));
1473
1474 if (!ctk_menu_get_attach_widget (CTK_MENU (popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup_menu)), ((ctk_menu_get_type ()))))))
))
1475 ctk_menu_attach_to_widget (CTK_MENU (popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup_menu)), ((ctk_menu_get_type ()))))))
,CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
,NULL((void*)0));
1476
1477 event = ctk_get_current_event ();
1478
1479 seat = cdk_display_get_default_seat (cdk_display_get_default());
1480
1481 device = cdk_seat_get_pointer (seat);
1482
1483 cdk_event_set_device (event, device);
1484
1485 ctk_menu_popup_at_pointer (CTK_MENU (popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup_menu)), ((ctk_menu_get_type ()))))))
, (const CdkEvent*) event);
1486
1487 cdk_event_free (event);
1488}
1489
1490static void
1491screen_show_popup_menu_callback (TerminalScreen *screen G_GNUC_UNUSED__attribute__ ((__unused__)),
1492 TerminalScreenPopupInfo *info,
1493 TerminalWindow *window)
1494{
1495 CtkClipboard *clipboard;
1496
1497 g_return_if_fail (info->window == window)do { if ((info->window == window)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "info->window == window"
); return; } } while (0)
;
1498
1499 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
1500 ctk_clipboard_request_targets (clipboard,
1501 (CtkClipboardTargetsReceivedFunc) popup_clipboard_targets_received_cb,
1502 terminal_screen_popup_info_ref (info));
1503}
1504
1505static gboolean
1506screen_match_clicked_cb (TerminalScreen *screen,
1507 const char *match,
1508 int flavour,
1509 guint state G_GNUC_UNUSED__attribute__ ((__unused__)),
1510 TerminalWindow *window)
1511{
1512 TerminalWindowPrivate *priv = window->priv;
1513
1514 if (screen != priv->active_screen)
1515 return FALSE(0);
1516
1517 switch (flavour)
1518 {
1519#ifdef ENABLE_SKEY1
1520 case FLAVOR_SKEY:
1521 terminal_skey_do_popup (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, screen, match);
1522 break;
1523#endif
1524 default:
1525 ctk_widget_grab_focus (CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
);
1526 terminal_util_open_url (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, match, flavour,
1527 ctk_get_current_event_time ());
1528 break;
1529 }
1530
1531 return TRUE(!(0));
1532}
1533
1534static void
1535screen_close_cb (TerminalScreen *screen,
1536 TerminalWindow *window)
1537{
1538 terminal_window_remove_screen (window, screen);
1539}
1540
1541static gboolean
1542terminal_window_accel_activate_cb (CtkAccelGroup *accel_group,
1543 GObject *acceleratable G_GNUC_UNUSED__attribute__ ((__unused__)),
1544 guint keyval,
1545 CdkModifierType modifier,
1546 TerminalWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)))
1547{
1548 CtkAccelGroupEntry *entries;
1549 guint n_entries;
1550 gboolean retval = FALSE(0);
1551
1552 entries = ctk_accel_group_query (accel_group, keyval, modifier, &n_entries);
1553 if (n_entries > 0)
1554 {
1555 const char *accel_path;
1556
1557 accel_path = g_quark_to_string (entries[0].accel_path_quark);
1558
1559 if (g_str_has_prefix (accel_path, "<Actions>/Main/")(__builtin_constant_p ("<Actions>/Main/")? __extension__
({ const char * const __str = (accel_path); const char * const
__prefix = ("<Actions>/Main/"); gboolean __result = (0
); if (__str == ((void*)0) || __prefix == ((void*)0)) __result
= (g_str_has_prefix) (__str, __prefix); else { const size_t __str_len
= strlen (((__str) + !(__str))); const size_t __prefix_len =
strlen (((__prefix) + !(__prefix))); if (__str_len >= __prefix_len
) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix
)), __prefix_len) == 0; } __result; }) : (g_str_has_prefix) (
accel_path, "<Actions>/Main/") )
)
1560 {
1561 const char *action_name;
1562
1563 /* We want to always consume these accelerators, even if the corresponding
1564 * action is insensitive, so the corresponding shortcut key escape code
1565 * isn't sent to the terminal. See bug #453193, bug #138609 and bug #559728.
1566 * This also makes tab cycling work, bug #92139. (NOT!)
1567 */
1568
1569 action_name = I_(accel_path + strlen ("<Actions>/Main/"))g_intern_static_string (accel_path + strlen ("<Actions>/Main/"
))
;
1570
1571#if 0
1572 if (ctk_notebook_get_n_pages (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
) > 1 &&
1573 (action_name == I_("TabsPrevious")g_intern_static_string ("TabsPrevious") || action_name == I_("TabsNext")g_intern_static_string ("TabsNext")))
1574 retval = TRUE(!(0));
1575 else
1576#endif
1577 if (action_name == I_("EditCopy")g_intern_static_string ("EditCopy") ||
1578 action_name == I_("PopupCopy")g_intern_static_string ("PopupCopy") ||
1579 action_name == I_("EditPaste")g_intern_static_string ("EditPaste") ||
1580 action_name == I_("PopupPaste")g_intern_static_string ("PopupPaste"))
1581 retval = TRUE(!(0));
1582 }
1583 }
1584
1585 return retval;
1586}
1587
1588/*****************************************/
1589
1590#ifdef CAFE_ENABLE_DEBUG
1591static void
1592terminal_window_size_allocate_cb (CtkWidget *widget,
1593 CtkAllocation *allocation)
1594{
1595 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] size-alloc result %d : %d at (%d, %d)\n"
, widget, allocation->width, allocation->height, allocation
->x, allocation->y); } while (0)
1596 "[window %p] size-alloc result %d : %d at (%d, %d)\n",do { if (0) g_printerr("[window %p] size-alloc result %d : %d at (%d, %d)\n"
, widget, allocation->width, allocation->height, allocation
->x, allocation->y); } while (0)
1597 widget,do { if (0) g_printerr("[window %p] size-alloc result %d : %d at (%d, %d)\n"
, widget, allocation->width, allocation->height, allocation
->x, allocation->y); } while (0)
1598 allocation->width, allocation->height,do { if (0) g_printerr("[window %p] size-alloc result %d : %d at (%d, %d)\n"
, widget, allocation->width, allocation->height, allocation
->x, allocation->y); } while (0)
1599 allocation->x, allocation->y)do { if (0) g_printerr("[window %p] size-alloc result %d : %d at (%d, %d)\n"
, widget, allocation->width, allocation->height, allocation
->x, allocation->y); } while (0)
;
1600}
1601#endif /* CAFE_ENABLE_DEBUG */
1602
1603static void
1604terminal_window_realize (CtkWidget *widget)
1605{
1606 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
1607 TerminalWindowPrivate *priv = window->priv;
1608#if defined(CDK_WINDOWING_X11) || defined(CDK_WINDOWING_WAYLAND)
1609 CdkScreen *screen;
1610 CtkAllocation widget_allocation;
1611 CdkVisual *visual;
1612
1613 ctk_widget_get_allocation (widget, &widget_allocation);
1614 screen = ctk_widget_get_screen (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1615
1616 if (cdk_screen_is_composited (screen) &&
1617 (visual = cdk_screen_get_rgba_visual (screen)) != NULL((void*)0))
1618 {
1619 /* Set RGBA visual if possible so BTE can use real transparency */
1620 ctk_widget_set_visual (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_widget_get_type ()))))))
, visual);
1621 priv->have_argb_visual = TRUE(!(0));
1622 }
1623 else
1624 {
1625 ctk_widget_set_visual (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, cdk_screen_get_system_visual (screen));
1626 priv->have_argb_visual = FALSE(0);
1627 }
1628#endif
1629
1630 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] realize, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1631 "[window %p] realize, size %d : %d at (%d, %d)\n",do { if (0) g_printerr("[window %p] realize, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1632 widget,do { if (0) g_printerr("[window %p] realize, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1633 widget_allocation.width, widget_allocation.height,do { if (0) g_printerr("[window %p] realize, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1634 widget_allocation.x, widget_allocation.y)do { if (0) g_printerr("[window %p] realize, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
;
1635
1636 CTK_WIDGET_CLASS (terminal_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), ((ctk_widget_get_type ()
))))))
->realize (widget);
1637
1638 /* Need to do this now since this requires the window to be realized */
1639 if (priv->active_screen != NULL((void*)0))
1640 sync_screen_icon_title (priv->active_screen, NULL((void*)0), window);
1641}
1642
1643static gboolean
1644terminal_window_map_event (CtkWidget *widget,
1645 CdkEventAny *event)
1646{
1647 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
1648 TerminalWindowPrivate *priv = window->priv;
1649 gboolean (* map_event) (CtkWidget *, CdkEventAny *) =
1650 CTK_WIDGET_CLASS (terminal_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), ((ctk_widget_get_type ()
))))))
->map_event;
1651 CtkAllocation widget_allocation;
1652
1653 ctk_widget_get_allocation (widget, &widget_allocation);
1654 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] map-event, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1655 "[window %p] map-event, size %d : %d at (%d, %d)\n",do { if (0) g_printerr("[window %p] map-event, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1656 widget,do { if (0) g_printerr("[window %p] map-event, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1657 widget_allocation.width, widget_allocation.height,do { if (0) g_printerr("[window %p] map-event, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
1658 widget_allocation.x, widget_allocation.y)do { if (0) g_printerr("[window %p] map-event, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
;
1659
1660 if (priv->clear_demands_attention)
1661 {
1662#ifdef CDK_WINDOWING_X11
1663 terminal_util_x11_clear_demands_attention (ctk_widget_get_window (widget));
1664#endif
1665
1666 priv->clear_demands_attention = FALSE(0);
1667 }
1668
1669 if (map_event)
1670 return map_event (widget, event);
1671
1672 return FALSE(0);
1673}
1674
1675
1676static gboolean
1677terminal_window_state_event (CtkWidget *widget,
1678 CdkEventWindowState *event)
1679{
1680 gboolean (* window_state_event) (CtkWidget *, CdkEventWindowState *event) =
1681 CTK_WIDGET_CLASS (terminal_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), ((ctk_widget_get_type ()
))))))
->window_state_event;
1682
1683 if (event->changed_mask & CDK_WINDOW_STATE_FULLSCREEN)
1684 {
1685 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
1686 TerminalWindowPrivate *priv = window->priv;
1687 CtkAction *action;
1688 gboolean is_fullscreen;
1689
1690 is_fullscreen = (event->new_window_state & CDK_WINDOW_STATE_FULLSCREEN) != 0;
1691
1692 action = ctk_action_group_get_action (priv->action_group, "ViewFullscreen");
1693 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
, is_fullscreen);
1694
1695 action = ctk_action_group_get_action (priv->action_group, "PopupLeaveFullscreen");
1696 ctk_action_set_visible (action, is_fullscreen);
1697 }
1698
1699 if (window_state_event)
1700 return window_state_event (widget, event);
1701
1702 return FALSE(0);
1703}
1704
1705#ifdef CDK_WINDOWING_X11
1706static void
1707terminal_window_window_manager_changed_cb (CdkScreen *screen,
1708 TerminalWindow *window)
1709{
1710 TerminalWindowPrivate *priv = window->priv;
1711 CtkAction *action;
1712 gboolean supports_fs;
1713
1714 supports_fs = cdk_x11_screen_supports_net_wm_hint (screen, cdk_atom_intern ("_NET_WM_STATE_FULLSCREEN", FALSE(0)));
1715
1716 action = ctk_action_group_get_action (priv->action_group, "ViewFullscreen");
1717 ctk_action_set_sensitive (action, supports_fs);
1718}
1719#endif
1720
1721static void
1722terminal_window_screen_update (TerminalWindow *window,
1723 CdkScreen *screen)
1724{
1725 TerminalApp *app;
1726
1727#ifdef CDK_WINDOWING_X11
1728 if (screen && CDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((cdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1729 {
1730 terminal_window_window_manager_changed_cb (screen, window);
1731 g_signal_connect (screen, "window-manager-changed",g_signal_connect_data ((screen), ("window-manager-changed"), (
((GCallback) (terminal_window_window_manager_changed_cb))), (
window), ((void*)0), (GConnectFlags) 0)
1732 G_CALLBACK (terminal_window_window_manager_changed_cb), window)g_signal_connect_data ((screen), ("window-manager-changed"), (
((GCallback) (terminal_window_window_manager_changed_cb))), (
window), ((void*)0), (GConnectFlags) 0)
;
1733 }
1734#endif
1735
1736 if ((gint) (glong) (void *) (g_object_get_data (G_OBJECT (screen)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), (((GType) ((20) << (2))))))))
, "GT::HasSettingsConnection")))
1737 return;
1738
1739 g_object_set_data_full (G_OBJECT (screen)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), (((GType) ((20) << (2))))))))
, "GT::HasSettingsConnection",
1740 GINT_TO_POINTER (TRUE)((gpointer) (glong) ((!(0)))),
1741 (GDestroyNotify) app_setting_notify_destroy_cb);
1742
1743 app = terminal_app_get ();
1744 app_setting_notify_cb (app, NULL((void*)0), screen);
1745 g_signal_connect (app, "notify::" TERMINAL_APP_ENABLE_MNEMONICS,g_signal_connect_data ((app), ("notify::" "enable-mnemonics")
, (((GCallback) (app_setting_notify_cb))), (screen), ((void*)
0), (GConnectFlags) 0)
1746 G_CALLBACK (app_setting_notify_cb), screen)g_signal_connect_data ((app), ("notify::" "enable-mnemonics")
, (((GCallback) (app_setting_notify_cb))), (screen), ((void*)
0), (GConnectFlags) 0)
;
1747 g_signal_connect (app, "notify::" TERMINAL_APP_ENABLE_MENU_BAR_ACCEL,g_signal_connect_data ((app), ("notify::" "enable-menu-accels"
), (((GCallback) (app_setting_notify_cb))), (screen), ((void*
)0), (GConnectFlags) 0)
1748 G_CALLBACK (app_setting_notify_cb), screen)g_signal_connect_data ((app), ("notify::" "enable-menu-accels"
), (((GCallback) (app_setting_notify_cb))), (screen), ((void*
)0), (GConnectFlags) 0)
;
1749}
1750
1751static void
1752terminal_window_screen_changed (CtkWidget *widget,
1753 CdkScreen *previous_screen)
1754{
1755 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
1756 void (* screen_changed) (CtkWidget *, CdkScreen *) =
1757 CTK_WIDGET_CLASS (terminal_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), ((ctk_widget_get_type ()
))))))
->screen_changed;
1758 CdkScreen *screen;
1759
1760 if (screen_changed)
1761 screen_changed (widget, previous_screen);
1762
1763 screen = ctk_widget_get_screen (widget);
1764 if (previous_screen == screen)
1765 return;
1766
1767#ifdef CDK_WINDOWING_X11
1768 if (previous_screen && CDK_IS_X11_SCREEN (previous_screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(previous_screen)); GType __t = ((cdk_x11_screen_get_type ())
); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1769 {
1770 g_signal_handlers_disconnect_by_func (previous_screen,g_signal_handlers_disconnect_matched ((previous_screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
1771 G_CALLBACK (terminal_window_window_manager_changed_cb),g_signal_handlers_disconnect_matched ((previous_screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
1772 window)g_signal_handlers_disconnect_matched ((previous_screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
;
1773 }
1774#endif
1775
1776 if (!screen)
1777 return;
1778
1779 terminal_window_screen_update (window, screen);
1780}
1781
1782static void
1783terminal_window_profile_list_changed_cb (TerminalApp *app G_GNUC_UNUSED__attribute__ ((__unused__)),
1784 TerminalWindow *window)
1785{
1786 terminal_window_update_set_profile_menu (window);
1787 terminal_window_update_new_terminal_menus (window);
1788}
1789
1790static void
1791terminal_window_encoding_list_changed_cb (TerminalApp *app G_GNUC_UNUSED__attribute__ ((__unused__)),
1792 TerminalWindow *window)
1793{
1794 terminal_window_update_encoding_menu (window);
1795}
1796
1797static void
1798terminal_window_init (TerminalWindow *window)
1799{
1800 const CtkActionEntry menu_entries[] =
1801 {
1802 /* Toplevel */
1803 { "File", NULL((void*)0), N_("_File")("_File"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1804 { "FileNewWindowProfiles", "utilities-terminal", N_("Open _Terminal")("Open _Terminal"), NULL((void*)0), NULL((void*)0), NULL((void*)0)},
1805 { "FileNewTabProfiles", STOCK_NEW_TAB"tab-new", N_("Open Ta_b")("Open Ta_b"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1806 { "Edit", NULL((void*)0), N_("_Edit")("_Edit"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1807 { "View", NULL((void*)0), N_("_View")("_View"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1808 { "Search", NULL((void*)0), N_("_Search")("_Search"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1809 { "Terminal", NULL((void*)0), N_("_Terminal")("_Terminal"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1810 { "Tabs", NULL((void*)0), N_("Ta_bs")("Ta_bs"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1811 { "Help", NULL((void*)0), N_("_Help")("_Help"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1812 { "Popup", NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1813 { "NotebookPopup", NULL((void*)0), "", NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1814
1815 /* File menu */
1816 {
1817 "FileNewWindow", "utilities-terminal", N_("Open _Terminal")("Open _Terminal"), "<shift><control>N",
1818 NULL((void*)0),
1819 G_CALLBACK (file_new_window_callback)((GCallback) (file_new_window_callback))
1820 },
1821 {
1822 "FileNewTab", STOCK_NEW_TAB"tab-new", N_("Open Ta_b")("Open Ta_b"), "<shift><control>T",
1823 NULL((void*)0),
1824 G_CALLBACK (file_new_tab_callback)((GCallback) (file_new_tab_callback))
1825 },
1826 {
1827 "FileNewProfile", "document-open", N_("New _Profile…")("New _Profile…"), "",
1828 NULL((void*)0),
1829 G_CALLBACK (file_new_profile_callback)((GCallback) (file_new_profile_callback))
1830 },
1831 {
1832 "FileSaveContents", "document-save", N_("_Save Contents")("_Save Contents"), "",
1833 NULL((void*)0),
1834 G_CALLBACK (file_save_contents_callback)((GCallback) (file_save_contents_callback))
1835 },
1836 {
1837 "FileCloseTab", "window-close", N_("C_lose Tab")("C_lose Tab"), "<shift><control>W",
1838 NULL((void*)0),
1839 G_CALLBACK (file_close_tab_callback)((GCallback) (file_close_tab_callback))
1840 },
1841 {
1842 "FileCloseWindow", "window-close", N_("_Close Window")("_Close Window"), "<shift><control>Q",
1843 NULL((void*)0),
1844 G_CALLBACK (file_close_window_callback)((GCallback) (file_close_window_callback))
1845 },
1846
1847 /* Edit menu */
1848 {
1849 "EditCopy", "edit-copy", N_("_Copy")("_Copy"), "<shift><control>C",
1850 NULL((void*)0),
1851 G_CALLBACK (edit_copy_callback)((GCallback) (edit_copy_callback))
1852 },
1853 {
1854 "EditPaste", "edit-paste", N_("_Paste")("_Paste"), "<shift><control>V",
1855 NULL((void*)0),
1856 G_CALLBACK (edit_paste_callback)((GCallback) (edit_paste_callback))
1857 },
1858 {
1859 "EditPasteURIPaths", "edit-paste", N_("Paste _Filenames")("Paste _Filenames"), "",
1860 NULL((void*)0),
1861 G_CALLBACK (edit_paste_callback)((GCallback) (edit_paste_callback))
1862 },
1863 {
1864 "EditSelectAll", "edit-select-all", N_("Select _All")("Select _All"), "<shift><control>A",
1865 NULL((void*)0),
1866 G_CALLBACK (edit_select_all_callback)((GCallback) (edit_select_all_callback))
1867 },
1868 {
1869 "EditProfiles", NULL((void*)0), N_("P_rofiles…")("P_rofiles…"), NULL((void*)0),
1870 NULL((void*)0),
1871 G_CALLBACK (edit_profiles_callback)((GCallback) (edit_profiles_callback))
1872 },
1873 {
1874 "EditKeybindings", NULL((void*)0), N_("_Keyboard Shortcuts…")("_Keyboard Shortcuts…"), NULL((void*)0),
1875 NULL((void*)0),
1876 G_CALLBACK (edit_keybindings_callback)((GCallback) (edit_keybindings_callback))
1877 },
1878 {
1879 "EditCurrentProfile", NULL((void*)0), N_("Pr_ofile Preferences")("Pr_ofile Preferences"), NULL((void*)0),
1880 NULL((void*)0),
1881 G_CALLBACK (edit_current_profile_callback)((GCallback) (edit_current_profile_callback))
1882 },
1883
1884 /* View menu */
1885 {
1886 "ViewZoomIn", "zoom-in", N_("Zoom _In")("Zoom _In"), "<control>plus",
1887 NULL((void*)0),
1888 G_CALLBACK (view_zoom_in_callback)((GCallback) (view_zoom_in_callback))
1889 },
1890 {
1891 "ViewZoomOut", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>minus",
1892 NULL((void*)0),
1893 G_CALLBACK (view_zoom_out_callback)((GCallback) (view_zoom_out_callback))
1894 },
1895 {
1896 "ViewZoom100", "zoom-original", N_("_Normal Size")("_Normal Size"), "<control>0",
1897 NULL((void*)0),
1898 G_CALLBACK (view_zoom_normal_callback)((GCallback) (view_zoom_normal_callback))
1899 },
1900
1901 /* Search menu */
1902 {
1903 "SearchFind", "edit-find", N_("_Find...")("_Find..."), "<shift><control>F",
1904 NULL((void*)0),
1905 G_CALLBACK (search_find_callback)((GCallback) (search_find_callback))
1906 },
1907 {
1908 "SearchFindNext", NULL((void*)0), N_("Find Ne_xt")("Find Ne_xt"), "<shift><control>H",
1909 NULL((void*)0),
1910 G_CALLBACK (search_find_next_callback)((GCallback) (search_find_next_callback))
1911 },
1912 {
1913 "SearchFindPrevious", NULL((void*)0), N_("Find Pre_vious")("Find Pre_vious"), "<shift><control>G",
1914 NULL((void*)0),
1915 G_CALLBACK (search_find_prev_callback)((GCallback) (search_find_prev_callback))
1916 },
1917 {
1918 "SearchClearHighlight", NULL((void*)0), N_("_Clear Highlight")("_Clear Highlight"), "<shift><control>J",
1919 NULL((void*)0),
1920 G_CALLBACK (search_clear_highlight_callback)((GCallback) (search_clear_highlight_callback))
1921 },
1922#if 0
1923 {
1924 "SearchGoToLine", "go-jump", N_("Go to _Line...")("Go to _Line..."), "<shift><control>I",
1925 NULL((void*)0),
1926 G_CALLBACK (search_goto_line_callback)((GCallback) (search_goto_line_callback))
1927 },
1928 {
1929 "SearchIncrementalSearch", "edit-find", N_("_Incremental Search...")("_Incremental Search..."), "<shift><control>K",
1930 NULL((void*)0),
1931 G_CALLBACK (search_incremental_search_callback)((GCallback) (search_incremental_search_callback))
1932 },
1933#endif
1934
1935 /* Terminal menu */
1936 { "TerminalProfiles", NULL((void*)0), N_("Change _Profile")("Change _Profile"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1937 {
1938 "ProfilePrevious", NULL((void*)0), N_("_Previous Profile")("_Previous Profile"), "<alt>Page_Up",
1939 NULL((void*)0),
1940 G_CALLBACK (terminal_next_or_previous_profile_cb)((GCallback) (terminal_next_or_previous_profile_cb))
1941 },
1942 {
1943 "ProfileNext", NULL((void*)0), N_("_Next Profile")("_Next Profile"), "<alt>Page_Down",
1944 NULL((void*)0),
1945 G_CALLBACK (terminal_next_or_previous_profile_cb)((GCallback) (terminal_next_or_previous_profile_cb))
1946 },
1947 {
1948 "TerminalSetTitle", NULL((void*)0), N_("_Set Title…")("_Set Title…"), NULL((void*)0),
1949 NULL((void*)0),
1950 G_CALLBACK (terminal_set_title_callback)((GCallback) (terminal_set_title_callback))
1951 },
1952 { "TerminalSetEncoding", NULL((void*)0), N_("Set _Character Encoding")("Set _Character Encoding"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
1953 {
1954 "TerminalReset", NULL((void*)0), N_("_Reset")("_Reset"), NULL((void*)0),
1955 NULL((void*)0),
1956 G_CALLBACK (terminal_reset_callback)((GCallback) (terminal_reset_callback))
1957 },
1958 {
1959 "TerminalResetClear", NULL((void*)0), N_("Reset and C_lear")("Reset and C_lear"), NULL((void*)0),
1960 NULL((void*)0),
1961 G_CALLBACK (terminal_reset_clear_callback)((GCallback) (terminal_reset_clear_callback))
1962 },
1963
1964 /* Terminal/Encodings menu */
1965 {
1966 "TerminalAddEncoding", NULL((void*)0), N_("_Add or Remove…")("_Add or Remove…"), NULL((void*)0),
1967 NULL((void*)0),
1968 G_CALLBACK (terminal_add_encoding_callback)((GCallback) (terminal_add_encoding_callback))
1969 },
1970
1971 /* Tabs menu */
1972 {
1973 "TabsPrevious", NULL((void*)0), N_("_Previous Tab")("_Previous Tab"), "<control>Page_Up",
1974 NULL((void*)0),
1975 G_CALLBACK (tabs_next_or_previous_tab_cb)((GCallback) (tabs_next_or_previous_tab_cb))
1976 },
1977 {
1978 "TabsNext", NULL((void*)0), N_("_Next Tab")("_Next Tab"), "<control>Page_Down",
1979 NULL((void*)0),
1980 G_CALLBACK (tabs_next_or_previous_tab_cb)((GCallback) (tabs_next_or_previous_tab_cb))
1981 },
1982 {
1983 "TabsMoveLeft", NULL((void*)0), N_("Move Tab _Left")("Move Tab _Left"), "<shift><control>Page_Up",
1984 NULL((void*)0),
1985 G_CALLBACK (tabs_move_left_callback)((GCallback) (tabs_move_left_callback))
1986 },
1987 {
1988 "TabsMoveRight", NULL((void*)0), N_("Move Tab _Right")("Move Tab _Right"), "<shift><control>Page_Down",
1989 NULL((void*)0),
1990 G_CALLBACK (tabs_move_right_callback)((GCallback) (tabs_move_right_callback))
1991 },
1992 {
1993 "TabsDetach", NULL((void*)0), N_("_Detach tab")("_Detach tab"), NULL((void*)0),
1994 NULL((void*)0),
1995 G_CALLBACK (tabs_detach_tab_callback)((GCallback) (tabs_detach_tab_callback))
1996 },
1997
1998 /* Help menu */
1999 {
2000 "HelpContents", "help-browser", N_("_Contents")("_Contents"), "F1",
2001 NULL((void*)0),
2002 G_CALLBACK (help_contents_callback)((GCallback) (help_contents_callback))
2003 },
2004 {
2005 "HelpAbout", "help-about", N_("_About")("_About"), NULL((void*)0),
2006 NULL((void*)0),
2007 G_CALLBACK (help_about_callback)((GCallback) (help_about_callback))
2008 },
2009
2010 /* Popup menu */
2011 {
2012 "PopupSendEmail", NULL((void*)0), N_("_Send Mail To…")("_Send Mail To…"), NULL((void*)0),
2013 NULL((void*)0),
2014 G_CALLBACK (popup_open_url_callback)((GCallback) (popup_open_url_callback))
2015 },
2016 {
2017 "PopupCopyEmailAddress", NULL((void*)0), N_("_Copy E-mail Address")("_Copy E-mail Address"), NULL((void*)0),
2018 NULL((void*)0),
2019 G_CALLBACK (popup_copy_url_callback)((GCallback) (popup_copy_url_callback))
2020 },
2021 {
2022 "PopupCall", NULL((void*)0), N_("C_all To…")("C_all To…"), NULL((void*)0),
2023 NULL((void*)0),
2024 G_CALLBACK (popup_open_url_callback)((GCallback) (popup_open_url_callback))
2025 },
2026 {
2027 "PopupCopyCallAddress", NULL((void*)0), N_("_Copy Call Address")("_Copy Call Address"), NULL((void*)0),
2028 NULL((void*)0),
2029 G_CALLBACK (popup_copy_url_callback)((GCallback) (popup_copy_url_callback))
2030 },
2031 {
2032 "PopupOpenLink", NULL((void*)0), N_("_Open Link")("_Open Link"), NULL((void*)0),
2033 NULL((void*)0),
2034 G_CALLBACK (popup_open_url_callback)((GCallback) (popup_open_url_callback))
2035 },
2036 {
2037 "PopupCopyLinkAddress", NULL((void*)0), N_("_Copy Link Address")("_Copy Link Address"), NULL((void*)0),
2038 NULL((void*)0),
2039 G_CALLBACK (popup_copy_url_callback)((GCallback) (popup_copy_url_callback))
2040 },
2041 { "PopupTerminalProfiles", NULL((void*)0), N_("P_rofiles")("P_rofiles"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
2042 {
2043 "PopupCopy", "edit-copy", N_("_Copy")("_Copy"), "",
2044 NULL((void*)0),
2045 G_CALLBACK (edit_copy_callback)((GCallback) (edit_copy_callback))
2046 },
2047 {
2048 "PopupPaste", "edit-paste", N_("_Paste")("_Paste"), "",
2049 NULL((void*)0),
2050 G_CALLBACK (edit_paste_callback)((GCallback) (edit_paste_callback))
2051 },
2052 {
2053 "PopupPasteURIPaths", "edit-paste", N_("Paste _Filenames")("Paste _Filenames"), "",
2054 NULL((void*)0),
2055 G_CALLBACK (edit_paste_callback)((GCallback) (edit_paste_callback))
2056 },
2057 {
2058 "PopupNewTerminal", "utilities-terminal", N_("Open _Terminal")("Open _Terminal"), NULL((void*)0),
2059 NULL((void*)0),
2060 G_CALLBACK (file_new_window_callback)((GCallback) (file_new_window_callback))
2061 },
2062 {
2063 "PopupNewTab", NULL((void*)0), N_("Open Ta_b")("Open Ta_b"), NULL((void*)0),
2064 NULL((void*)0),
2065 G_CALLBACK (file_new_tab_callback)((GCallback) (file_new_tab_callback))
2066 },
2067 {
2068 "PopupCloseWindow", NULL((void*)0), N_("C_lose Window")("C_lose Window"), NULL((void*)0),
2069 NULL((void*)0),
2070 G_CALLBACK (file_close_window_callback)((GCallback) (file_close_window_callback))
2071 },
2072 {
2073 "PopupCloseTab", NULL((void*)0), N_("C_lose Tab")("C_lose Tab"), NULL((void*)0),
2074 NULL((void*)0),
2075 G_CALLBACK (file_close_tab_callback)((GCallback) (file_close_tab_callback))
2076 },
2077 {
2078 "PopupLeaveFullscreen", NULL((void*)0), N_("L_eave Full Screen")("L_eave Full Screen"), NULL((void*)0),
2079 NULL((void*)0),
2080 G_CALLBACK (popup_leave_fullscreen_callback)((GCallback) (popup_leave_fullscreen_callback))
2081 },
2082 { "PopupInputMethods", NULL((void*)0), N_("_Input Methods")("_Input Methods"), NULL((void*)0), NULL((void*)0), NULL((void*)0) }
2083 };
2084
2085 const CtkToggleActionEntry toggle_menu_entries[] =
2086 {
2087 /* View Menu */
2088 {
2089 "ViewMenubar", NULL((void*)0), N_("Show _Menubar")("Show _Menubar"), NULL((void*)0),
2090 NULL((void*)0),
2091 G_CALLBACK (view_menubar_toggled_callback)((GCallback) (view_menubar_toggled_callback)),
2092 FALSE(0)
2093 },
2094 {
2095 "ViewFullscreen", NULL((void*)0), N_("_Full Screen")("_Full Screen"), NULL((void*)0),
2096 NULL((void*)0),
2097 G_CALLBACK (view_fullscreen_toggled_callback)((GCallback) (view_fullscreen_toggled_callback)),
2098 FALSE(0)
2099 }
2100 };
2101 TerminalWindowPrivate *priv;
2102 TerminalApp *app;
2103 CtkActionGroup *action_group;
2104 CtkAction *action;
2105 CtkUIManager *manager;
2106 GError *error;
2107 CtkWindowGroup *window_group;
2108 CtkAccelGroup *accel_group;
2109 CtkClipboard *clipboard;
2110
2111 priv = window->priv = terminal_window_get_instance_private (window);
2112
2113 g_signal_connect (G_OBJECT (window), "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (terminal_window_delete_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2114 G_CALLBACK(terminal_window_delete_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (terminal_window_delete_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2115 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (terminal_window_delete_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
2116 g_signal_connect (G_OBJECT (window), "focus_in_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("focus_in_event"), (((GCallback) (terminal_window_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2117 G_CALLBACK(terminal_window_focus_in_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("focus_in_event"), (((GCallback) (terminal_window_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2118 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("focus_in_event"), (((GCallback) (terminal_window_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
2119
2120#ifdef CAFE_ENABLE_DEBUG
2121 _TERMINAL_DEBUG_IF (TERMINAL_DEBUG_GEOMETRY)if (0)
2122 {
2123 g_signal_connect_after (window, "size-allocate", G_CALLBACK (terminal_window_size_allocate_cb), NULL)g_signal_connect_data ((window), ("size-allocate"), (((GCallback
) (terminal_window_size_allocate_cb))), (((void*)0)), ((void*
)0), G_CONNECT_AFTER)
;
2124 }
2125#endif
2126
2127 CtkStyleContext *context;
2128
2129 context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
2130 ctk_style_context_add_class (context, "cafe-terminal");
2131
2132 ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, _("Terminal")gettext ("Terminal"));
2133
2134 priv->active_screen = NULL((void*)0);
2135 priv->menubar_visible = FALSE(0);
2136
2137 priv->main_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0);
2138 ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_container_get_type ()))))))
, priv->main_vbox);
2139 ctk_widget_show (priv->main_vbox);
2140
2141 priv->notebook = ctk_notebook_new ();
2142 ctk_notebook_set_scrollable (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, TRUE(!(0)));
2143 ctk_notebook_set_show_border (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, FALSE(0));
2144 ctk_notebook_set_show_tabs (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, FALSE(0));
2145 ctk_notebook_set_group_name (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, I_("cafe-terminal-window")g_intern_static_string ("cafe-terminal-window"));
2146 g_signal_connect (priv->notebook, "button-press-event",g_signal_connect_data ((priv->notebook), ("button-press-event"
), (((GCallback) (notebook_button_press_cb))), (settings_global
), ((void*)0), (GConnectFlags) 0)
2147 G_CALLBACK (notebook_button_press_cb), settings_global)g_signal_connect_data ((priv->notebook), ("button-press-event"
), (((GCallback) (notebook_button_press_cb))), (settings_global
), ((void*)0), (GConnectFlags) 0)
;
2148 g_signal_connect (window, "key-press-event",g_signal_connect_data ((window), ("key-press-event"), (((GCallback
) (window_key_press_cb))), (settings_global), ((void*)0), (GConnectFlags
) 0)
2149 G_CALLBACK (window_key_press_cb), settings_global)g_signal_connect_data ((window), ("key-press-event"), (((GCallback
) (window_key_press_cb))), (settings_global), ((void*)0), (GConnectFlags
) 0)
;
2150 g_signal_connect (priv->notebook, "popup-menu",g_signal_connect_data ((priv->notebook), ("popup-menu"), (
((GCallback) (notebook_popup_menu_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2151 G_CALLBACK (notebook_popup_menu_cb), window)g_signal_connect_data ((priv->notebook), ("popup-menu"), (
((GCallback) (notebook_popup_menu_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
2152 g_signal_connect_after (priv->notebook, "switch-page",g_signal_connect_data ((priv->notebook), ("switch-page"), (
((GCallback) (notebook_page_selected_callback))), (window), (
(void*)0), G_CONNECT_AFTER)
2153 G_CALLBACK (notebook_page_selected_callback), window)g_signal_connect_data ((priv->notebook), ("switch-page"), (
((GCallback) (notebook_page_selected_callback))), (window), (
(void*)0), G_CONNECT_AFTER)
;
2154 g_signal_connect_after (priv->notebook, "page-added",g_signal_connect_data ((priv->notebook), ("page-added"), (
((GCallback) (notebook_page_added_callback))), (window), ((void
*)0), G_CONNECT_AFTER)
2155 G_CALLBACK (notebook_page_added_callback), window)g_signal_connect_data ((priv->notebook), ("page-added"), (
((GCallback) (notebook_page_added_callback))), (window), ((void
*)0), G_CONNECT_AFTER)
;
2156 g_signal_connect_after (priv->notebook, "page-removed",g_signal_connect_data ((priv->notebook), ("page-removed"),
(((GCallback) (notebook_page_removed_callback))), (window), (
(void*)0), G_CONNECT_AFTER)
2157 G_CALLBACK (notebook_page_removed_callback), window)g_signal_connect_data ((priv->notebook), ("page-removed"),
(((GCallback) (notebook_page_removed_callback))), (window), (
(void*)0), G_CONNECT_AFTER)
;
2158 g_signal_connect_data (priv->notebook, "page-reordered",
2159 G_CALLBACK (terminal_window_update_tabs_menu_sensitivity)((GCallback) (terminal_window_update_tabs_menu_sensitivity)),
2160 window, NULL((void*)0), G_CONNECT_SWAPPED | G_CONNECT_AFTER);
2161
2162 ctk_widget_add_events (priv->notebook, CDK_SCROLL_MASK);
2163 g_signal_connect (priv->notebook, "scroll-event",g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (notebook_scroll_event_cb))), (window), ((void
*)0), (GConnectFlags) 0)
2164 G_CALLBACK (notebook_scroll_event_cb), window)g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (notebook_scroll_event_cb))), (window), ((void
*)0), (GConnectFlags) 0)
;
2165
2166 g_signal_connect (priv->notebook, "create-window",g_signal_connect_data ((priv->notebook), ("create-window")
, (((GCallback) (handle_tab_droped_on_desktop))), (window), (
(void*)0), (GConnectFlags) 0)
2167 G_CALLBACK (handle_tab_droped_on_desktop), window)g_signal_connect_data ((priv->notebook), ("create-window")
, (((GCallback) (handle_tab_droped_on_desktop))), (window), (
(void*)0), (GConnectFlags) 0)
;
2168
2169 ctk_box_pack_end (CTK_BOX (priv->main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->main_vbox)), ((ctk_box_get_type ()))))))
, priv->notebook, TRUE(!(0)), TRUE(!(0)), 0);
2170 ctk_widget_show (priv->notebook);
2171
2172 priv->old_char_width = -1;
2173 priv->old_char_height = -1;
2174
2175 priv->old_chrome_width = -1;
2176 priv->old_chrome_height = -1;
2177 priv->old_padding_width = -1;
2178 priv->old_padding_height = -1;
2179
2180 priv->old_geometry_widget = NULL((void*)0);
2181
2182 /* Create the UI manager */
2183 manager = priv->ui_manager = ctk_ui_manager_new ();
2184
2185 accel_group = ctk_ui_manager_get_accel_group (manager);
2186 ctk_window_add_accel_group (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, accel_group);
2187 /* Workaround for bug #453193, bug #138609 and bug #559728 */
2188 g_signal_connect_after (accel_group, "accel-activate",g_signal_connect_data ((accel_group), ("accel-activate"), (((
GCallback) (terminal_window_accel_activate_cb))), (window), (
(void*)0), G_CONNECT_AFTER)
2189 G_CALLBACK (terminal_window_accel_activate_cb), window)g_signal_connect_data ((accel_group), ("accel-activate"), (((
GCallback) (terminal_window_accel_activate_cb))), (window), (
(void*)0), G_CONNECT_AFTER)
;
2190
2191 /* Create the actions */
2192 /* Note that this action group name is used in terminal-accels.c; do not change it */
2193 priv->action_group = action_group = ctk_action_group_new ("Main");
2194 ctk_action_group_set_translation_domain (action_group, NULL((void*)0));
2195 ctk_action_group_add_actions (action_group, menu_entries,
2196 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])), window);
2197 ctk_action_group_add_toggle_actions (action_group,
2198 toggle_menu_entries,
2199 G_N_ELEMENTS (toggle_menu_entries)(sizeof (toggle_menu_entries) / sizeof ((toggle_menu_entries)
[0]))
,
2200 window);
2201 ctk_ui_manager_insert_action_group (manager, action_group, 0);
2202 g_object_unref (action_group);
2203
2204 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
2205 g_signal_connect_swapped (clipboard, "owner-change",g_signal_connect_data ((clipboard), ("owner-change"), (((GCallback
) (update_edit_menu))), (window), ((void*)0), G_CONNECT_SWAPPED
)
2206 G_CALLBACK (update_edit_menu), window)g_signal_connect_data ((clipboard), ("owner-change"), (((GCallback
) (update_edit_menu))), (window), ((void*)0), G_CONNECT_SWAPPED
)
;
2207 update_edit_menu (window);
2208 /* Idem for this action, since the window is not fullscreen. */
2209 action = ctk_action_group_get_action (priv->action_group, "PopupLeaveFullscreen");
2210 ctk_action_set_visible (action, FALSE(0));
2211
2212 action = ctk_action_group_get_action (priv->action_group, "FileSaveContents");
2213 ctk_action_set_visible (action, FALSE(0));
2214
2215 /* Load the UI */
2216 error = NULL((void*)0);
2217 priv->ui_id = ctk_ui_manager_add_ui_from_resource (manager,
2218 TERMINAL_RESOURCES_PATH_PREFIX"/org/cafe/terminal" G_DIR_SEPARATOR_S"/" "ui/terminal.xml",
2219 &error);
2220 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 2220, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2221
2222 priv->menubar = ctk_ui_manager_get_widget (manager, "/menubar");
2223 ctk_box_pack_start (CTK_BOX (priv->main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->main_vbox)), ((ctk_box_get_type ()))))))
,
2224 priv->menubar,
2225 FALSE(0), FALSE(0), 0);
2226
2227 /* Add tabs menu */
2228 priv->tabs_menu = terminal_tabs_menu_new (window);
2229
2230 app = terminal_app_get ();
2231 terminal_window_profile_list_changed_cb (app, window);
2232 g_signal_connect (app, "profile-list-changed",g_signal_connect_data ((app), ("profile-list-changed"), (((GCallback
) (terminal_window_profile_list_changed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
2233 G_CALLBACK (terminal_window_profile_list_changed_cb), window)g_signal_connect_data ((app), ("profile-list-changed"), (((GCallback
) (terminal_window_profile_list_changed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
;
2234
2235 terminal_window_encoding_list_changed_cb (app, window);
2236 g_signal_connect (app, "encoding-list-changed",g_signal_connect_data ((app), ("encoding-list-changed"), (((GCallback
) (terminal_window_encoding_list_changed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
2237 G_CALLBACK (terminal_window_encoding_list_changed_cb), window)g_signal_connect_data ((app), ("encoding-list-changed"), (((GCallback
) (terminal_window_encoding_list_changed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
;
2238
2239 terminal_window_set_menubar_visible (window, TRUE(!(0)));
2240 priv->use_default_menubar_visibility = TRUE(!(0));
2241
2242 terminal_window_update_size_to_menu (window);
2243
2244 /* We have to explicitly call this, since screen-changed is NOT
2245 * emitted for the toplevel the first time!
2246 */
2247 terminal_window_screen_update (window, ctk_widget_get_screen (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
));
2248
2249 window_group = ctk_window_group_new ();
2250 ctk_window_group_add_window (window_group, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
2251 g_object_unref (window_group);
2252
2253 terminal_util_set_unique_role (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, "cafe-terminal-window");
2254}
2255
2256static void
2257terminal_window_class_init (TerminalWindowClass *klass)
2258{
2259 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2260 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
2261
2262 object_class->dispose = terminal_window_dispose;
2263 object_class->finalize = terminal_window_finalize;
2264
2265 widget_class->show = terminal_window_show;
2266 widget_class->realize = terminal_window_realize;
2267 widget_class->map_event = terminal_window_map_event;
2268 widget_class->window_state_event = terminal_window_state_event;
2269 widget_class->screen_changed = terminal_window_screen_changed;
2270}
2271
2272static void
2273terminal_window_dispose (GObject *object)
2274{
2275 TerminalWindow *window = TERMINAL_WINDOW (object)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((terminal_window_get_type ()))))))
;
2276 TerminalWindowPrivate *priv = window->priv;
2277 TerminalApp *app;
2278 CtkClipboard *clipboard;
2279#ifdef CDK_WINDOWING_X11
2280 CdkScreen *screen;
2281#endif
2282
2283 remove_popup_info (window);
2284
2285 priv->disposed = TRUE(!(0));
2286
2287 if (priv->tabs_menu)
2288 {
2289 g_object_unref (priv->tabs_menu);
2290 priv->tabs_menu = NULL((void*)0);
2291 }
2292
2293 if (priv->profiles_action_group != NULL((void*)0))
2294 disconnect_profiles_from_actions_in_group (priv->profiles_action_group);
2295 if (priv->new_terminal_action_group != NULL((void*)0))
2296 disconnect_profiles_from_actions_in_group (priv->new_terminal_action_group);
2297
2298 app = terminal_app_get ();
2299 g_signal_handlers_disconnect_by_func (app,g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_profile_list_changed_cb)))
, (window))
2300 G_CALLBACK (terminal_window_profile_list_changed_cb),g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_profile_list_changed_cb)))
, (window))
2301 window)g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_profile_list_changed_cb)))
, (window))
;
2302 g_signal_handlers_disconnect_by_func (app,g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_encoding_list_changed_cb))
), (window))
2303 G_CALLBACK (terminal_window_encoding_list_changed_cb),g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_encoding_list_changed_cb))
), (window))
2304 window)g_signal_handlers_disconnect_matched ((app), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_encoding_list_changed_cb))
), (window))
;
2305 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
2306 g_signal_handlers_disconnect_by_func (clipboard,g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (update_edit_menu))), (window))
2307 G_CALLBACK (update_edit_menu),g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (update_edit_menu))), (window))
2308 window)g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (update_edit_menu))), (window))
;
2309
2310#ifdef CDK_WINDOWING_X11
2311 screen = ctk_widget_get_screen (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
);
2312 if (screen && CDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((cdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
2313 {
2314 g_signal_handlers_disconnect_by_func (screen,g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
2315 G_CALLBACK (terminal_window_window_manager_changed_cb),g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
2316 window)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (terminal_window_window_manager_changed_cb)
)), (window))
;
2317 }
2318#endif
2319
2320 G_OBJECT_CLASS (terminal_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose (object);
2321}
2322
2323static void
2324terminal_window_finalize (GObject *object)
2325{
2326 TerminalWindow *window = TERMINAL_WINDOW (object)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((terminal_window_get_type ()))))))
;
2327 TerminalWindowPrivate *priv = window->priv;
2328
2329 g_object_unref (priv->ui_manager);
2330
2331 if (priv->confirm_close_dialog)
2332 ctk_dialog_response (CTK_DIALOG (priv->confirm_close_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->confirm_close_dialog)), ((ctk_dialog_get_type (
)))))))
,
2333 CTK_RESPONSE_DELETE_EVENT);
2334
2335 if (priv->search_find_dialog)
2336 ctk_dialog_response (CTK_DIALOG (priv->search_find_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->search_find_dialog)), ((ctk_dialog_get_type ())
)))))
,
2337 CTK_RESPONSE_DELETE_EVENT);
2338
2339 G_OBJECT_CLASS (terminal_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
2340}
2341
2342static gboolean
2343terminal_window_delete_event (CtkWidget *widget,
2344 CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)),
2345 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
2346{
2347 return confirm_close_window_or_tab (TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
, NULL((void*)0));
2348}
2349
2350static gboolean
2351terminal_window_focus_in_event (CtkWidget *widget,
2352 CdkEventFocus *event,
2353 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
2354{
2355 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2356 TerminalWindowPrivate *priv = window->priv;
2357
2358 if (event->in)
2359 priv->focus_time = time(NULL((void*)0));
2360
2361 return FALSE(0);
2362}
2363
2364static void
2365terminal_window_show (CtkWidget *widget)
2366{
2367 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2368 CtkAllocation widget_allocation;
2369
2370 ctk_widget_get_allocation (widget, &widget_allocation);
2371
2372 TerminalWindowPrivate *priv = window->priv;
2373
2374 if (priv->active_screen != NULL((void*)0))
2375 {
2376 terminal_window_update_copy_selection (priv->active_screen, window);
2377#if 0
2378 /* At this point, we have our CdkScreen, and hence the right
2379 * font size, so we can go ahead and size the window. */
2380 terminal_window_update_size (window, priv->active_screen, FALSE(0));
2381#endif
2382 }
2383
2384 terminal_window_update_geometry (window);
2385
2386 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] show, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
2387 "[window %p] show, size %d : %d at (%d, %d)\n",do { if (0) g_printerr("[window %p] show, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
2388 widget,do { if (0) g_printerr("[window %p] show, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
2389 widget_allocation.width, widget_allocation.height,do { if (0) g_printerr("[window %p] show, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
2390 widget_allocation.x, widget_allocation.y)do { if (0) g_printerr("[window %p] show, size %d : %d at (%d, %d)\n"
, widget, widget_allocation.width, widget_allocation.height, widget_allocation
.x, widget_allocation.y); } while (0)
;
2391
2392 CTK_WIDGET_CLASS (terminal_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), ((ctk_widget_get_type ()
))))))
->show (widget);
2393}
2394
2395TerminalWindow*
2396terminal_window_new (void)
2397{
2398 return g_object_new (TERMINAL_TYPE_WINDOW(terminal_window_get_type ()), NULL((void*)0));
2399}
2400
2401/**
2402 * terminal_window_set_is_restored:
2403 * @window:
2404 *
2405 * Marks the window as restored from session.
2406 */
2407void
2408terminal_window_set_is_restored (TerminalWindow *window)
2409{
2410 g_return_if_fail (TERMINAL_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((terminal_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "TERMINAL_IS_WINDOW (window)"); return; } } while
(0)
;
2411 g_return_if_fail (!ctk_widget_get_mapped (CTK_WIDGET (window)))do { if ((!ctk_widget_get_mapped (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((ctk_widget_get_type ()))))))
))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "!ctk_widget_get_mapped (CTK_WIDGET (window))"
); return; } } while (0)
;
2412
2413 window->priv->clear_demands_attention = TRUE(!(0));
2414}
2415
2416static void
2417profile_set_callback (TerminalScreen *screen,
2418 TerminalProfile *old_profile G_GNUC_UNUSED__attribute__ ((__unused__)),
2419 TerminalWindow *window)
2420{
2421 TerminalWindowPrivate *priv = window->priv;
2422
2423 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2424 return;
2425
2426 if (screen != priv->active_screen)
2427 return;
2428
2429 terminal_window_update_set_profile_menu_active_profile (window);
2430}
2431
2432static void
2433sync_screen_title (TerminalScreen *screen,
2434 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2435 TerminalWindow *window)
2436{
2437 TerminalWindowPrivate *priv = window->priv;
2438
2439 if (screen != priv->active_screen)
2440 return;
2441
2442 ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, terminal_screen_get_title (screen));
2443}
2444
2445static void
2446sync_screen_icon_title (TerminalScreen *screen,
2447 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2448 TerminalWindow *window)
2449{
2450 TerminalWindowPrivate *priv = window->priv;
2451
2452 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2453 return;
2454
2455 if (screen != priv->active_screen)
2456 return;
2457
2458 if (!terminal_screen_get_icon_title_set (screen))
2459 return;
2460
2461 cdk_window_set_icon_name (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
), terminal_screen_get_icon_title (screen));
2462
2463 priv->icon_title_set = TRUE(!(0));
2464}
2465
2466static void
2467sync_screen_icon_title_set (TerminalScreen *screen,
2468 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2469 TerminalWindow *window)
2470{
2471 TerminalWindowPrivate *priv = window->priv;
2472
2473 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2474 return;
2475
2476 /* No need to restore the title if we never set an icon title */
2477 if (!priv->icon_title_set)
2478 return;
2479
2480 if (screen != priv->active_screen)
2481 return;
2482
2483 if (terminal_screen_get_icon_title_set (screen))
2484 return;
2485
2486 /* Need to reset the icon name */
2487 /* FIXME: Once ctk+ bug 535557 is fixed, use that to unset the icon title. */
2488
2489 g_object_set_qdata (G_OBJECT (ctk_widget_get_window (CTK_WIDGET (window)))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_window (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((ctk_widget_get_type ()))))))
))), (((GType) ((20) << (2))))))))
,
2490 g_quark_from_static_string ("cdk-icon-name-set"),
2491 GUINT_TO_POINTER (FALSE)((gpointer) (gulong) ((0))));
2492 priv->icon_title_set = FALSE(0);
2493
2494 /* Re-setting the right title will be done by the notify::title handler which comes after this one */
2495}
2496
2497/* Notebook callbacks */
2498
2499static void
2500close_button_clicked_cb (CtkWidget *tab_label G_GNUC_UNUSED__attribute__ ((__unused__)),
2501 CtkWidget *screen_container)
2502{
2503 CtkWidget *toplevel;
2504 TerminalWindow *window;
2505 TerminalScreen *screen;
2506
2507 toplevel = ctk_widget_get_toplevel (screen_container);
2508 if (!ctk_widget_is_toplevel (toplevel))
2509 return;
2510
2511 if (!TERMINAL_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((terminal_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
2512 return;
2513
2514 window = TERMINAL_WINDOW (toplevel)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((terminal_window_get_type ()))))))
;
2515
2516 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (screen_container)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen_container)), ((terminal_screen_container_get_type
()))))))
);
2517 if (confirm_close_window_or_tab (window, screen))
2518 return;
2519
2520 terminal_window_remove_screen (window, screen);
2521}
2522
2523void
2524terminal_window_add_screen (TerminalWindow *window,
2525 TerminalScreen *screen,
2526 int position)
2527{
2528 TerminalWindowPrivate *priv = window->priv;
2529 CtkWidget *old_window;
2530 CtkWidget *screen_container, *tab_label;
2531
2532 old_window = ctk_widget_get_toplevel (CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
);
2533 if (ctk_widget_is_toplevel (old_window) &&
2534 TERMINAL_IS_WINDOW (old_window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(old_window)); GType __t = ((terminal_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&&
2535 TERMINAL_WINDOW (old_window)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((old_window)), ((terminal_window_get_type ()))))))
== window)
2536 return;
2537
2538 if (TERMINAL_IS_WINDOW (old_window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(old_window)); GType __t = ((terminal_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
2539 terminal_window_remove_screen (TERMINAL_WINDOW (old_window)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((old_window)), ((terminal_window_get_type ()))))))
, screen);
2540
2541 screen_container = terminal_screen_container_new (screen);
2542 ctk_widget_show (screen_container);
2543
2544 update_tab_visibility (window, +1);
2545
2546 tab_label = terminal_tab_label_new (screen);
2547 g_signal_connect (tab_label, "close-button-clicked",g_signal_connect_data ((tab_label), ("close-button-clicked"),
(((GCallback) (close_button_clicked_cb))), (screen_container
), ((void*)0), (GConnectFlags) 0)
2548 G_CALLBACK (close_button_clicked_cb), screen_container)g_signal_connect_data ((tab_label), ("close-button-clicked"),
(((GCallback) (close_button_clicked_cb))), (screen_container
), ((void*)0), (GConnectFlags) 0)
;
2549
2550 ctk_notebook_insert_page (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2551 screen_container,
2552 tab_label,
2553 position);
2554 ctk_container_child_set (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
,
2555 screen_container,
2556 "tab-expand", TRUE(!(0)),
2557 "tab-fill", TRUE(!(0)),
2558 NULL((void*)0));
2559 ctk_notebook_set_tab_reorderable (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2560 screen_container,
2561 TRUE(!(0)));
2562 ctk_notebook_set_tab_detachable (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2563 screen_container,
2564 TRUE(!(0)));
2565}
2566
2567void
2568terminal_window_remove_screen (TerminalWindow *window,
2569 TerminalScreen *screen)
2570{
2571 TerminalWindowPrivate *priv = window->priv;
2572 TerminalScreenContainer *screen_container;
2573
2574 g_return_if_fail (ctk_widget_get_toplevel (CTK_WIDGET (screen)) == CTK_WIDGET (window))do { if ((ctk_widget_get_toplevel (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), ((ctk_widget_get_type ()))))))
) == ((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ())))))))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "ctk_widget_get_toplevel (CTK_WIDGET (screen)) == CTK_WIDGET (window)"
); return; } } while (0)
;
2575
2576 update_tab_visibility (window, -1);
2577
2578 screen_container = terminal_screen_container_get_from_screen (screen);
2579 if (detach_tab)
2580 {
2581 ctk_notebook_detach_tab (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2582 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2583 detach_tab = FALSE(0);
2584 }
2585 else
2586 ctk_container_remove (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
,
2587 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2588}
2589
2590void
2591terminal_window_move_screen (TerminalWindow *source_window,
2592 TerminalWindow *dest_window,
2593 TerminalScreen *screen,
2594 int dest_position)
2595{
2596 TerminalScreenContainer *screen_container;
2597
2598 g_return_if_fail (TERMINAL_IS_WINDOW (source_window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((source_window)); GType __t = ((terminal_window_get_type (
))); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "TERMINAL_IS_WINDOW (source_window)"
); return; } } while (0)
;
2599 g_return_if_fail (TERMINAL_IS_WINDOW (dest_window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dest_window)); GType __t = ((terminal_window_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "TERMINAL_IS_WINDOW (dest_window)"
); return; } } while (0)
;
2600 g_return_if_fail (TERMINAL_IS_SCREEN (screen))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((terminal_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "TERMINAL_IS_SCREEN (screen)"); return; } } while
(0)
;
2601 g_return_if_fail (ctk_widget_get_toplevel (CTK_WIDGET (screen)) == CTK_WIDGET (source_window))do { if ((ctk_widget_get_toplevel (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), ((ctk_widget_get_type ()))))))
) == ((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_window)), ((ctk_widget_get_type ())))))))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "ctk_widget_get_toplevel (CTK_WIDGET (screen)) == CTK_WIDGET (source_window)"
); return; } } while (0)
;
2602 g_return_if_fail (dest_position >= -1)do { if ((dest_position >= -1)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dest_position >= -1"
); return; } } while (0)
;
2603
2604 screen_container = terminal_screen_container_get_from_screen (screen);
2605 g_assert (TERMINAL_IS_SCREEN_CONTAINER (screen_container))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen_container)); GType __t = ((terminal_screen_container_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "terminal-window.c"
, 2605, ((const char*) (__func__)), "TERMINAL_IS_SCREEN_CONTAINER (screen_container)"
); } while (0)
;
2606
2607 /* We have to ref the screen container as well as the screen,
2608 * because otherwise removing the screen container from the source
2609 * window's notebook will cause the container and its containing
2610 * screen to be ctk_widget_destroy()ed!
2611 */
2612 g_object_ref_sink (screen_container)((__typeof__ (screen_container)) (g_object_ref_sink) (screen_container
))
;
2613 g_object_ref_sink (screen)((__typeof__ (screen)) (g_object_ref_sink) (screen));
2614
2615 detach_tab = TRUE(!(0));
2616
2617 terminal_window_remove_screen (source_window, screen);
2618
2619 /* Now we can safely remove the screen from the container and let the container die */
2620 ctk_container_remove (CTK_CONTAINER (ctk_widget_get_parent (CTK_WIDGET (screen)))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), ((ctk_widget_get_type ()))))))
))), ((ctk_container_get_type ()))))))
, CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
);
2621 g_object_unref (screen_container);
2622
2623 terminal_window_add_screen (dest_window, screen, dest_position);
2624 ctk_notebook_set_current_page (CTK_NOTEBOOK (dest_window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dest_window->priv->notebook)), ((ctk_notebook_get_type
()))))))
, dest_position);
2625 g_object_unref (screen);
2626}
2627
2628GList*
2629terminal_window_list_screen_containers (TerminalWindow *window)
2630{
2631 TerminalWindowPrivate *priv = window->priv;
2632
2633 /* We are trusting that CtkNotebook will return pages in order */
2634 return ctk_container_get_children (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
);
2635}
2636
2637void
2638terminal_window_set_menubar_visible (TerminalWindow *window,
2639 gboolean setting)
2640{
2641 TerminalWindowPrivate *priv = window->priv;
2642 CtkAction *action;
2643
2644 /* it's been set now, so don't override when adding a screen.
2645 * this side effect must happen before we short-circuit below.
2646 */
2647 priv->use_default_menubar_visibility = FALSE(0);
2648
2649 if (setting == priv->menubar_visible)
2650 return;
2651
2652 priv->menubar_visible = setting;
2653
2654 action = ctk_action_group_get_action (priv->action_group, "ViewMenubar");
2655 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
, setting);
2656
2657 g_object_set (priv->menubar, "visible", setting, NULL((void*)0));
2658
2659 /* FIXMEchpe: use ctk_widget_get_realized instead? */
2660 if (priv->active_screen)
2661 {
2662 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] setting size after toggling menubar visibility\n"
, window); } while (0)
2663 "[window %p] setting size after toggling menubar visibility\n",do { if (0) g_printerr("[window %p] setting size after toggling menubar visibility\n"
, window); } while (0)
2664 window)do { if (0) g_printerr("[window %p] setting size after toggling menubar visibility\n"
, window); } while (0)
;
2665
2666 terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
2667 }
2668}
2669
2670gboolean
2671terminal_window_get_menubar_visible (TerminalWindow *window)
2672{
2673 TerminalWindowPrivate *priv = window->priv;
2674
2675 return priv->menubar_visible;
2676}
2677
2678CtkWidget *
2679terminal_window_get_notebook (TerminalWindow *window)
2680{
2681 TerminalWindowPrivate *priv = window->priv;
2682
2683 g_return_val_if_fail (TERMINAL_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((terminal_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "TERMINAL_IS_WINDOW (window)"); return (((void
*)0)); } } while (0)
;
2684
2685 return CTK_WIDGET (priv->notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_widget_get_type ()))))))
;
2686}
2687
2688void
2689terminal_window_update_size (TerminalWindow *window,
2690 TerminalScreen *screen,
2691 gboolean even_if_mapped)
2692{
2693 terminal_window_update_size_set_geometry (window, screen,
2694 even_if_mapped, NULL((void*)0));
2695}
2696
2697gboolean
2698terminal_window_update_size_set_geometry (TerminalWindow *window,
2699 TerminalScreen *screen,
2700 gboolean even_if_mapped,
2701 gchar *geometry_string)
2702{
2703 TerminalWindowPrivate *priv = window->priv;
2704 CtkWidget *widget;
2705 CtkWidget *app;
2706 gboolean result;
2707 int geom_result;
2708 gint force_pos_x = 0, force_pos_y = 0;
2709 unsigned int force_grid_width = 0, force_grid_height = 0;
2710 int grid_width, grid_height;
2711 gint pixel_width, pixel_height;
2712 CdkWindow *cdk_window;
2713 CdkGravity pos_gravity;
2714
2715 cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
2716 result = TRUE(!(0));
2717
2718 if (cdk_window != NULL((void*)0) &&
2719 (cdk_window_get_state (cdk_window) &
2720 (CDK_WINDOW_STATE_MAXIMIZED | CDK_WINDOW_STATE_TILED)))
2721 {
2722 /* Don't adjust the size of maximized or tiled (snapped, half-maximized)
2723 * windows: if we do, there will be ugly gaps of up to 1 character cell
2724 * around otherwise tiled windows. */
2725 return result;
2726 }
2727
2728 /* be sure our geometry is up-to-date */
2729 terminal_window_update_geometry (window);
2730
2731 if (CTK_IS_WIDGET (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((ctk_widget_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
2732 widget = CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
;
2733 else
2734 widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
;
2735
2736 app = ctk_widget_get_toplevel (widget);
2737 g_assert (app != NULL)do { if (app != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "terminal-window.c", 2737, ((const char*) (__func__
)), "app != NULL"); } while (0)
;
2738
2739 terminal_screen_get_size (screen, &grid_width, &grid_height);
2740 if (geometry_string != NULL((void*)0))
2741 {
2742 geom_result = terminal_window_XParseGeometry (geometry_string,
2743 &force_pos_x,
2744 &force_pos_y,
2745 &force_grid_width,
2746 &force_grid_height);
2747 if (geom_result == NoValue0x0000)
2748 result = FALSE(0);
2749 }
2750 else
2751 geom_result = NoValue0x0000;
2752
2753 if ((geom_result & WidthValue0x0004) != 0)
2754 grid_width = force_grid_width;
2755 if ((geom_result & HeightValue0x0008) != 0)
2756 grid_height = force_grid_height;
2757
2758 /* the "old" struct members were updated by update_geometry */
2759 pixel_width = priv->old_chrome_width + grid_width * priv->old_char_width;
2760 pixel_height = priv->old_chrome_height + grid_height * priv->old_char_height;
2761
2762 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] size is %dx%d cells of %dx%d px\n"
, window, grid_width, grid_height, priv->old_char_width, priv
->old_char_height); } while (0)
2763 "[window %p] size is %dx%d cells of %dx%d px\n",do { if (0) g_printerr("[window %p] size is %dx%d cells of %dx%d px\n"
, window, grid_width, grid_height, priv->old_char_width, priv
->old_char_height); } while (0)
2764 window, grid_width, grid_height,do { if (0) g_printerr("[window %p] size is %dx%d cells of %dx%d px\n"
, window, grid_width, grid_height, priv->old_char_width, priv
->old_char_height); } while (0)
2765 priv->old_char_width, priv->old_char_height)do { if (0) g_printerr("[window %p] size is %dx%d cells of %dx%d px\n"
, window, grid_width, grid_height, priv->old_char_width, priv
->old_char_height); } while (0)
;
2766
2767 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
2768 "[window %p] %dx%d + %dx%d = %dx%d\n",do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
2769 window, grid_width * priv->old_char_width,do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
2770 grid_height * priv->old_char_height,do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
2771 priv->old_chrome_width, priv->old_chrome_height,do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
2772 pixel_width, pixel_height)do { if (0) g_printerr("[window %p] %dx%d + %dx%d = %dx%d\n",
window, grid_width * priv->old_char_width, grid_height * priv
->old_char_height, priv->old_chrome_width, priv->old_chrome_height
, pixel_width, pixel_height); } while (0)
;
2773
2774 pos_gravity = CDK_GRAVITY_NORTH_WEST;
2775 if ((geom_result & XNegative0x0010) != 0 && (geom_result & YNegative0x0020) != 0)
2776 pos_gravity = CDK_GRAVITY_SOUTH_EAST;
2777 else if ((geom_result & XNegative0x0010) != 0)
2778 pos_gravity = CDK_GRAVITY_NORTH_EAST;
2779 else if ((geom_result & YNegative0x0020) != 0)
2780 pos_gravity = CDK_GRAVITY_SOUTH_WEST;
2781
2782 if ((geom_result & XValue0x0001) == 0)
2783 force_pos_x = 0;
2784 if ((geom_result & YValue0x0002) == 0)
2785 force_pos_y = 0;
2786
2787 if (pos_gravity == CDK_GRAVITY_SOUTH_EAST ||
2788 pos_gravity == CDK_GRAVITY_NORTH_EAST)
2789 force_pos_x = WidthOfScreen (cdk_x11_screen_get_xscreen (ctk_widget_get_screen (app)))((cdk_x11_screen_get_xscreen (ctk_widget_get_screen (app)))->
width)
-
2790 pixel_width + force_pos_x;
2791 if (pos_gravity == CDK_GRAVITY_SOUTH_WEST ||
2792 pos_gravity == CDK_GRAVITY_SOUTH_EAST)
2793 force_pos_y = HeightOfScreen (cdk_x11_screen_get_xscreen (ctk_widget_get_screen (app)))((cdk_x11_screen_get_xscreen (ctk_widget_get_screen (app)))->
height)
-
2794 pixel_height + force_pos_y;
2795
2796 /* we don't let you put a window offscreen; maybe some people would
2797 * prefer to be able to, but it's kind of a bogus thing to do.
2798 */
2799 if (force_pos_x < 0)
2800 force_pos_x = 0;
2801 if (force_pos_y < 0)
2802 force_pos_y = 0;
2803
2804 if (even_if_mapped && ctk_widget_get_mapped (app))
2805 ctk_window_resize (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, pixel_width, pixel_height);
2806 else
2807 ctk_window_set_default_size (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, pixel_width, pixel_height);
2808
2809 if ((geom_result & XValue0x0001) != 0 || (geom_result & YValue0x0002) != 0)
2810 {
2811 ctk_window_set_gravity (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, pos_gravity);
2812 ctk_window_move (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, force_pos_x, force_pos_y);
2813 }
2814
2815 return result;
2816}
2817
2818void
2819terminal_window_switch_screen (TerminalWindow *window,
2820 TerminalScreen *screen)
2821{
2822 TerminalWindowPrivate *priv = window->priv;
2823 TerminalScreenContainer *screen_container;
2824 int page_num;
2825
2826 screen_container = terminal_screen_container_get_from_screen (screen);
2827 g_assert (TERMINAL_IS_SCREEN_CONTAINER (screen_container))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen_container)); GType __t = ((terminal_screen_container_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "terminal-window.c"
, 2827, ((const char*) (__func__)), "TERMINAL_IS_SCREEN_CONTAINER (screen_container)"
); } while (0)
;
2828 page_num = ctk_notebook_page_num (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2829 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2830 ctk_notebook_set_current_page (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
, page_num);
2831}
2832
2833TerminalScreen*
2834terminal_window_get_active (TerminalWindow *window)
2835{
2836 TerminalWindowPrivate *priv = window->priv;
2837
2838 return priv->active_screen;
2839}
2840
2841static gboolean
2842notebook_button_press_cb (CtkWidget *widget,
2843 CdkEventButton *event,
2844 GSettings *settings)
2845{
2846 TerminalWindow *window = TERMINAL_WINDOW (ctk_widget_get_toplevel (widget))((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_toplevel (widget))), ((terminal_window_get_type
()))))))
;
2847 TerminalWindowPrivate *priv = window->priv;
2848 CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_notebook_get_type ()))))))
;
2849 CtkWidget *tab;
2850 CtkWidget *menu;
2851 CtkAction *action;
2852 int tab_clicked;
2853
2854 if ((event->type == CDK_BUTTON_PRESS && event->button == 2) &&
2855 (g_settings_get_boolean (settings, "middle-click-closes-tabs")))
2856 {
2857 tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
2858 if (tab_clicked >= 0)
2859 {
2860 int page_num;
2861 int before_pages;
2862 int later_pages;
2863
2864 before_pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
2865 page_num = ctk_notebook_get_current_page (notebook);
2866 ctk_notebook_set_current_page (notebook, tab_clicked);
2867 TerminalScreen *active_screen = priv->active_screen;
2868
2869 if (!(confirm_close_window_or_tab (window, active_screen)))
2870 {
2871 update_tab_visibility (window, -1);
2872 ctk_notebook_remove_page(notebook, tab_clicked);
2873 }
2874
2875 later_pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
2876
2877 if (before_pages > later_pages) {
2878 if (tab_clicked > page_num)
2879 ctk_notebook_set_current_page (notebook, page_num);
2880 else if (tab_clicked < page_num)
2881 ctk_notebook_set_current_page (notebook, page_num - 1);
2882 }
2883 else
2884 ctk_notebook_set_current_page (notebook, page_num);
2885
2886 }
2887 }
2888
2889 if (event->type != CDK_BUTTON_PRESS ||
2890 event->button != 3 ||
2891 (event->state & ctk_accelerator_get_default_mod_mask ()) != 0)
2892 return FALSE(0);
2893
2894 tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
2895 if (tab_clicked < 0)
2896 return FALSE(0);
2897
2898 /* switch to the page the mouse is over */
2899 ctk_notebook_set_current_page (notebook, tab_clicked);
2900
2901 action = ctk_action_group_get_action (priv->action_group, "NotebookPopup");
2902 ctk_action_activate (action);
2903
2904 menu = ctk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
2905 if (ctk_menu_get_attach_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
))
2906 ctk_menu_detach (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
);
2907 tab = ctk_notebook_get_nth_page (notebook, tab_clicked);
2908 ctk_menu_attach_to_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
, tab, NULL((void*)0));
2909 ctk_menu_popup_at_pointer (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
, NULL((void*)0));
2910
2911 return TRUE(!(0));
2912}
2913
2914static gboolean
2915window_key_press_cb (CtkWidget *widget,
2916 CdkEventKey *event,
2917 GSettings *settings)
2918{
2919 if ((g_settings_get_boolean (settings, "exit-ctrl-d") == FALSE(0)) &&
2920 (event->state & CDK_CONTROL_MASK) && (event->keyval == CDK_KEY_d0x064))
2921 return TRUE(!(0));
2922
2923 if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs") &&
2924 event->state & CDK_CONTROL_MASK)
2925 {
2926 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2927 TerminalWindowPrivate *priv = window->priv;
2928 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
2929
2930 int pages = ctk_notebook_get_n_pages (notebook);
2931 int page_num = ctk_notebook_get_current_page (notebook);
2932
2933 if (event->keyval == CDK_KEY_ISO_Left_Tab0xfe20)
2934 {
2935 if (page_num != 0)
2936 ctk_notebook_prev_page (notebook);
2937 else
2938 ctk_notebook_set_current_page (notebook, (pages - 1));
2939 return TRUE(!(0));
2940 }
2941
2942 if (event->keyval == CDK_KEY_Tab0xff09)
2943 {
2944 if (page_num != (pages -1))
2945 ctk_notebook_next_page (notebook);
2946 else
2947 ctk_notebook_set_current_page (notebook, 0);
2948 return TRUE(!(0));
2949 }
2950 }
2951 return FALSE(0);
2952}
2953
2954static gboolean
2955notebook_popup_menu_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
2956 TerminalWindow *window)
2957{
2958 TerminalWindowPrivate *priv = window->priv;
2959 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
2960 CtkWidget *focus_widget, *tab, *tab_label, *menu;
2961 CtkAction *action;
2962 int page_num;
2963
2964 focus_widget = ctk_window_get_focus (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
2965 /* Only respond if the notebook is the actual focus */
2966 if (focus_widget != priv->notebook)
2967 return FALSE(0);
2968
2969 page_num = ctk_notebook_get_current_page (notebook);
2970 tab = ctk_notebook_get_nth_page (notebook, page_num);
2971 tab_label = ctk_notebook_get_tab_label (notebook, tab);
2972
2973 action = ctk_action_group_get_action (priv->action_group, "NotebookPopup");
2974 ctk_action_activate (action);
2975
2976 menu = ctk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
2977 if (ctk_menu_get_attach_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
))
2978 ctk_menu_detach (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
);
2979 ctk_menu_attach_to_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
, tab_label, NULL((void*)0));
2980 ctk_menu_popup_at_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
,
2981 tab_label,
2982 CDK_GRAVITY_SOUTH_WEST,
2983 CDK_GRAVITY_NORTH_WEST,
2984 NULL((void*)0));
2985 ctk_menu_shell_select_first (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, FALSE(0));
2986
2987 return TRUE(!(0));
2988}
2989
2990static void
2991notebook_page_selected_callback (CtkWidget *notebook G_GNUC_UNUSED__attribute__ ((__unused__)),
2992 CtkWidget *page_widget,
2993 guint page_num,
2994 TerminalWindow *window)
2995{
2996 TerminalWindowPrivate *priv = window->priv;
2997 CtkWidget *widget;
2998 TerminalScreen *screen;
2999 int old_grid_width, old_grid_height;
3000
3001 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
3002 "[window %p] MDI: page-selected %d\n",do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
3003 window, page_num)do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
;
3004
3005 if (priv->disposed)
3006 return;
3007
3008 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (page_widget)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((page_widget)), ((terminal_screen_container_get_type
()))))))
);
3009 widget = CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
;
3010 g_assert (screen != NULL)do { if (screen != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "terminal-window.c", 3010, ((const char*) (__func__
)), "screen != NULL"); } while (0)
;
3011
3012 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: setting active tab to screen %p (old active screen %p)\n"
, window, screen, priv->active_screen); } while (0)
3013 "[window %p] MDI: setting active tab to screen %p (old active screen %p)\n",do { if (0) g_printerr("[window %p] MDI: setting active tab to screen %p (old active screen %p)\n"
, window, screen, priv->active_screen); } while (0)
3014 window, screen, priv->active_screen)do { if (0) g_printerr("[window %p] MDI: setting active tab to screen %p (old active screen %p)\n"
, window, screen, priv->active_screen); } while (0)
;
3015
3016 if (priv->active_screen == screen)
3017 return;
3018
3019 if (priv->active_screen != NULL((void*)0))
3020 {
3021 terminal_screen_get_size (priv->active_screen, &old_grid_width, &old_grid_height);
3022
3023 /* This is so that we maintain the same grid */
3024 bte_terminal_set_size (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
, old_grid_width, old_grid_height);
3025 }
3026
3027 /* Workaround to remove ctknotebook's feature of computing its size based on
3028 * all pages. When the widget is hidden, its size will not be taken into
3029 * account.
3030 */
3031 if (priv->active_screen)
3032 ctk_widget_hide (CTK_WIDGET (priv->active_screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((ctk_widget_get_type ()))))))
); /* FIXME */
3033
3034 /* Make sure that the widget is no longer hidden due to the workaround */
3035 ctk_widget_show (widget);
3036
3037 priv->active_screen = screen;
3038
3039 /* Override menubar setting if it wasn't restored from session */
3040 if (priv->use_default_menubar_visibility)
3041 {
3042 gboolean setting =
3043 terminal_profile_get_property_boolean (terminal_screen_get_profile (screen), TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR"default-show-menubar");
3044
3045 terminal_window_set_menubar_visible (window, setting);
3046 }
3047
3048 sync_screen_icon_title_set (screen, NULL((void*)0), window);
3049 sync_screen_icon_title (screen, NULL((void*)0), window);
3050 sync_screen_title (screen, NULL((void*)0), window);
3051
3052 /* set size of window to current grid size */
3053 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] setting size after flipping notebook pages\n"
, window); } while (0)
3054 "[window %p] setting size after flipping notebook pages\n",do { if (0) g_printerr("[window %p] setting size after flipping notebook pages\n"
, window); } while (0)
3055 window)do { if (0) g_printerr("[window %p] setting size after flipping notebook pages\n"
, window); } while (0)
;
3056 terminal_window_update_size (window, screen, TRUE(!(0)));
3057
3058 terminal_window_update_tabs_menu_sensitivity (window);
3059 terminal_window_update_encoding_menu_active_encoding (window);
3060 terminal_window_update_set_profile_menu_active_profile (window);
3061 terminal_window_update_copy_sensitivity (screen, window);
3062 terminal_window_update_zoom_sensitivity (window);
3063 terminal_window_update_search_sensitivity (screen, window);
3064}
3065
3066static void
3067notebook_page_added_callback (CtkWidget *notebook,
3068 CtkWidget *container,
3069 guint page_num G_GNUC_UNUSED__attribute__ ((__unused__)),
3070 TerminalWindow *window)
3071{
3072 TerminalWindowPrivate *priv = window->priv;
3073 TerminalScreen *screen;
3074 int pages;
3075
3076 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (container)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((container)), ((terminal_screen_container_get_type
()))))))
);
3077
3078 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
3079 "[window %p] MDI: screen %p inserted\n",do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
3080 window, screen)do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
;
3081
3082 g_signal_connect (G_OBJECT (screen),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), (((GType) ((20) << (2)))
)))))), ("profile-set"), (((GCallback) (profile_set_callback)
)), (window), ((void*)0), (GConnectFlags) 0)
3083 "profile-set",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), (((GType) ((20) << (2)))
)))))), ("profile-set"), (((GCallback) (profile_set_callback)
)), (window), ((void*)0), (GConnectFlags) 0)
3084 G_CALLBACK (profile_set_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), (((GType) ((20) << (2)))
)))))), ("profile-set"), (((GCallback) (profile_set_callback)
)), (window), ((void*)0), (GConnectFlags) 0)
3085 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((screen)), (((GType) ((20) << (2)))
)))))), ("profile-set"), (((GCallback) (profile_set_callback)
)), (window), ((void*)0), (GConnectFlags) 0)
;
3086
3087 /* FIXME: only connect on the active screen, not all screens! */
3088 g_signal_connect (screen, "notify::title",g_signal_connect_data ((screen), ("notify::title"), (((GCallback
) (sync_screen_title))), (window), ((void*)0), (GConnectFlags
) 0)
3089 G_CALLBACK (sync_screen_title), window)g_signal_connect_data ((screen), ("notify::title"), (((GCallback
) (sync_screen_title))), (window), ((void*)0), (GConnectFlags
) 0)
;
3090 g_signal_connect (screen, "notify::icon-title",g_signal_connect_data ((screen), ("notify::icon-title"), (((GCallback
) (sync_screen_icon_title))), (window), ((void*)0), (GConnectFlags
) 0)
3091 G_CALLBACK (sync_screen_icon_title), window)g_signal_connect_data ((screen), ("notify::icon-title"), (((GCallback
) (sync_screen_icon_title))), (window), ((void*)0), (GConnectFlags
) 0)
;
3092 g_signal_connect (screen, "notify::icon-title-set",g_signal_connect_data ((screen), ("notify::icon-title-set"), (
((GCallback) (sync_screen_icon_title_set))), (window), ((void
*)0), (GConnectFlags) 0)
3093 G_CALLBACK (sync_screen_icon_title_set), window)g_signal_connect_data ((screen), ("notify::icon-title-set"), (
((GCallback) (sync_screen_icon_title_set))), (window), ((void
*)0), (GConnectFlags) 0)
;
3094 g_signal_connect (screen, "selection-changed",g_signal_connect_data ((screen), ("selection-changed"), (((GCallback
) (terminal_window_update_copy_sensitivity))), (window), ((void
*)0), (GConnectFlags) 0)
3095 G_CALLBACK (terminal_window_update_copy_sensitivity), window)g_signal_connect_data ((screen), ("selection-changed"), (((GCallback
) (terminal_window_update_copy_sensitivity))), (window), ((void
*)0), (GConnectFlags) 0)
;
3096
3097 g_signal_connect (screen, "show-popup-menu",g_signal_connect_data ((screen), ("show-popup-menu"), (((GCallback
) (screen_show_popup_menu_callback))), (window), ((void*)0), (
GConnectFlags) 0)
3098 G_CALLBACK (screen_show_popup_menu_callback), window)g_signal_connect_data ((screen), ("show-popup-menu"), (((GCallback
) (screen_show_popup_menu_callback))), (window), ((void*)0), (
GConnectFlags) 0)
;
3099 g_signal_connect (screen, "match-clicked",g_signal_connect_data ((screen), ("match-clicked"), (((GCallback
) (screen_match_clicked_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3100 G_CALLBACK (screen_match_clicked_cb), window)g_signal_connect_data ((screen), ("match-clicked"), (((GCallback
) (screen_match_clicked_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3101 g_signal_connect (screen, "resize-window",g_signal_connect_data ((screen), ("resize-window"), (((GCallback
) (screen_resize_window_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3102 G_CALLBACK (screen_resize_window_cb), window)g_signal_connect_data ((screen), ("resize-window"), (((GCallback
) (screen_resize_window_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3103
3104 g_signal_connect (screen, "close-screen",g_signal_connect_data ((screen), ("close-screen"), (((GCallback
) (screen_close_cb))), (window), ((void*)0), (GConnectFlags) 0
)
3105 G_CALLBACK (screen_close_cb), window)g_signal_connect_data ((screen), ("close-screen"), (((GCallback
) (screen_close_cb))), (window), ((void*)0), (GConnectFlags) 0
)
;
3106
3107 update_tab_visibility (window, 0);
3108 terminal_window_update_tabs_menu_sensitivity (window);
3109 terminal_window_update_search_sensitivity (screen, window);
3110
3111#if 0
3112 /* FIXMEchpe: wtf is this doing? */
3113
3114 /* If we have an active screen, match its size and zoom */
3115 if (priv->active_screen)
3116 {
3117 int current_width, current_height;
3118 double scale;
3119
3120 terminal_screen_get_size (priv->active_screen, &current_width, &current_height);
3121 bte_terminal_set_size (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
, current_width, current_height);
3122
3123 scale = terminal_screen_get_font_scale (priv->active_screen);
3124 terminal_screen_set_font_scale (screen, scale);
3125 }
3126#endif
3127
3128 if (priv->present_on_insert)
3129 {
3130 ctk_window_present_with_time (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, ctk_get_current_event_time ());
3131 priv->present_on_insert = FALSE(0);
3132 }
3133 pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
3134 if (pages == 2) terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
3135}
3136
3137static void
3138notebook_page_removed_callback (CtkWidget *notebook,
3139 CtkWidget *container,
3140 guint page_num G_GNUC_UNUSED__attribute__ ((__unused__)),
3141 TerminalWindow *window)
3142{
3143 TerminalWindowPrivate *priv = window->priv;
3144 TerminalScreen *screen;
3145 int pages;
3146
3147 if (priv->disposed)
3148 return;
3149
3150 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (container)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((container)), ((terminal_screen_container_get_type
()))))))
);
3151
3152 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
3153 "[window %p] MDI: screen %p removed\n",do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
3154 window, screen)do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
;
3155
3156 g_signal_handlers_disconnect_by_func (G_OBJECT (screen),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (profile_set_callback
))), (window))
3157 G_CALLBACK (profile_set_callback),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (profile_set_callback
))), (window))
3158 window)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (profile_set_callback
))), (window))
;
3159
3160 g_signal_handlers_disconnect_by_func (G_OBJECT (screen),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_title
))), (window))
3161 G_CALLBACK (sync_screen_title),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_title
))), (window))
3162 window)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_title
))), (window))
;
3163
3164 g_signal_handlers_disconnect_by_func (G_OBJECT (screen),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title
))), (window))
3165 G_CALLBACK (sync_screen_icon_title),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title
))), (window))
3166 window)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title
))), (window))
;
3167
3168 g_signal_handlers_disconnect_by_func (G_OBJECT (screen),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title_set
))), (window))
3169 G_CALLBACK (sync_screen_icon_title_set),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title_set
))), (window))
3170 window)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (sync_screen_icon_title_set
))), (window))
;
3171
3172 g_signal_handlers_disconnect_by_func (G_OBJECT (screen),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (terminal_window_update_copy_sensitivity
))), (window))
3173 G_CALLBACK (terminal_window_update_copy_sensitivity),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (terminal_window_update_copy_sensitivity
))), (window))
3174 window)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((screen)), (((
GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (terminal_window_update_copy_sensitivity
))), (window))
;
3175
3176 g_signal_handlers_disconnect_by_func (screen,g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_show_popup_menu_callback))), (window
))
3177 G_CALLBACK (screen_show_popup_menu_callback),g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_show_popup_menu_callback))), (window
))
3178 window)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_show_popup_menu_callback))), (window
))
;
3179
3180 g_signal_handlers_disconnect_by_func (screen,g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_match_clicked_cb))), (window))
3181 G_CALLBACK (screen_match_clicked_cb),g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_match_clicked_cb))), (window))
3182 window)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_match_clicked_cb))), (window))
;
3183 g_signal_handlers_disconnect_by_func (screen,g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_resize_window_cb))), (window))
3184 G_CALLBACK (screen_resize_window_cb),g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_resize_window_cb))), (window))
3185 window)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_resize_window_cb))), (window))
;
3186
3187 g_signal_handlers_disconnect_by_func (screen,g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_close_cb))), (window))
3188 G_CALLBACK (screen_close_cb),g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_close_cb))), (window))
3189 window)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (screen_close_cb))), (window))
;
3190
3191 terminal_window_update_tabs_menu_sensitivity (window);
3192 update_tab_visibility (window, 0);
3193 terminal_window_update_search_sensitivity (screen, window);
3194
3195 pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
3196 if (pages == 1)
3197 {
3198 terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
3199 }
3200 else if (pages == 0)
3201 {
3202 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3203 }
3204}
3205
3206void
3207terminal_window_update_copy_selection (TerminalScreen *screen,
3208 TerminalWindow *window)
3209{
3210 TerminalWindowPrivate *priv = window->priv;
3211 priv->copy_selection =
3212 terminal_profile_get_property_boolean (terminal_screen_get_profile (screen),
3213 TERMINAL_PROFILE_COPY_SELECTION"copy-selection");
3214}
3215
3216static gboolean
3217notebook_scroll_event_cb (CtkWidget *widget,
3218 CdkEventScroll *event,
3219 TerminalWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)))
3220{
3221 CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_notebook_get_type ()))))))
;
3222 CtkWidget *child, *event_widget, *action_widget;
3223
3224 child = ctk_notebook_get_nth_page (notebook, ctk_notebook_get_current_page (notebook));
3225 if (child == NULL((void*)0))
3226 return FALSE(0);
3227
3228 event_widget = ctk_get_event_widget ((CdkEvent *) event);
3229
3230 /* Ignore scroll events from the content of the page */
3231 if (event_widget == NULL((void*)0) ||
3232 event_widget == child ||
3233 ctk_widget_is_ancestor (event_widget, child))
3234 return FALSE(0);
3235
3236 /* And also from the action widgets */
3237 action_widget = ctk_notebook_get_action_widget (notebook, CTK_PACK_START);
3238 if (event_widget == action_widget ||
3239 (action_widget != NULL((void*)0) && ctk_widget_is_ancestor (event_widget, action_widget)))
3240 return FALSE(0);
3241 action_widget = ctk_notebook_get_action_widget (notebook, CTK_PACK_END);
3242 if (event_widget == action_widget ||
3243 (action_widget != NULL((void*)0) && ctk_widget_is_ancestor (event_widget, action_widget)))
3244 return FALSE(0);
3245
3246 switch (event->direction) {
3247 case CDK_SCROLL_RIGHT:
3248 case CDK_SCROLL_DOWN:
3249 ctk_notebook_next_page (notebook);
3250 break;
3251 case CDK_SCROLL_LEFT:
3252 case CDK_SCROLL_UP:
3253 ctk_notebook_prev_page (notebook);
3254 break;
3255 case CDK_SCROLL_SMOOTH:
3256 switch (ctk_notebook_get_tab_pos (notebook)) {
3257 case CTK_POS_LEFT:
3258 case CTK_POS_RIGHT:
3259 if (event->delta_y > 0)
3260 ctk_notebook_next_page (notebook);
3261 else if (event->delta_y < 0)
3262 ctk_notebook_prev_page (notebook);
3263 break;
3264 case CTK_POS_TOP:
3265 case CTK_POS_BOTTOM:
3266 if (event->delta_x > 0)
3267 ctk_notebook_next_page (notebook);
3268 else if (event->delta_x < 0)
3269 ctk_notebook_prev_page (notebook);
3270 break;
3271 }
3272 break;
3273 }
3274
3275 return TRUE(!(0));
3276}
3277
3278void
3279terminal_window_update_geometry (TerminalWindow *window)
3280{
3281 TerminalWindowPrivate *priv = window->priv;
3282 CtkWidget *widget;
3283 CdkGeometry hints;
3284 CtkBorder padding;
3285 CtkRequisition toplevel_request, vbox_request, widget_request;
3286 int grid_width, grid_height;
3287 int char_width, char_height;
3288 int chrome_width, chrome_height;
3289
3290 if (priv->active_screen == NULL((void*)0))
3291 return;
3292
3293 widget = CTK_WIDGET (priv->active_screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((ctk_widget_get_type ()))))))
;
3294
3295 /* We set geometry hints from the active term; best thing
3296 * I can think of to do. Other option would be to try to
3297 * get some kind of union of all hints from all terms in the
3298 * window, but that doesn't make too much sense.
3299 */
3300 terminal_screen_get_cell_size (priv->active_screen, &char_width, &char_height);
3301
3302 terminal_screen_get_size (priv->active_screen, &grid_width, &grid_height);
3303 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "%dx%d cells of %dx%d px = %dx%d px\n",do { if (0) g_printerr("%dx%d cells of %dx%d px = %dx%d px\n"
, grid_width, grid_height, char_width, char_height, char_width
* grid_width, char_height * grid_height); } while (0)
3304 grid_width, grid_height, char_width, char_height,do { if (0) g_printerr("%dx%d cells of %dx%d px = %dx%d px\n"
, grid_width, grid_height, char_width, char_height, char_width
* grid_width, char_height * grid_height); } while (0)
3305 char_width * grid_width, char_height * grid_height)do { if (0) g_printerr("%dx%d cells of %dx%d px = %dx%d px\n"
, grid_width, grid_height, char_width, char_height, char_width
* grid_width, char_height * grid_height); } while (0)
;
3306
3307 ctk_style_context_get_padding(ctk_widget_get_style_context (widget),
3308 ctk_widget_get_state_flags (widget),
3309 &padding);
3310
3311 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "padding = %dx%d px\n",do { if (0) g_printerr("padding = %dx%d px\n", padding.left +
padding.right, padding.top + padding.bottom); } while (0)
3312 padding.left + padding.right,do { if (0) g_printerr("padding = %dx%d px\n", padding.left +
padding.right, padding.top + padding.bottom); } while (0)
3313 padding.top + padding.bottom)do { if (0) g_printerr("padding = %dx%d px\n", padding.left +
padding.right, padding.top + padding.bottom); } while (0)
;
3314
3315 ctk_widget_get_preferred_size (priv->main_vbox, NULL((void*)0), &vbox_request);
3316 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "content area requests %dx%d px\n",do { if (0) g_printerr("content area requests %dx%d px\n", vbox_request
.width, vbox_request.height); } while (0)
3317 vbox_request.width, vbox_request.height)do { if (0) g_printerr("content area requests %dx%d px\n", vbox_request
.width, vbox_request.height); } while (0)
;
3318
3319 ctk_widget_get_preferred_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, NULL((void*)0), &toplevel_request);
3320 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "window requests %dx%d px\n",do { if (0) g_printerr("window requests %dx%d px\n", toplevel_request
.width, toplevel_request.height); } while (0)
3321 toplevel_request.width, toplevel_request.height)do { if (0) g_printerr("window requests %dx%d px\n", toplevel_request
.width, toplevel_request.height); } while (0)
;
3322
3323 chrome_width = vbox_request.width - (char_width * grid_width);
3324 chrome_height = vbox_request.height - (char_height * grid_height);
3325 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "chrome: %dx%d px\n",do { if (0) g_printerr("chrome: %dx%d px\n", chrome_width, chrome_height
); } while (0)
3326 chrome_width, chrome_height)do { if (0) g_printerr("chrome: %dx%d px\n", chrome_width, chrome_height
); } while (0)
;
3327
3328 ctk_widget_get_preferred_size (widget, NULL((void*)0), &widget_request);
3329 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "terminal widget requests %dx%d px\n",do { if (0) g_printerr("terminal widget requests %dx%d px\n",
widget_request.width, widget_request.height); } while (0)
3330 widget_request.width, widget_request.height)do { if (0) g_printerr("terminal widget requests %dx%d px\n",
widget_request.width, widget_request.height); } while (0)
;
3331
3332 if (char_width != priv->old_char_width ||
3333 char_height != priv->old_char_height ||
3334 padding.left + padding.right != priv->old_padding_width ||
3335 padding.top + padding.bottom != priv->old_padding_height ||
3336 chrome_width != priv->old_chrome_width ||
3337 chrome_height != priv->old_chrome_height ||
3338 widget != CTK_WIDGET (priv->old_geometry_widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->old_geometry_widget)), ((ctk_widget_get_type ()
))))))
)
3339 {
3340 hints.base_width = chrome_width;
3341 hints.base_height = chrome_height;
3342
3343#define MIN_WIDTH_CHARS4 4
3344#define MIN_HEIGHT_CHARS1 1
3345
3346 hints.width_inc = char_width;
3347 hints.height_inc = char_height;
3348
3349 /* min size is min size of the whole window, remember. */
3350 hints.min_width = hints.base_width + hints.width_inc * MIN_WIDTH_CHARS4;
3351 hints.min_height = hints.base_height + hints.height_inc * MIN_HEIGHT_CHARS1;
3352
3353 ctk_window_set_geometry_hints (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3354 NULL((void*)0),
3355 &hints,
3356 CDK_HINT_RESIZE_INC |
3357 CDK_HINT_MIN_SIZE |
3358 CDK_HINT_BASE_SIZE);
3359
3360 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3361 "[window %p] hints: base %dx%d min %dx%d inc %d %d\n",do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3362 window,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3363 hints.base_width,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3364 hints.base_height,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3365 hints.min_width,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3366 hints.min_height,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3367 hints.width_inc,do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
3368 hints.height_inc)do { if (0) g_printerr("[window %p] hints: base %dx%d min %dx%d inc %d %d\n"
, window, hints.base_width, hints.base_height, hints.min_width
, hints.min_height, hints.width_inc, hints.height_inc); } while
(0)
;
3369
3370 priv->old_geometry_widget = widget;
3371 }
3372 else
3373 {
3374 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
3375 "[window %p] hints: increment unchanged, not setting\n",do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
3376 window)do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
;
3377 }
3378
3379 /* We need these for the size calculation in terminal_window_update_size(),
3380 * so we set them unconditionally. */
3381 priv->old_char_width = char_width;
3382 priv->old_char_height = char_height;
3383 priv->old_chrome_width = chrome_width;
3384 priv->old_chrome_height = chrome_height;
3385 priv->old_padding_width = padding.left + padding.right;
3386 priv->old_padding_height = padding.top + padding.bottom;
3387}
3388
3389static void
3390file_new_window_callback (CtkAction *action,
3391 TerminalWindow *window)
3392{
3393 TerminalWindowPrivate *priv = window->priv;
3394 TerminalApp *app;
3395 TerminalWindow *new_window;
3396 TerminalProfile *profile;
3397 char *new_working_directory;
3398
3399 app = terminal_app_get ();
3400
3401 profile = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, PROFILE_DATA_KEY"GT::Profile");
3402 if (!profile)
3403 profile = terminal_screen_get_profile (priv->active_screen);
3404 if (!profile)
3405 profile = terminal_app_get_profile_for_new_term (app);
3406 if (!profile)
3407 return;
3408
3409 if (_terminal_profile_get_forgotten (profile))
3410 return;
3411
3412 new_window = terminal_app_new_window (app, ctk_widget_get_screen (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
));
3413
3414 new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
3415 terminal_app_new_terminal (app, new_window, profile,
3416 NULL((void*)0), NULL((void*)0),
3417 new_working_directory,
3418 terminal_screen_get_initial_environment (priv->active_screen),
3419 1.0);
3420 g_free (new_working_directory);
3421
3422 ctk_window_present (CTK_WINDOW (new_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((ctk_window_get_type ()))))))
);
3423}
3424
3425static void
3426file_new_tab_callback (CtkAction *action,
3427 TerminalWindow *window)
3428{
3429 TerminalWindowPrivate *priv = window->priv;
3430 TerminalApp *app;
3431 TerminalProfile *profile;
3432 char *new_working_directory;
3433
3434 app = terminal_app_get ();
3435 profile = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, PROFILE_DATA_KEY"GT::Profile");
3436 if (!profile)
3437 profile = terminal_screen_get_profile (priv->active_screen);
3438 if (!profile)
3439 profile = terminal_app_get_profile_for_new_term (app);
3440 if (!profile)
3441 return;
3442
3443 if (_terminal_profile_get_forgotten (profile))
3444 return;
3445
3446 new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
3447 terminal_app_new_terminal (app, window, profile,
3448 NULL((void*)0), NULL((void*)0),
3449 new_working_directory,
3450 terminal_screen_get_initial_environment (priv->active_screen),
3451 1.0);
3452 g_free (new_working_directory);
3453}
3454
3455static void
3456confirm_close_response_cb (CtkWidget *dialog,
3457 int response,
3458 TerminalWindow *window)
3459{
3460 TerminalScreen *screen;
3461
3462 screen = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "close-screen");
3463
3464 ctk_widget_destroy (dialog);
3465
3466 if (response != CTK_RESPONSE_ACCEPT)
3467 return;
3468
3469 if (screen)
3470 terminal_window_remove_screen (window, screen);
3471 else
3472 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3473}
3474
3475/* Returns: TRUE if closing needs to wait until user confirmation;
3476 * FALSE if the terminal or window can close immediately.
3477 */
3478static gboolean
3479confirm_close_window_or_tab (TerminalWindow *window,
3480 TerminalScreen *screen)
3481{
3482 TerminalWindowPrivate *priv = window->priv;
3483 CtkWidget *dialog;
3484 gboolean do_confirm;
3485 gboolean has_processes;
2
'has_processes' declared without an initial value
3486 int n_tabs;
3487 char *confirm_msg;
3488
3489 if (priv->confirm_close_dialog)
3
Assuming field 'confirm_close_dialog' is null
4
Taking false branch
3490 {
3491 /* WTF, already have one? It's modal, so how did that happen? */
3492 ctk_dialog_response (CTK_DIALOG (priv->confirm_close_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->confirm_close_dialog)), ((ctk_dialog_get_type (
)))))))
,
3493 CTK_RESPONSE_DELETE_EVENT);
3494 }
3495
3496 do_confirm = g_settings_get_boolean (settings_global, "confirm-window-close");
3497
3498 if (!do_confirm)
5
Assuming 'do_confirm' is not equal to 0
6
Taking false branch
3499 return FALSE(0);
3500
3501 if (screen
6.1
'screen' is null
)
7
Taking false branch
3502 {
3503 has_processes = terminal_screen_has_foreground_process (screen);
3504 n_tabs = 1;
3505 }
3506 else
3507 {
3508 GList *tabs, *t;
3509
3510 tabs = terminal_window_list_screen_containers (window);
3511 n_tabs = g_list_length (tabs);
3512
3513 for (t = tabs; t != NULL((void*)0); t = t->next)
8
Assuming 't' is equal to NULL
9
Loop condition is false. Execution continues on line 3522
3514 {
3515 TerminalScreen *terminal_screen;
3516
3517 terminal_screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (t->data)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((t->data)), ((terminal_screen_container_get_type
()))))))
);
3518 has_processes = terminal_screen_has_foreground_process (terminal_screen);
3519 if (has_processes)
3520 break;
3521 }
3522 g_list_free (tabs);
3523 }
3524
3525
3526 if (has_processes)
10
Branch condition evaluates to a garbage value
3527 {
3528 if (n_tabs > 1)
3529 confirm_msg = _("There are still processes running in some terminals in this window. "gettext ("There are still processes running in some terminals in this window. "
"Closing the window will kill all of them.")
3530 "Closing the window will kill all of them.")gettext ("There are still processes running in some terminals in this window. "
"Closing the window will kill all of them.")
;
3531 else
3532 confirm_msg = _("There is still a process running in this terminal. "gettext ("There is still a process running in this terminal. "
"Closing the terminal will kill it.")
3533 "Closing the terminal will kill it.")gettext ("There is still a process running in this terminal. "
"Closing the terminal will kill it.")
;
3534 } else if (n_tabs > 1)
3535 confirm_msg = _("There are multiple tabs open in this window.")gettext ("There are multiple tabs open in this window.");
3536 else
3537 return FALSE(0);
3538
3539 dialog = priv->confirm_close_dialog =
3540 ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3541 CTK_DIALOG_MODAL | CTK_DIALOG_DESTROY_WITH_PARENT,
3542 CTK_MESSAGE_WARNING,
3543 CTK_BUTTONS_CANCEL,
3544 "%s", n_tabs > 1 ? _("Close this window?")gettext ("Close this window?") : _("Close this terminal?")gettext ("Close this terminal?"));
3545
3546 ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ())
)))))
,
3547 "%s", confirm_msg);
3548
3549 ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, "");
3550
3551 ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, n_tabs > 1 ? _("C_lose Window")gettext ("C_lose Window") : _("C_lose Terminal")gettext ("C_lose Terminal"), CTK_RESPONSE_ACCEPT);
3552 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_ACCEPT);
3553
3554 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "close-screen", screen);
3555
3556 g_signal_connect (dialog, "destroy",g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->confirm_close_dialog)
, ((void*)0), (GConnectFlags) 0)
3557 G_CALLBACK (ctk_widget_destroyed), &priv->confirm_close_dialog)g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->confirm_close_dialog)
, ((void*)0), (GConnectFlags) 0)
;
3558 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
confirm_close_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3559 G_CALLBACK (confirm_close_response_cb), window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
confirm_close_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3560
3561 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
3562
3563 return TRUE(!(0));
3564}
3565
3566static void
3567file_close_window_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3568 TerminalWindow *window)
3569{
3570 if (confirm_close_window_or_tab (window, NULL((void*)0)))
1
Calling 'confirm_close_window_or_tab'
3571 return;
3572
3573 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3574}
3575
3576static void
3577save_contents_dialog_on_response (CtkDialog *dialog, gint response_id, gpointer terminal)
3578{
3579 CtkWindow *parent;
3580 gchar *filename_uri = NULL((void*)0);
3581 GFile *file;
3582 GOutputStream *stream;
3583 GError *error = NULL((void*)0);
3584
3585 if (response_id != CTK_RESPONSE_ACCEPT)
3586 {
3587 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
3588 return;
3589 }
3590
3591 parent = (CtkWindow*) ctk_widget_get_ancestor (CTK_WIDGET (terminal)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((terminal)), ((ctk_widget_get_type ()))))))
, CTK_TYPE_WINDOW(ctk_window_get_type ()));
3592 filename_uri = ctk_file_chooser_get_uri (CTK_FILE_CHOOSER (dialog)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_file_chooser_get_type ()))))))
);
3593
3594 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
3595
3596 if (filename_uri == NULL((void*)0))
3597 return;
3598
3599 file = g_file_new_for_uri (filename_uri);
3600 stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), &error))), ((g_output_stream_get_type ())))
)))
;
3601
3602 if (stream)
3603 {
3604 /* FIXME
3605 * Should be replaced with the async version when bte implements that.
3606 */
3607 bte_terminal_write_contents_sync (terminal, stream,
3608 BTE_WRITE_DEFAULT,
3609 NULL((void*)0), &error);
3610 g_object_unref (stream);
3611 }
3612
3613 if (error)
3614 {
3615 terminal_util_show_error_dialog (parent, NULL((void*)0), error,
3616 "%s", _("Could not save contents")gettext ("Could not save contents"));
3617 g_error_free (error);
3618 }
3619
3620 g_object_unref(file);
3621 g_free(filename_uri);
3622}
3623
3624static void
3625file_save_contents_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3626 TerminalWindow *window)
3627{
3628 CtkWidget *dialog = NULL((void*)0);
3629 TerminalWindowPrivate *priv = window->priv;
3630 BteTerminal *terminal;
3631
3632 if (!priv->active_screen)
3633 return;
3634
3635 terminal = BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
;
3636 g_return_if_fail (BTE_IS_TERMINAL (terminal))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((terminal)); GType __t = ((bte_terminal_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "BTE_IS_TERMINAL (terminal)"); return; } } while
(0)
;
3637
3638 dialog = ctk_file_chooser_dialog_new (_("Save as...")gettext ("Save as..."),
3639 CTK_WINDOW(window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3640 CTK_FILE_CHOOSER_ACTION_SAVE,
3641 "ctk-cancel", CTK_RESPONSE_CANCEL,
3642 "ctk-save", CTK_RESPONSE_ACCEPT,
3643 NULL((void*)0));
3644
3645 ctk_file_chooser_set_do_overwrite_confirmation (CTK_FILE_CHOOSER (dialog)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_file_chooser_get_type ()))))))
, TRUE(!(0)));
3646 /* XXX where should we save to? */
3647 ctk_file_chooser_set_current_folder (CTK_FILE_CHOOSER (dialog)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_file_chooser_get_type ()))))))
, g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
3648
3649 ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, CTK_WINDOW(window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3650 ctk_window_set_modal (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
3651 ctk_window_set_destroy_with_parent (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
3652
3653 g_signal_connect (dialog, "response", G_CALLBACK (save_contents_dialog_on_response), terminal)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
save_contents_dialog_on_response))), (terminal), ((void*)0), (
GConnectFlags) 0)
;
3654 g_signal_connect (dialog, "delete_event", G_CALLBACK (terminal_util_dialog_response_on_delete), NULL)g_signal_connect_data ((dialog), ("delete_event"), (((GCallback
) (terminal_util_dialog_response_on_delete))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
3655
3656 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
3657}
3658
3659static void
3660file_close_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3661 TerminalWindow *window)
3662{
3663 TerminalWindowPrivate *priv = window->priv;
3664 TerminalScreen *active_screen = priv->active_screen;
3665
3666 if (!active_screen)
3667 return;
3668
3669 if (confirm_close_window_or_tab (window, active_screen))
3670 return;
3671
3672 terminal_window_remove_screen (window, active_screen);
3673}
3674
3675static void
3676edit_copy_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3677 TerminalWindow *window)
3678{
3679 TerminalWindowPrivate *priv = window->priv;
3680
3681 if (!priv->active_screen)
3682 return;
3683
3684 bte_terminal_copy_clipboard_format (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
, BTE_FORMAT_TEXT);
3685}
3686
3687typedef struct
3688{
3689 TerminalScreen *screen;
3690 gboolean uris_as_paths;
3691} PasteData;
3692
3693static void
3694clipboard_uris_received_cb (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)),
3695 /* const */ char **uris,
3696 PasteData *data)
3697{
3698 char *text;
3699 gsize len;
3700
3701 if (!uris)
3702 {
3703 g_object_unref (data->screen);
3704 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3705 return;
3706 }
3707
3708 /* This potentially modifies the strings in |uris| but that's ok */
3709 if (data->uris_as_paths)
3710 terminal_util_transform_uris_to_quoted_fuse_paths (uris);
3711
3712 text = terminal_util_concat_uris (uris, &len);
3713 bte_terminal_feed_child (BTE_TERMINAL (data->screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->screen)), ((bte_terminal_get_type()))))))
, text, len);
3714 g_free (text);
3715
3716 g_object_unref (data->screen);
3717 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3718}
3719
3720static void
3721clipboard_targets_received_cb (CtkClipboard *clipboard,
3722 CdkAtom *targets,
3723 int n_targets,
3724 PasteData *data)
3725{
3726 if (!targets)
3727 {
3728 g_object_unref (data->screen);
3729 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3730 return;
3731 }
3732
3733 if (ctk_targets_include_uri (targets, n_targets))
3734 {
3735 ctk_clipboard_request_uris (clipboard,
3736 (CtkClipboardURIReceivedFunc) clipboard_uris_received_cb,
3737 data);
3738 return;
3739 }
3740 else /* if (ctk_targets_include_text (targets, n_targets)) */
3741 {
3742 bte_terminal_paste_clipboard (BTE_TERMINAL (data->screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->screen)), ((bte_terminal_get_type()))))))
);
3743 }
3744
3745 g_object_unref (data->screen);
3746 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3747}
3748
3749static void
3750edit_paste_callback (CtkAction *action,
3751 TerminalWindow *window)
3752{
3753 TerminalWindowPrivate *priv = window->priv;
3754 CtkClipboard *clipboard;
3755 PasteData *data;
3756 const char *name;
3757
3758 if (!priv->active_screen)
3759 return;
3760
3761 clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
, CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))));
3762 name = ctk_action_get_name (action);
3763
3764 data = g_slice_new (PasteData)((PasteData*) g_slice_alloc (sizeof (PasteData)));
3765 data->screen = g_object_ref (priv->active_screen)((__typeof__ (priv->active_screen)) (g_object_ref) (priv->
active_screen))
;
3766 data->uris_as_paths = (name == I_("EditPasteURIPaths")g_intern_static_string ("EditPasteURIPaths") || name == I_("PopupPasteURIPaths")g_intern_static_string ("PopupPasteURIPaths"));
3767
3768 ctk_clipboard_request_targets (clipboard,
3769 (CtkClipboardTargetsReceivedFunc) clipboard_targets_received_cb,
3770 data);
3771}
3772
3773static void
3774edit_select_all_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3775 TerminalWindow *window)
3776{
3777 TerminalWindowPrivate *priv = window->priv;
3778
3779 if (!priv->active_screen)
3780 return;
3781
3782 bte_terminal_select_all (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
);
3783}
3784
3785static void
3786edit_keybindings_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3787 TerminalWindow *window)
3788{
3789 terminal_app_edit_keybindings (terminal_app_get (),
3790 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3791}
3792
3793static void
3794edit_current_profile_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3795 TerminalWindow *window)
3796{
3797 TerminalWindowPrivate *priv = window->priv;
3798
3799 terminal_app_edit_profile (terminal_app_get (),
3800 terminal_screen_get_profile (priv->active_screen),
3801 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3802 NULL((void*)0));
3803}
3804
3805static void
3806file_new_profile_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3807 TerminalWindow *window)
3808{
3809 TerminalWindowPrivate *priv = window->priv;
3810
3811 terminal_app_new_profile (terminal_app_get (),
3812 terminal_screen_get_profile (priv->active_screen),
3813 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3814}
3815
3816static void
3817edit_profiles_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3818 TerminalWindow *window)
3819{
3820 terminal_app_manage_profiles (terminal_app_get (),
3821 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3822}
3823
3824static void
3825view_menubar_toggled_callback (CtkToggleAction *action,
3826 TerminalWindow *window)
3827{
3828 terminal_window_set_menubar_visible (window, ctk_toggle_action_get_active (action));
3829}
3830
3831static void
3832view_fullscreen_toggled_callback (CtkToggleAction *action,
3833 TerminalWindow *window)
3834{
3835 gboolean toggle_action_check;
3836
3837 g_return_if_fail (ctk_widget_get_realized (CTK_WIDGET (window)))do { if ((ctk_widget_get_realized (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((ctk_widget_get_type ()))))))
))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "ctk_widget_get_realized (CTK_WIDGET (window))"
); return; } } while (0)
;
3838
3839 toggle_action_check = ctk_toggle_action_get_active (action);
3840 if (toggle_action_check)
3841 ctk_window_fullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3842 else
3843 ctk_window_unfullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3844}
3845
3846static const double zoom_factors[] =
3847{
3848 TERMINAL_SCALE_MINIMUM((((((double)0.5787037037037)/1.2)/1.2)/1.2)/1.2),
3849 TERMINAL_SCALE_XXXXX_SMALL(((((double)0.5787037037037)/1.2)/1.2)/1.2),
3850 TERMINAL_SCALE_XXXX_SMALL((((double)0.5787037037037)/1.2)/1.2),
3851 TERMINAL_SCALE_XXX_SMALL(((double)0.5787037037037)/1.2),
3852 PANGO_SCALE_XX_SMALL((double)0.5787037037037),
3853 PANGO_SCALE_X_SMALL((double)0.6944444444444),
3854 PANGO_SCALE_SMALL((double)0.8333333333333),
3855 PANGO_SCALE_MEDIUM((double)1.0),
3856 PANGO_SCALE_LARGE((double)1.2),
3857 PANGO_SCALE_X_LARGE((double)1.44),
3858 PANGO_SCALE_XX_LARGE((double)1.728),
3859 TERMINAL_SCALE_XXX_LARGE(((double)1.728)*1.2),
3860 TERMINAL_SCALE_XXXX_LARGE((((double)1.728)*1.2)*1.2),
3861 TERMINAL_SCALE_XXXXX_LARGE(((((double)1.728)*1.2)*1.2)*1.2),
3862 TERMINAL_SCALE_MAXIMUM((((((double)1.728)*1.2)*1.2)*1.2)*1.2)
3863};
3864
3865static gboolean
3866find_larger_zoom_factor (double current,
3867 double *found)
3868{
3869 guint i;
3870
3871 for (i = 0; i < G_N_ELEMENTS (zoom_factors)(sizeof (zoom_factors) / sizeof ((zoom_factors)[0])); ++i)
3872 {
3873 /* Find a font that's larger than this one */
3874 if ((zoom_factors[i] - current) > 1e-6)
3875 {
3876 *found = zoom_factors[i];
3877 return TRUE(!(0));
3878 }
3879 }
3880
3881 return FALSE(0);
3882}
3883
3884static gboolean
3885find_smaller_zoom_factor (double current,
3886 double *found)
3887{
3888 int i;
3889
3890 i = (int) G_N_ELEMENTS (zoom_factors)(sizeof (zoom_factors) / sizeof ((zoom_factors)[0])) - 1;
3891 while (i >= 0)
3892 {
3893 /* Find a font that's smaller than this one */
3894 if ((current - zoom_factors[i]) > 1e-6)
3895 {
3896 *found = zoom_factors[i];
3897 return TRUE(!(0));
3898 }
3899
3900 --i;
3901 }
3902
3903 return FALSE(0);
3904}
3905
3906static void
3907view_zoom_in_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3908 TerminalWindow *window)
3909{
3910 TerminalWindowPrivate *priv = window->priv;
3911 double current;
3912
3913 if (priv->active_screen == NULL((void*)0))
3914 return;
3915
3916 current = terminal_screen_get_font_scale (priv->active_screen);
3917 if (!find_larger_zoom_factor (current, &current))
3918 return;
3919
3920 terminal_screen_set_font_scale (priv->active_screen, current);
3921 terminal_window_update_zoom_sensitivity (window);
3922}
3923
3924static void
3925view_zoom_out_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3926 TerminalWindow *window)
3927{
3928 TerminalWindowPrivate *priv = window->priv;
3929 double current;
3930
3931 if (priv->active_screen == NULL((void*)0))
3932 return;
3933
3934 current = terminal_screen_get_font_scale (priv->active_screen);
3935 if (!find_smaller_zoom_factor (current, &current))
3936 return;
3937
3938 terminal_screen_set_font_scale (priv->active_screen, current);
3939 terminal_window_update_zoom_sensitivity (window);
3940}
3941
3942static void
3943view_zoom_normal_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3944 TerminalWindow *window)
3945{
3946 TerminalWindowPrivate *priv = window->priv;
3947
3948 if (priv->active_screen == NULL((void*)0))
3949 return;
3950
3951 terminal_screen_set_font_scale (priv->active_screen, PANGO_SCALE_MEDIUM((double)1.0));
3952 terminal_window_update_zoom_sensitivity (window);
3953}
3954
3955
3956static void
3957search_find_response_callback (CtkWidget *dialog,
3958 int response,
3959 gpointer user_data)
3960{
3961 TerminalWindow *window = TERMINAL_WINDOW (user_data)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((terminal_window_get_type ()))))))
;
3962 TerminalWindowPrivate *priv = window->priv;
3963 TerminalSearchFlags flags;
3964 BteRegex *regex;
3965
3966 if (response != CTK_RESPONSE_ACCEPT)
3967 return;
3968
3969 if (G_UNLIKELY (!priv->active_screen)(!priv->active_screen))
3970 return;
3971
3972 regex = terminal_search_dialog_get_regex (dialog);
3973 g_return_if_fail (regex != NULL)do { if ((regex != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "regex != NULL");
return; } } while (0)
;
3974
3975 flags = terminal_search_dialog_get_search_flags (dialog);
3976
3977 bte_terminal_search_set_regex (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
, regex, 0);
3978 bte_terminal_search_set_wrap_around (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
,
3979 (flags & TERMINAL_SEARCH_FLAG_WRAP_AROUND));
3980
3981 if (flags & TERMINAL_SEARCH_FLAG_BACKWARDS)
3982 bte_terminal_search_find_previous (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
);
3983 else
3984 bte_terminal_search_find_next (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
);
3985
3986 terminal_window_update_search_sensitivity (priv->active_screen, window);
3987}
3988
3989static gboolean
3990search_dialog_delete_event_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
3991 CdkEventAny *event G_GNUC_UNUSED__attribute__ ((__unused__)),
3992 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
3993{
3994 /* prevent destruction */
3995 return TRUE(!(0));
3996}
3997
3998static void
3999search_find_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4000 TerminalWindow *window)
4001{
4002 TerminalWindowPrivate *priv = window->priv;
4003
4004 if (!priv->search_find_dialog)
4005 {
4006 CtkWidget *dialog;
4007
4008 dialog = priv->search_find_dialog = terminal_search_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
4009
4010 g_signal_connect (dialog, "destroy",g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->search_find_dialog), (
(void*)0), (GConnectFlags) 0)
4011 G_CALLBACK (ctk_widget_destroyed), &priv->search_find_dialog)g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->search_find_dialog), (
(void*)0), (GConnectFlags) 0)
;
4012 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
search_find_response_callback))), (window), ((void*)0), (GConnectFlags
) 0)
4013 G_CALLBACK (search_find_response_callback), window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
search_find_response_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
4014 g_signal_connect (dialog, "delete-event",g_signal_connect_data ((dialog), ("delete-event"), (((GCallback
) (search_dialog_delete_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
4015 G_CALLBACK (search_dialog_delete_event_cb), NULL)g_signal_connect_data ((dialog), ("delete-event"), (((GCallback
) (search_dialog_delete_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
;
4016 }
4017
4018 terminal_search_dialog_present (priv->search_find_dialog);
4019}
4020
4021static void
4022search_find_next_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4023 TerminalWindow *window)
4024{
4025 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4026 return;
4027
4028 bte_terminal_search_find_next (BTE_TERMINAL (window->priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->active_screen)), ((bte_terminal_get_type
()))))))
);
4029}
4030
4031static void
4032search_find_prev_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4033 TerminalWindow *window)
4034{
4035 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4036 return;
4037
4038 bte_terminal_search_find_previous (BTE_TERMINAL (window->priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->active_screen)), ((bte_terminal_get_type
()))))))
);
4039}
4040
4041static void
4042search_clear_highlight_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4043 TerminalWindow *window)
4044{
4045 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4046 return;
4047
4048 bte_terminal_search_set_regex (BTE_TERMINAL (window->priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->active_screen)), ((bte_terminal_get_type
()))))))
, NULL((void*)0), 0);
4049}
4050
4051static void
4052terminal_next_or_previous_profile_cb (CtkAction *action,
4053 TerminalWindow *window)
4054{
4055 TerminalWindowPrivate *priv = window->priv;
4056 TerminalProfile *active_profile, *new_profile = NULL((void*)0);
4057 GList *profiles, *p;
4058
4059 const char *name;
4060 guint backwards = 0;
4061
4062 name = ctk_action_get_name (action);
4063 if (strcmp (name, "ProfilePrevious") == 0)
4064 {
4065 backwards = 1;
4066 }
4067
4068 profiles = terminal_app_get_profile_list (terminal_app_get ());
4069 if (profiles == NULL((void*)0))
4070 return;
4071
4072 if (priv->active_screen)
4073 active_profile = terminal_screen_get_profile (priv->active_screen);
4074 else
4075 return;
4076
4077 for (p = profiles; p != NULL((void*)0); p = p->next)
4078 {
4079 TerminalProfile *profile = (TerminalProfile *) p->data;
4080 if (profile == active_profile)
4081 {
4082 if (backwards) {
4083 p = p->prev;
4084 if (p == NULL((void*)0))
4085 p = g_list_last (profiles);
4086 new_profile = p->data;
4087 break;
4088 }
4089 else
4090 {
4091 p = p->next;
4092 if (p == NULL((void*)0))
4093 p = g_list_first (profiles);
4094 new_profile = p->data;
4095 break;
4096 }
4097 }
4098 }
4099
4100 if (new_profile)
4101 terminal_screen_set_profile (priv->active_screen, new_profile);
4102
4103 g_list_free (profiles);
4104}
4105
4106static void
4107terminal_set_title_dialog_response_cb (CtkWidget *dialog,
4108 int response,
4109 TerminalScreen *screen)
4110{
4111 if (response == CTK_RESPONSE_OK)
4112 {
4113 CtkEntry *entry;
4114 const char *text;
4115
4116 entry = CTK_ENTRY (g_object_get_data (G_OBJECT (dialog), "title-entry"))((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
))))), "title-entry"))), ((ctk_entry_get_type ()))))))
;
4117 text = ctk_entry_get_text (entry);
4118 terminal_screen_set_user_title (screen, text);
4119 }
4120
4121 ctk_widget_destroy (dialog);
4122}
4123
4124static void
4125terminal_set_title_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4126 TerminalWindow *window)
4127{
4128 TerminalWindowPrivate *priv = window->priv;
4129 CtkWidget *dialog, *message_area, *hbox, *label, *entry;
4130
4131 if (priv->active_screen == NULL((void*)0))
4132 return;
4133
4134 /* FIXME: hook the screen up so this dialogue closes if the terminal screen closes */
4135
4136 dialog = ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
4137 CTK_DIALOG_MODAL | CTK_DIALOG_DESTROY_WITH_PARENT,
4138 CTK_MESSAGE_OTHER,
4139 CTK_BUTTONS_OK_CANCEL,
4140 "%s", "");
4141
4142 ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, _("Set Title")gettext ("Set Title"));
4143 ctk_window_set_resizable (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, FALSE(0));
4144 ctk_window_set_role (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, "cafe-terminal-change-title");
4145 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_OK);
4146 /* Alternative button order was set automatically by CtkMessageDialog */
4147
4148 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
terminal_set_title_dialog_response_cb))), (priv->active_screen
), ((void*)0), (GConnectFlags) 0)
4149 G_CALLBACK (terminal_set_title_dialog_response_cb), priv->active_screen)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
terminal_set_title_dialog_response_cb))), (priv->active_screen
), ((void*)0), (GConnectFlags) 0)
;
4150 g_signal_connect (dialog, "delete-event",g_signal_connect_data ((dialog), ("delete-event"), (((GCallback
) (terminal_util_dialog_response_on_delete))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
4151 G_CALLBACK (terminal_util_dialog_response_on_delete), NULL)g_signal_connect_data ((dialog), ("delete-event"), (((GCallback
) (terminal_util_dialog_response_on_delete))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
4152
4153 message_area = ctk_message_dialog_get_message_area (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ())
)))))
);
4154 ctk_container_foreach (CTK_CONTAINER (message_area)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((message_area)), ((ctk_container_get_type ()))))))
, (CtkCallback) ctk_widget_hide, NULL((void*)0));
4155
4156 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
4157 ctk_box_pack_start (CTK_BOX (message_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((message_area)), ((ctk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
4158
4159 label = ctk_label_new_with_mnemonic (_("_Title:")gettext ("_Title:"));
4160 ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, 0.0);
4161 ctk_label_set_yalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, 0.5);
4162 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 0);
4163
4164 entry = ctk_entry_new ();
4165 ctk_entry_set_width_chars (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, 32);
4166 ctk_entry_set_activates_default (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, TRUE(!(0)));
4167 ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, entry);
4168 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, entry, TRUE(!(0)), TRUE(!(0)), 0);
4169 ctk_widget_show_all (hbox);
4170
4171 ctk_widget_grab_focus (entry);
4172 ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, terminal_screen_get_raw_title (priv->active_screen));
4173 ctk_editable_select_region (CTK_EDITABLE (entry)((((CtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_editable_get_type ()))))))
, 0, -1);
4174 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "title-entry", entry);
4175
4176 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
4177}
4178
4179static void
4180terminal_add_encoding_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4181 TerminalWindow *window)
4182{
4183 terminal_app_edit_encodings (terminal_app_get (),
4184 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
4185}
4186
4187static void
4188terminal_reset_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4189 TerminalWindow *window)
4190{
4191 TerminalWindowPrivate *priv = window->priv;
4192
4193 if (priv->active_screen == NULL((void*)0))
4194 return;
4195
4196 bte_terminal_reset (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
, TRUE(!(0)), FALSE(0));
4197}
4198
4199static void
4200terminal_reset_clear_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4201 TerminalWindow *window)
4202{
4203 TerminalWindowPrivate *priv = window->priv;
4204
4205 if (priv->active_screen == NULL((void*)0))
4206 return;
4207
4208 bte_terminal_reset (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
, TRUE(!(0)), TRUE(!(0)));
4209}
4210
4211static void
4212tabs_next_or_previous_tab_cb (CtkAction *action,
4213 TerminalWindow *window)
4214{
4215 TerminalWindowPrivate *priv = window->priv;
4216 CtkNotebookClass *klass;
4217 const char *name;
4218 guint keyval = 0;
4219
4220 name = ctk_action_get_name (action);
4221 if (strcmp (name, "TabsNext") == 0)
4222 {
4223 keyval = CDK_KEY_Page_Down0xff56;
4224 }
4225 else if (strcmp (name, "TabsPrevious") == 0)
4226 {
4227 keyval = CDK_KEY_Page_Up0xff55;
4228 }
4229
4230 klass = CTK_NOTEBOOK_GET_CLASS (CTK_NOTEBOOK (priv->notebook))((((CtkNotebookClass*) (((GTypeInstance*) ((((((CtkNotebook*)
(void *) g_type_check_instance_cast ((GTypeInstance*) ((priv
->notebook)), ((ctk_notebook_get_type ())))))))))->g_class
))))
;
4231 ctk_binding_set_activate (ctk_binding_set_by_class (klass),
4232 keyval,
4233 CDK_CONTROL_MASK,
4234 G_OBJECT (priv->notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), (((GType) ((20) << (2))))))))
);
4235}
4236
4237static void
4238tabs_move_left_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4239 TerminalWindow *window)
4240{
4241 TerminalWindowPrivate *priv = window->priv;
4242 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
4243 gint page_num,last_page;
4244 CtkWidget *page;
4245
4246 page_num = ctk_notebook_get_current_page (notebook);
4247 last_page = ctk_notebook_get_n_pages (notebook) - 1;
4248 page = ctk_notebook_get_nth_page (notebook, page_num);
4249
4250 ctk_notebook_reorder_child (notebook, page, page_num == 0 ? last_page : page_num - 1);
4251}
4252
4253static void
4254tabs_move_right_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4255 TerminalWindow *window)
4256{
4257 TerminalWindowPrivate *priv = window->priv;
4258 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
4259 gint page_num,last_page;
4260 CtkWidget *page;
4261
4262 page_num = ctk_notebook_get_current_page (notebook);
4263 last_page = ctk_notebook_get_n_pages (notebook) - 1;
4264 page = ctk_notebook_get_nth_page (notebook, page_num);
4265
4266 ctk_notebook_reorder_child (notebook, page, page_num == last_page ? 0 : page_num + 1);
4267}
4268
4269static void
4270tabs_detach_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4271 TerminalWindow *window)
4272{
4273 TerminalWindowPrivate *priv = window->priv;
4274 TerminalApp *app;
4275 TerminalWindow *new_window;
4276 TerminalScreen *screen;
4277
4278 app = terminal_app_get ();
4279
4280 screen = priv->active_screen;
4281
4282 new_window = terminal_app_new_window (app, ctk_widget_get_screen (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
));
4283
4284 terminal_window_move_screen (window, new_window, screen, -1);
4285
4286 /* FIXME: this seems wrong if tabs are shown in the window */
4287 terminal_window_update_size (new_window, screen, FALSE(0));
4288
4289 ctk_window_present_with_time (CTK_WINDOW (new_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((ctk_window_get_type ()))))))
, ctk_get_current_event_time ());
4290}
4291
4292static void
4293help_contents_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4294 TerminalWindow *window)
4295{
4296 terminal_util_show_help (NULL((void*)0), CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
4297}
4298
4299#define ABOUT_GROUP"About" "About"
4300#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
4301
4302static void
4303help_about_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4304 TerminalWindow *window)
4305{
4306 char *licence_text;
4307 GBytes *bytes;
4308 const guint8 *data;
4309 GKeyFile *key_file;
4310 GError *error = NULL((void*)0);
4311 char **authors, **contributors, **artists, **documenters, **array_strv;
4312 gchar *comments = NULL((void*)0);
4313 gsize data_len, n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i;
4314 GPtrArray *array;
4315
4316
4317 bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX"/org/cafe/terminal" G_DIR_SEPARATOR_S"/" "ui/terminal.about",
4318 G_RESOURCE_LOOKUP_FLAGS_NONE,
4319 &error);
4320 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 4320, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
4321
4322 data = g_bytes_get_data (bytes, &data_len);
4323 key_file = g_key_file_new ();
4324 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
4325 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 4325, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
4326
4327 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
4328 contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Contributors", &n_contributors, NULL((void*)0));
4329 artists = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Artists", &n_artists, NULL((void*)0));
4330 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
4331 g_key_file_free (key_file);
4332 g_bytes_unref (bytes);
4333
4334 array = g_ptr_array_new ();
4335
4336 for (i = 0; i < n_authors; ++i)
4337 g_ptr_array_add (array, EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@')));
4338 g_free (authors); /* strings are now owned by the array */
4339
4340 if (n_contributors > 0)
4341 {
4342 g_ptr_array_add (array, g_strdup ("")g_strdup_inline (""));
4343 g_ptr_array_add (array, g_strdup (_("Contributors:"))g_strdup_inline (gettext ("Contributors:")));
4344 for (i = 0; i < n_contributors; ++i)
4345 g_ptr_array_add (array, EMAILIFY (contributors[i])(g_strdelimit ((contributors[i]), "%", '@')));
4346 }
4347 g_free (contributors); /* strings are now owned by the array */
4348
4349 g_ptr_array_add (array, NULL((void*)0));
4350 array_strv = (char **) g_ptr_array_free (array, FALSE(0));
4351
4352 for (i = 0; i < n_artists; ++i)
4353 artists[i] = EMAILIFY (artists[i])(g_strdelimit ((artists[i]), "%", '@'));
4354 for (i = 0; i < n_documenters; ++i)
4355 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
4356
4357 licence_text = terminal_util_get_licence_text ();
4358
4359 comments = g_strdup_printf (_("A terminal emulator for the CAFE desktop\nUsing CTK %d.%d.%d\nand BTE %d.%d.%d")gettext ("A terminal emulator for the CAFE desktop\nUsing CTK %d.%d.%d\nand BTE %d.%d.%d"
)
,
4360 ctk_get_major_version (), ctk_get_minor_version (), ctk_get_micro_version (),
4361 bte_get_major_version (), bte_get_minor_version (), bte_get_micro_version ());
4362
4363 ctk_show_about_dialog (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
4364 "program-name", _("CAFE Terminal")gettext ("CAFE Terminal"),
4365 "version", VERSION"1.25.1",
4366 "title", _("About CAFE Terminal")gettext ("About CAFE Terminal"),
4367 "copyright", _("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4368 "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4369 "Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4370 "Copyright \xc2\xa9 2007–2010 Christian Persch\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4371 "Copyright \xc2\xa9 2011 Perberos\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4372 "Copyright \xc2\xa9 2012-2020 MATE developers\n"gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
4373 "Copyright \xc2\xa9 2020-2026 Pablo Barciela")gettext ("Copyright \xc2\xa9 2002–2004 Havoc Pennington\n" "Copyright \xc2\xa9 2003–2004, 2007 Mariano Suárez-Alvarez\n"
"Copyright \xc2\xa9 2006 Guilherme de S. Pastore\n" "Copyright \xc2\xa9 2007–2010 Christian Persch\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n"
"Copyright \xc2\xa9 2020-2026 Pablo Barciela")
,
4374 "comments", comments,
4375 "authors", array_strv,
4376 "artists", artists,
4377 "documenters", documenters,
4378 "license", licence_text,
4379 "wrap-license", TRUE(!(0)),
4380 "translator-credits", _("translator-credits")gettext ("translator-credits"),
4381 "logo-icon-name", CAFE_TERMINAL_ICON_NAME"utilities-terminal",
4382 "website", "https://cafe-desktop.org",
4383 NULL((void*)0));
4384
4385 g_free (comments);
4386 g_strfreev (array_strv);
4387 g_strfreev (artists);
4388 g_strfreev (documenters);
4389 g_free (licence_text);
4390}
4391
4392CtkUIManager *
4393terminal_window_get_ui_manager (TerminalWindow *window)
4394{
4395 TerminalWindowPrivate *priv = window->priv;
4396
4397 return priv->ui_manager;
4398}
4399
4400void
4401terminal_window_save_state (TerminalWindow *window,
4402 GKeyFile *key_file,
4403 const char *group)
4404{
4405 TerminalWindowPrivate *priv = window->priv;
4406 GList *tabs, *lt;
4407 TerminalScreen *active_screen;
4408 CdkWindowState state;
4409 GPtrArray *tab_names_array;
4410 char **tab_names;
4411 gsize len;
4412
4413 //XXXif (priv->menub)//XXX
4414 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_MENUBAR_VISIBLE"MenubarVisible",
4415 priv->menubar_visible);
4416
4417 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_ROLE"Role",
4418 ctk_window_get_role (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
));
4419
4420 state = cdk_window_get_state (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
));
4421 if (state & CDK_WINDOW_STATE_MAXIMIZED)
4422 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_MAXIMIZED"Maximized", TRUE(!(0)));
4423 if (state & CDK_WINDOW_STATE_FULLSCREEN)
4424 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_FULLSCREEN"Fullscreen", TRUE(!(0)));
4425
4426 active_screen = terminal_window_get_active (window);
4427 tabs = terminal_window_list_screen_containers (window);
4428
4429 tab_names_array = g_ptr_array_sized_new (g_list_length (tabs) + 1);
4430
4431 for (lt = tabs; lt != NULL((void*)0); lt = lt->next)
4432 {
4433 TerminalScreen *screen;
4434 char *tab_group;
4435
4436 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (lt->data)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((lt->data)), ((terminal_screen_container_get_type
()))))))
);
4437
4438 tab_group = g_strdup_printf ("Terminal%p", screen);
4439 g_ptr_array_add (tab_names_array, tab_group);
4440
4441 terminal_screen_save_config (screen, key_file, tab_group);
4442
4443 if (screen == active_screen)
4444 {
4445 int w, h, x, y;
4446 char *geometry;
4447
4448 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_ACTIVE_TAB"ActiveTerminal", tab_group);
4449
4450 /* FIXME saving the geometry is not great :-/ */
4451 terminal_screen_get_size (screen, &w, &h);
4452 ctk_window_get_position (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, &x, &y);
4453 geometry = g_strdup_printf ("%dx%d+%d+%d", w, h, x, y);
4454 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_GEOMETRY"Geometry", geometry);
4455 g_free (geometry);
4456 }
4457 }
4458
4459 g_list_free (tabs);
4460
4461 len = tab_names_array->len;
4462 g_ptr_array_add (tab_names_array, NULL((void*)0));
4463 tab_names = (char **) g_ptr_array_free (tab_names_array, FALSE(0));
4464 g_key_file_set_string_list (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_TABS"Terminals", (const char * const *) tab_names, len);
4465 g_strfreev (tab_names);
4466}
4467
4468
4469TerminalWindow *
4470terminal_window_get_latest_focused (TerminalWindow *window1,
4471 TerminalWindow *window2)
4472{
4473 TerminalWindowPrivate *priv1 = NULL((void*)0);
4474 TerminalWindowPrivate *priv2 = NULL((void*)0);
4475
4476 if (!window1)
4477 return window2;
4478
4479 if (!window2)
4480 return window1;
4481
4482 priv1 = window1->priv;
4483 priv2 = window2->priv;
4484
4485 if (priv2->focus_time > priv1->focus_time)
4486 return window2;
4487
4488 return window1;
4489}