Bug Summary

File:terminal-window.c
Warning:line 3523, 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/glycin-2 -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-02-23-221244-19215-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 /* Load the UI */
2213 error = NULL((void*)0);
2214 priv->ui_id = ctk_ui_manager_add_ui_from_resource (manager,
2215 TERMINAL_RESOURCES_PATH_PREFIX"/org/cafe/terminal" G_DIR_SEPARATOR_S"/" "ui/terminal.xml",
2216 &error);
2217 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 2217, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2218
2219 priv->menubar = ctk_ui_manager_get_widget (manager, "/menubar");
2220 ctk_box_pack_start (CTK_BOX (priv->main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->main_vbox)), ((ctk_box_get_type ()))))))
,
2221 priv->menubar,
2222 FALSE(0), FALSE(0), 0);
2223
2224 /* Add tabs menu */
2225 priv->tabs_menu = terminal_tabs_menu_new (window);
2226
2227 app = terminal_app_get ();
2228 terminal_window_profile_list_changed_cb (app, window);
2229 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)
2230 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)
;
2231
2232 terminal_window_encoding_list_changed_cb (app, window);
2233 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)
2234 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)
;
2235
2236 terminal_window_set_menubar_visible (window, TRUE(!(0)));
2237 priv->use_default_menubar_visibility = TRUE(!(0));
2238
2239 terminal_window_update_size_to_menu (window);
2240
2241 /* We have to explicitly call this, since screen-changed is NOT
2242 * emitted for the toplevel the first time!
2243 */
2244 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 ()))))))
));
2245
2246 window_group = ctk_window_group_new ();
2247 ctk_window_group_add_window (window_group, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
2248 g_object_unref (window_group);
2249
2250 terminal_util_set_unique_role (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, "cafe-terminal-window");
2251}
2252
2253static void
2254terminal_window_class_init (TerminalWindowClass *klass)
2255{
2256 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2257 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
2258
2259 object_class->dispose = terminal_window_dispose;
2260 object_class->finalize = terminal_window_finalize;
2261
2262 widget_class->show = terminal_window_show;
2263 widget_class->realize = terminal_window_realize;
2264 widget_class->map_event = terminal_window_map_event;
2265 widget_class->window_state_event = terminal_window_state_event;
2266 widget_class->screen_changed = terminal_window_screen_changed;
2267}
2268
2269static void
2270terminal_window_dispose (GObject *object)
2271{
2272 TerminalWindow *window = TERMINAL_WINDOW (object)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((terminal_window_get_type ()))))))
;
2273 TerminalWindowPrivate *priv = window->priv;
2274 TerminalApp *app;
2275 CtkClipboard *clipboard;
2276#ifdef CDK_WINDOWING_X11
2277 CdkScreen *screen;
2278#endif
2279
2280 remove_popup_info (window);
2281
2282 priv->disposed = TRUE(!(0));
2283
2284 if (priv->tabs_menu)
2285 {
2286 g_object_unref (priv->tabs_menu);
2287 priv->tabs_menu = NULL((void*)0);
2288 }
2289
2290 if (priv->profiles_action_group != NULL((void*)0))
2291 disconnect_profiles_from_actions_in_group (priv->profiles_action_group);
2292 if (priv->new_terminal_action_group != NULL((void*)0))
2293 disconnect_profiles_from_actions_in_group (priv->new_terminal_action_group);
2294
2295 app = terminal_app_get ();
2296 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))
2297 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))
2298 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))
;
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_encoding_list_changed_cb))
), (window))
2300 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))
2301 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))
;
2302 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))));
2303 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))
2304 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))
2305 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))
;
2306
2307#ifdef CDK_WINDOWING_X11
2308 screen = ctk_widget_get_screen (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
);
2309 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; }))))
)
2310 {
2311 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))
2312 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))
2313 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))
;
2314 }
2315#endif
2316
2317 G_OBJECT_CLASS (terminal_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose (object);
2318}
2319
2320static void
2321terminal_window_finalize (GObject *object)
2322{
2323 TerminalWindow *window = TERMINAL_WINDOW (object)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((terminal_window_get_type ()))))))
;
2324 TerminalWindowPrivate *priv = window->priv;
2325
2326 g_object_unref (priv->ui_manager);
2327
2328 if (priv->confirm_close_dialog)
2329 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 (
)))))))
,
2330 CTK_RESPONSE_DELETE_EVENT);
2331
2332 if (priv->search_find_dialog)
2333 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 ())
)))))
,
2334 CTK_RESPONSE_DELETE_EVENT);
2335
2336 G_OBJECT_CLASS (terminal_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((terminal_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
2337}
2338
2339static gboolean
2340terminal_window_delete_event (CtkWidget *widget,
2341 CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)),
2342 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
2343{
2344 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));
2345}
2346
2347static gboolean
2348terminal_window_focus_in_event (CtkWidget *widget,
2349 CdkEventFocus *event,
2350 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
2351{
2352 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2353 TerminalWindowPrivate *priv = window->priv;
2354
2355 if (event->in)
2356 priv->focus_time = time(NULL((void*)0));
2357
2358 return FALSE(0);
2359}
2360
2361static void
2362terminal_window_show (CtkWidget *widget)
2363{
2364 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2365 CtkAllocation widget_allocation;
2366
2367 ctk_widget_get_allocation (widget, &widget_allocation);
2368
2369 TerminalWindowPrivate *priv = window->priv;
2370
2371 if (priv->active_screen != NULL((void*)0))
2372 {
2373 terminal_window_update_copy_selection (priv->active_screen, window);
2374#if 0
2375 /* At this point, we have our CdkScreen, and hence the right
2376 * font size, so we can go ahead and size the window. */
2377 terminal_window_update_size (window, priv->active_screen, FALSE(0));
2378#endif
2379 }
2380
2381 terminal_window_update_geometry (window);
2382
2383 _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)
2384 "[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)
2385 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)
2386 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)
2387 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)
;
2388
2389 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);
2390}
2391
2392TerminalWindow*
2393terminal_window_new (void)
2394{
2395 return g_object_new (TERMINAL_TYPE_WINDOW(terminal_window_get_type ()), NULL((void*)0));
2396}
2397
2398/**
2399 * terminal_window_set_is_restored:
2400 * @window:
2401 *
2402 * Marks the window as restored from session.
2403 */
2404void
2405terminal_window_set_is_restored (TerminalWindow *window)
2406{
2407 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)
;
2408 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)
;
2409
2410 window->priv->clear_demands_attention = TRUE(!(0));
2411}
2412
2413static void
2414profile_set_callback (TerminalScreen *screen,
2415 TerminalProfile *old_profile G_GNUC_UNUSED__attribute__ ((__unused__)),
2416 TerminalWindow *window)
2417{
2418 TerminalWindowPrivate *priv = window->priv;
2419
2420 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2421 return;
2422
2423 if (screen != priv->active_screen)
2424 return;
2425
2426 terminal_window_update_set_profile_menu_active_profile (window);
2427}
2428
2429static void
2430sync_screen_title (TerminalScreen *screen,
2431 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2432 TerminalWindow *window)
2433{
2434 TerminalWindowPrivate *priv = window->priv;
2435
2436 if (screen != priv->active_screen)
2437 return;
2438
2439 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));
2440}
2441
2442static void
2443sync_screen_icon_title (TerminalScreen *screen,
2444 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2445 TerminalWindow *window)
2446{
2447 TerminalWindowPrivate *priv = window->priv;
2448
2449 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2450 return;
2451
2452 if (screen != priv->active_screen)
2453 return;
2454
2455 if (!terminal_screen_get_icon_title_set (screen))
2456 return;
2457
2458 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));
2459
2460 priv->icon_title_set = TRUE(!(0));
2461}
2462
2463static void
2464sync_screen_icon_title_set (TerminalScreen *screen,
2465 GParamSpec *psepc G_GNUC_UNUSED__attribute__ ((__unused__)),
2466 TerminalWindow *window)
2467{
2468 TerminalWindowPrivate *priv = window->priv;
2469
2470 if (!ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2471 return;
2472
2473 /* No need to restore the title if we never set an icon title */
2474 if (!priv->icon_title_set)
2475 return;
2476
2477 if (screen != priv->active_screen)
2478 return;
2479
2480 if (terminal_screen_get_icon_title_set (screen))
2481 return;
2482
2483 /* Need to reset the icon name */
2484 /* FIXME: Once ctk+ bug 535557 is fixed, use that to unset the icon title. */
2485
2486 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))))))))
,
2487 g_quark_from_static_string ("cdk-icon-name-set"),
2488 GUINT_TO_POINTER (FALSE)((gpointer) (gulong) ((0))));
2489 priv->icon_title_set = FALSE(0);
2490
2491 /* Re-setting the right title will be done by the notify::title handler which comes after this one */
2492}
2493
2494/* Notebook callbacks */
2495
2496static void
2497close_button_clicked_cb (CtkWidget *tab_label G_GNUC_UNUSED__attribute__ ((__unused__)),
2498 CtkWidget *screen_container)
2499{
2500 CtkWidget *toplevel;
2501 TerminalWindow *window;
2502 TerminalScreen *screen;
2503
2504 toplevel = ctk_widget_get_toplevel (screen_container);
2505 if (!ctk_widget_is_toplevel (toplevel))
2506 return;
2507
2508 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; }))))
)
2509 return;
2510
2511 window = TERMINAL_WINDOW (toplevel)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((terminal_window_get_type ()))))))
;
2512
2513 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
()))))))
);
2514 if (confirm_close_window_or_tab (window, screen))
2515 return;
2516
2517 terminal_window_remove_screen (window, screen);
2518}
2519
2520void
2521terminal_window_add_screen (TerminalWindow *window,
2522 TerminalScreen *screen,
2523 int position)
2524{
2525 TerminalWindowPrivate *priv = window->priv;
2526 CtkWidget *old_window;
2527 CtkWidget *screen_container, *tab_label;
2528
2529 old_window = ctk_widget_get_toplevel (CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
);
2530 if (ctk_widget_is_toplevel (old_window) &&
2531 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; }))))
&&
2532 TERMINAL_WINDOW (old_window)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((old_window)), ((terminal_window_get_type ()))))))
== window)
2533 return;
2534
2535 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; }))))
)
2536 terminal_window_remove_screen (TERMINAL_WINDOW (old_window)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((old_window)), ((terminal_window_get_type ()))))))
, screen);
2537
2538 screen_container = terminal_screen_container_new (screen);
2539 ctk_widget_show (screen_container);
2540
2541 update_tab_visibility (window, +1);
2542
2543 tab_label = terminal_tab_label_new (screen);
2544 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)
2545 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)
;
2546
2547 ctk_notebook_insert_page (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2548 screen_container,
2549 tab_label,
2550 position);
2551 ctk_container_child_set (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
,
2552 screen_container,
2553 "tab-expand", TRUE(!(0)),
2554 "tab-fill", TRUE(!(0)),
2555 NULL((void*)0));
2556 ctk_notebook_set_tab_reorderable (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2557 screen_container,
2558 TRUE(!(0)));
2559 ctk_notebook_set_tab_detachable (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}
2563
2564void
2565terminal_window_remove_screen (TerminalWindow *window,
2566 TerminalScreen *screen)
2567{
2568 TerminalWindowPrivate *priv = window->priv;
2569 TerminalScreenContainer *screen_container;
2570
2571 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)
;
2572
2573 update_tab_visibility (window, -1);
2574
2575 screen_container = terminal_screen_container_get_from_screen (screen);
2576 if (detach_tab)
2577 {
2578 ctk_notebook_detach_tab (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2579 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2580 detach_tab = FALSE(0);
2581 }
2582 else
2583 ctk_container_remove (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
,
2584 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2585}
2586
2587void
2588terminal_window_move_screen (TerminalWindow *source_window,
2589 TerminalWindow *dest_window,
2590 TerminalScreen *screen,
2591 int dest_position)
2592{
2593 TerminalScreenContainer *screen_container;
2594
2595 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)
;
2596 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)
;
2597 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)
;
2598 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)
;
2599 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)
;
2600
2601 screen_container = terminal_screen_container_get_from_screen (screen);
2602 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"
, 2602, ((const char*) (__func__)), "TERMINAL_IS_SCREEN_CONTAINER (screen_container)"
); } while (0)
;
2603
2604 /* We have to ref the screen container as well as the screen,
2605 * because otherwise removing the screen container from the source
2606 * window's notebook will cause the container and its containing
2607 * screen to be ctk_widget_destroy()ed!
2608 */
2609 g_object_ref_sink (screen_container)((__typeof__ (screen_container)) (g_object_ref_sink) (screen_container
))
;
2610 g_object_ref_sink (screen)((__typeof__ (screen)) (g_object_ref_sink) (screen));
2611
2612 detach_tab = TRUE(!(0));
2613
2614 terminal_window_remove_screen (source_window, screen);
2615
2616 /* Now we can safely remove the screen from the container and let the container die */
2617 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 ()))))))
);
2618 g_object_unref (screen_container);
2619
2620 terminal_window_add_screen (dest_window, screen, dest_position);
2621 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);
2622 g_object_unref (screen);
2623}
2624
2625GList*
2626terminal_window_list_screen_containers (TerminalWindow *window)
2627{
2628 TerminalWindowPrivate *priv = window->priv;
2629
2630 /* We are trusting that CtkNotebook will return pages in order */
2631 return ctk_container_get_children (CTK_CONTAINER (priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_container_get_type ()))))))
);
2632}
2633
2634void
2635terminal_window_set_menubar_visible (TerminalWindow *window,
2636 gboolean setting)
2637{
2638 TerminalWindowPrivate *priv = window->priv;
2639 CtkAction *action;
2640
2641 /* it's been set now, so don't override when adding a screen.
2642 * this side effect must happen before we short-circuit below.
2643 */
2644 priv->use_default_menubar_visibility = FALSE(0);
2645
2646 if (setting == priv->menubar_visible)
2647 return;
2648
2649 priv->menubar_visible = setting;
2650
2651 action = ctk_action_group_get_action (priv->action_group, "ViewMenubar");
2652 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
, setting);
2653
2654 g_object_set (priv->menubar, "visible", setting, NULL((void*)0));
2655
2656 /* FIXMEchpe: use ctk_widget_get_realized instead? */
2657 if (priv->active_screen)
2658 {
2659 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] setting size after toggling menubar visibility\n"
, window); } while (0)
2660 "[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)
2661 window)do { if (0) g_printerr("[window %p] setting size after toggling menubar visibility\n"
, window); } while (0)
;
2662
2663 terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
2664 }
2665}
2666
2667gboolean
2668terminal_window_get_menubar_visible (TerminalWindow *window)
2669{
2670 TerminalWindowPrivate *priv = window->priv;
2671
2672 return priv->menubar_visible;
2673}
2674
2675CtkWidget *
2676terminal_window_get_notebook (TerminalWindow *window)
2677{
2678 TerminalWindowPrivate *priv = window->priv;
2679
2680 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)
;
2681
2682 return CTK_WIDGET (priv->notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_widget_get_type ()))))))
;
2683}
2684
2685void
2686terminal_window_update_size (TerminalWindow *window,
2687 TerminalScreen *screen,
2688 gboolean even_if_mapped)
2689{
2690 terminal_window_update_size_set_geometry (window, screen,
2691 even_if_mapped, NULL((void*)0));
2692}
2693
2694gboolean
2695terminal_window_update_size_set_geometry (TerminalWindow *window,
2696 TerminalScreen *screen,
2697 gboolean even_if_mapped,
2698 gchar *geometry_string)
2699{
2700 TerminalWindowPrivate *priv = window->priv;
2701 CtkWidget *widget;
2702 CtkWidget *app;
2703 gboolean result;
2704 int geom_result;
2705 gint force_pos_x = 0, force_pos_y = 0;
2706 unsigned int force_grid_width = 0, force_grid_height = 0;
2707 int grid_width, grid_height;
2708 gint pixel_width, pixel_height;
2709 CdkWindow *cdk_window;
2710 CdkGravity pos_gravity;
2711
2712 cdk_window = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
2713 result = TRUE(!(0));
2714
2715 if (cdk_window != NULL((void*)0) &&
2716 (cdk_window_get_state (cdk_window) &
2717 (CDK_WINDOW_STATE_MAXIMIZED | CDK_WINDOW_STATE_TILED)))
2718 {
2719 /* Don't adjust the size of maximized or tiled (snapped, half-maximized)
2720 * windows: if we do, there will be ugly gaps of up to 1 character cell
2721 * around otherwise tiled windows. */
2722 return result;
2723 }
2724
2725 /* be sure our geometry is up-to-date */
2726 terminal_window_update_geometry (window);
2727
2728 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; }))))
)
2729 widget = CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
;
2730 else
2731 widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
;
2732
2733 app = ctk_widget_get_toplevel (widget);
2734 g_assert (app != NULL)do { if (app != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "terminal-window.c", 2734, ((const char*) (__func__
)), "app != NULL"); } while (0)
;
2735
2736 terminal_screen_get_size (screen, &grid_width, &grid_height);
2737 if (geometry_string != NULL((void*)0))
2738 {
2739 geom_result = terminal_window_XParseGeometry (geometry_string,
2740 &force_pos_x,
2741 &force_pos_y,
2742 &force_grid_width,
2743 &force_grid_height);
2744 if (geom_result == NoValue0x0000)
2745 result = FALSE(0);
2746 }
2747 else
2748 geom_result = NoValue0x0000;
2749
2750 if ((geom_result & WidthValue0x0004) != 0)
2751 grid_width = force_grid_width;
2752 if ((geom_result & HeightValue0x0008) != 0)
2753 grid_height = force_grid_height;
2754
2755 /* the "old" struct members were updated by update_geometry */
2756 pixel_width = priv->old_chrome_width + grid_width * priv->old_char_width;
2757 pixel_height = priv->old_chrome_height + grid_height * priv->old_char_height;
2758
2759 _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)
2760 "[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)
2761 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)
2762 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)
;
2763
2764 _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)
2765 "[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)
2766 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)
2767 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)
2768 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)
2769 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)
;
2770
2771 pos_gravity = CDK_GRAVITY_NORTH_WEST;
2772 if ((geom_result & XNegative0x0010) != 0 && (geom_result & YNegative0x0020) != 0)
2773 pos_gravity = CDK_GRAVITY_SOUTH_EAST;
2774 else if ((geom_result & XNegative0x0010) != 0)
2775 pos_gravity = CDK_GRAVITY_NORTH_EAST;
2776 else if ((geom_result & YNegative0x0020) != 0)
2777 pos_gravity = CDK_GRAVITY_SOUTH_WEST;
2778
2779 if ((geom_result & XValue0x0001) == 0)
2780 force_pos_x = 0;
2781 if ((geom_result & YValue0x0002) == 0)
2782 force_pos_y = 0;
2783
2784 if (pos_gravity == CDK_GRAVITY_SOUTH_EAST ||
2785 pos_gravity == CDK_GRAVITY_NORTH_EAST)
2786 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)
-
2787 pixel_width + force_pos_x;
2788 if (pos_gravity == CDK_GRAVITY_SOUTH_WEST ||
2789 pos_gravity == CDK_GRAVITY_SOUTH_EAST)
2790 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)
-
2791 pixel_height + force_pos_y;
2792
2793 /* we don't let you put a window offscreen; maybe some people would
2794 * prefer to be able to, but it's kind of a bogus thing to do.
2795 */
2796 if (force_pos_x < 0)
2797 force_pos_x = 0;
2798 if (force_pos_y < 0)
2799 force_pos_y = 0;
2800
2801 if (even_if_mapped && ctk_widget_get_mapped (app))
2802 ctk_window_resize (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, pixel_width, pixel_height);
2803 else
2804 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);
2805
2806 if ((geom_result & XValue0x0001) != 0 || (geom_result & YValue0x0002) != 0)
2807 {
2808 ctk_window_set_gravity (CTK_WINDOW (app)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_window_get_type ()))))))
, pos_gravity);
2809 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);
2810 }
2811
2812 return result;
2813}
2814
2815void
2816terminal_window_switch_screen (TerminalWindow *window,
2817 TerminalScreen *screen)
2818{
2819 TerminalWindowPrivate *priv = window->priv;
2820 TerminalScreenContainer *screen_container;
2821 int page_num;
2822
2823 screen_container = terminal_screen_container_get_from_screen (screen);
2824 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"
, 2824, ((const char*) (__func__)), "TERMINAL_IS_SCREEN_CONTAINER (screen_container)"
); } while (0)
;
2825 page_num = ctk_notebook_page_num (CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
,
2826 CTK_WIDGET (screen_container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen_container)), ((ctk_widget_get_type ()))))))
);
2827 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);
2828}
2829
2830TerminalScreen*
2831terminal_window_get_active (TerminalWindow *window)
2832{
2833 TerminalWindowPrivate *priv = window->priv;
2834
2835 return priv->active_screen;
2836}
2837
2838static gboolean
2839notebook_button_press_cb (CtkWidget *widget,
2840 CdkEventButton *event,
2841 GSettings *settings)
2842{
2843 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
()))))))
;
2844 TerminalWindowPrivate *priv = window->priv;
2845 CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_notebook_get_type ()))))))
;
2846 CtkWidget *tab;
2847 CtkWidget *menu;
2848 CtkAction *action;
2849 int tab_clicked;
2850
2851 if ((event->type == CDK_BUTTON_PRESS && event->button == 2) &&
2852 (g_settings_get_boolean (settings, "middle-click-closes-tabs")))
2853 {
2854 tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
2855 if (tab_clicked >= 0)
2856 {
2857 int page_num;
2858 int before_pages;
2859 int later_pages;
2860
2861 before_pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
2862 page_num = ctk_notebook_get_current_page (notebook);
2863 ctk_notebook_set_current_page (notebook, tab_clicked);
2864 TerminalScreen *active_screen = priv->active_screen;
2865
2866 if (!(confirm_close_window_or_tab (window, active_screen)))
2867 {
2868 update_tab_visibility (window, -1);
2869 ctk_notebook_remove_page(notebook, tab_clicked);
2870 }
2871
2872 later_pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
2873
2874 if (before_pages > later_pages) {
2875 if (tab_clicked > page_num)
2876 ctk_notebook_set_current_page (notebook, page_num);
2877 else if (tab_clicked < page_num)
2878 ctk_notebook_set_current_page (notebook, page_num - 1);
2879 }
2880 else
2881 ctk_notebook_set_current_page (notebook, page_num);
2882
2883 }
2884 }
2885
2886 if (event->type != CDK_BUTTON_PRESS ||
2887 event->button != 3 ||
2888 (event->state & ctk_accelerator_get_default_mod_mask ()) != 0)
2889 return FALSE(0);
2890
2891 tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
2892 if (tab_clicked < 0)
2893 return FALSE(0);
2894
2895 /* switch to the page the mouse is over */
2896 ctk_notebook_set_current_page (notebook, tab_clicked);
2897
2898 action = ctk_action_group_get_action (priv->action_group, "NotebookPopup");
2899 ctk_action_activate (action);
2900
2901 menu = ctk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
2902 if (ctk_menu_get_attach_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
))
2903 ctk_menu_detach (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
);
2904 tab = ctk_notebook_get_nth_page (notebook, tab_clicked);
2905 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));
2906 ctk_menu_popup_at_pointer (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
, NULL((void*)0));
2907
2908 return TRUE(!(0));
2909}
2910
2911static gboolean
2912window_key_press_cb (CtkWidget *widget,
2913 CdkEventKey *event,
2914 GSettings *settings)
2915{
2916 if ((g_settings_get_boolean (settings, "exit-ctrl-d") == FALSE(0)) &&
2917 (event->state & CDK_CONTROL_MASK) && (event->keyval == CDK_KEY_d0x064))
2918 return TRUE(!(0));
2919
2920 if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs") &&
2921 event->state & CDK_CONTROL_MASK)
2922 {
2923 TerminalWindow *window = TERMINAL_WINDOW (widget)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((terminal_window_get_type ()))))))
;
2924 TerminalWindowPrivate *priv = window->priv;
2925 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
2926
2927 int pages = ctk_notebook_get_n_pages (notebook);
2928 int page_num = ctk_notebook_get_current_page (notebook);
2929
2930 if (event->keyval == CDK_KEY_ISO_Left_Tab0xfe20)
2931 {
2932 if (page_num != 0)
2933 ctk_notebook_prev_page (notebook);
2934 else
2935 ctk_notebook_set_current_page (notebook, (pages - 1));
2936 return TRUE(!(0));
2937 }
2938
2939 if (event->keyval == CDK_KEY_Tab0xff09)
2940 {
2941 if (page_num != (pages -1))
2942 ctk_notebook_next_page (notebook);
2943 else
2944 ctk_notebook_set_current_page (notebook, 0);
2945 return TRUE(!(0));
2946 }
2947 }
2948 return FALSE(0);
2949}
2950
2951static gboolean
2952notebook_popup_menu_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
2953 TerminalWindow *window)
2954{
2955 TerminalWindowPrivate *priv = window->priv;
2956 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
2957 CtkWidget *focus_widget, *tab, *tab_label, *menu;
2958 CtkAction *action;
2959 int page_num;
2960
2961 focus_widget = ctk_window_get_focus (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
2962 /* Only respond if the notebook is the actual focus */
2963 if (focus_widget != priv->notebook)
2964 return FALSE(0);
2965
2966 page_num = ctk_notebook_get_current_page (notebook);
2967 tab = ctk_notebook_get_nth_page (notebook, page_num);
2968 tab_label = ctk_notebook_get_tab_label (notebook, tab);
2969
2970 action = ctk_action_group_get_action (priv->action_group, "NotebookPopup");
2971 ctk_action_activate (action);
2972
2973 menu = ctk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
2974 if (ctk_menu_get_attach_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
))
2975 ctk_menu_detach (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
);
2976 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));
2977 ctk_menu_popup_at_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
,
2978 tab_label,
2979 CDK_GRAVITY_SOUTH_WEST,
2980 CDK_GRAVITY_NORTH_WEST,
2981 NULL((void*)0));
2982 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));
2983
2984 return TRUE(!(0));
2985}
2986
2987static void
2988notebook_page_selected_callback (CtkWidget *notebook G_GNUC_UNUSED__attribute__ ((__unused__)),
2989 CtkWidget *page_widget,
2990 guint page_num,
2991 TerminalWindow *window)
2992{
2993 TerminalWindowPrivate *priv = window->priv;
2994 CtkWidget *widget;
2995 TerminalScreen *screen;
2996 int old_grid_width, old_grid_height;
2997
2998 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
2999 "[window %p] MDI: page-selected %d\n",do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
3000 window, page_num)do { if (0) g_printerr("[window %p] MDI: page-selected %d\n",
window, page_num); } while (0)
;
3001
3002 if (priv->disposed)
3003 return;
3004
3005 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
()))))))
);
3006 widget = CTK_WIDGET (screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((ctk_widget_get_type ()))))))
;
3007 g_assert (screen != NULL)do { if (screen != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "terminal-window.c", 3007, ((const char*) (__func__
)), "screen != NULL"); } while (0)
;
3008
3009 _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)
3010 "[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)
3011 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)
;
3012
3013 if (priv->active_screen == screen)
3014 return;
3015
3016 if (priv->active_screen != NULL((void*)0))
3017 {
3018 terminal_screen_get_size (priv->active_screen, &old_grid_width, &old_grid_height);
3019
3020 /* This is so that we maintain the same grid */
3021 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);
3022 }
3023
3024 /* Workaround to remove ctknotebook's feature of computing its size based on
3025 * all pages. When the widget is hidden, its size will not be taken into
3026 * account.
3027 */
3028 if (priv->active_screen)
3029 ctk_widget_hide (CTK_WIDGET (priv->active_screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((ctk_widget_get_type ()))))))
); /* FIXME */
3030
3031 /* Make sure that the widget is no longer hidden due to the workaround */
3032 ctk_widget_show (widget);
3033
3034 priv->active_screen = screen;
3035
3036 /* Override menubar setting if it wasn't restored from session */
3037 if (priv->use_default_menubar_visibility)
3038 {
3039 gboolean setting =
3040 terminal_profile_get_property_boolean (terminal_screen_get_profile (screen), TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR"default-show-menubar");
3041
3042 terminal_window_set_menubar_visible (window, setting);
3043 }
3044
3045 sync_screen_icon_title_set (screen, NULL((void*)0), window);
3046 sync_screen_icon_title (screen, NULL((void*)0), window);
3047 sync_screen_title (screen, NULL((void*)0), window);
3048
3049 /* set size of window to current grid size */
3050 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] setting size after flipping notebook pages\n"
, window); } while (0)
3051 "[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)
3052 window)do { if (0) g_printerr("[window %p] setting size after flipping notebook pages\n"
, window); } while (0)
;
3053 terminal_window_update_size (window, screen, TRUE(!(0)));
3054
3055 terminal_window_update_tabs_menu_sensitivity (window);
3056 terminal_window_update_encoding_menu_active_encoding (window);
3057 terminal_window_update_set_profile_menu_active_profile (window);
3058 terminal_window_update_copy_sensitivity (screen, window);
3059 terminal_window_update_zoom_sensitivity (window);
3060 terminal_window_update_search_sensitivity (screen, window);
3061}
3062
3063static void
3064notebook_page_added_callback (CtkWidget *notebook,
3065 CtkWidget *container,
3066 guint page_num G_GNUC_UNUSED__attribute__ ((__unused__)),
3067 TerminalWindow *window)
3068{
3069 TerminalWindowPrivate *priv = window->priv;
3070 TerminalScreen *screen;
3071 int pages;
3072
3073 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (container)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((container)), ((terminal_screen_container_get_type
()))))))
);
3074
3075 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
3076 "[window %p] MDI: screen %p inserted\n",do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
3077 window, screen)do { if (0) g_printerr("[window %p] MDI: screen %p inserted\n"
, window, screen); } while (0)
;
3078
3079 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)
3080 "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)
3081 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)
3082 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)
;
3083
3084 /* FIXME: only connect on the active screen, not all screens! */
3085 g_signal_connect (screen, "notify::title",g_signal_connect_data ((screen), ("notify::title"), (((GCallback
) (sync_screen_title))), (window), ((void*)0), (GConnectFlags
) 0)
3086 G_CALLBACK (sync_screen_title), window)g_signal_connect_data ((screen), ("notify::title"), (((GCallback
) (sync_screen_title))), (window), ((void*)0), (GConnectFlags
) 0)
;
3087 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)
3088 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)
;
3089 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)
3090 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)
;
3091 g_signal_connect (screen, "selection-changed",g_signal_connect_data ((screen), ("selection-changed"), (((GCallback
) (terminal_window_update_copy_sensitivity))), (window), ((void
*)0), (GConnectFlags) 0)
3092 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)
;
3093
3094 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)
3095 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)
;
3096 g_signal_connect (screen, "match-clicked",g_signal_connect_data ((screen), ("match-clicked"), (((GCallback
) (screen_match_clicked_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3097 G_CALLBACK (screen_match_clicked_cb), window)g_signal_connect_data ((screen), ("match-clicked"), (((GCallback
) (screen_match_clicked_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3098 g_signal_connect (screen, "resize-window",g_signal_connect_data ((screen), ("resize-window"), (((GCallback
) (screen_resize_window_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3099 G_CALLBACK (screen_resize_window_cb), window)g_signal_connect_data ((screen), ("resize-window"), (((GCallback
) (screen_resize_window_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3100
3101 g_signal_connect (screen, "close-screen",g_signal_connect_data ((screen), ("close-screen"), (((GCallback
) (screen_close_cb))), (window), ((void*)0), (GConnectFlags) 0
)
3102 G_CALLBACK (screen_close_cb), window)g_signal_connect_data ((screen), ("close-screen"), (((GCallback
) (screen_close_cb))), (window), ((void*)0), (GConnectFlags) 0
)
;
3103
3104 update_tab_visibility (window, 0);
3105 terminal_window_update_tabs_menu_sensitivity (window);
3106 terminal_window_update_search_sensitivity (screen, window);
3107
3108#if 0
3109 /* FIXMEchpe: wtf is this doing? */
3110
3111 /* If we have an active screen, match its size and zoom */
3112 if (priv->active_screen)
3113 {
3114 int current_width, current_height;
3115 double scale;
3116
3117 terminal_screen_get_size (priv->active_screen, &current_width, &current_height);
3118 bte_terminal_set_size (BTE_TERMINAL (screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((bte_terminal_get_type()))))))
, current_width, current_height);
3119
3120 scale = terminal_screen_get_font_scale (priv->active_screen);
3121 terminal_screen_set_font_scale (screen, scale);
3122 }
3123#endif
3124
3125 if (priv->present_on_insert)
3126 {
3127 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 ());
3128 priv->present_on_insert = FALSE(0);
3129 }
3130 pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
3131 if (pages == 2) terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
3132}
3133
3134static void
3135notebook_page_removed_callback (CtkWidget *notebook,
3136 CtkWidget *container,
3137 guint page_num G_GNUC_UNUSED__attribute__ ((__unused__)),
3138 TerminalWindow *window)
3139{
3140 TerminalWindowPrivate *priv = window->priv;
3141 TerminalScreen *screen;
3142 int pages;
3143
3144 if (priv->disposed)
3145 return;
3146
3147 screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (container)((((TerminalScreenContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((container)), ((terminal_screen_container_get_type
()))))))
);
3148
3149 _terminal_debug_print (TERMINAL_DEBUG_MDI,do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
3150 "[window %p] MDI: screen %p removed\n",do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
3151 window, screen)do { if (0) g_printerr("[window %p] MDI: screen %p removed\n"
, window, screen); } while (0)
;
3152
3153 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))
3154 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))
3155 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))
;
3156
3157 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))
3158 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))
3159 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))
;
3160
3161 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))
3162 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))
3163 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))
;
3164
3165 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))
3166 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))
3167 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))
;
3168
3169 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))
3170 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))
3171 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))
;
3172
3173 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
))
3174 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
))
3175 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
))
;
3176
3177 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))
3178 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))
3179 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))
;
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_resize_window_cb))), (window))
3181 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))
3182 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))
;
3183
3184 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))
3185 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))
3186 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))
;
3187
3188 terminal_window_update_tabs_menu_sensitivity (window);
3189 update_tab_visibility (window, 0);
3190 terminal_window_update_search_sensitivity (screen, window);
3191
3192 pages = ctk_notebook_get_n_pages (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((ctk_notebook_get_type ()))))))
);
3193 if (pages == 1)
3194 {
3195 terminal_window_update_size (window, priv->active_screen, TRUE(!(0)));
3196 }
3197 else if (pages == 0)
3198 {
3199 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3200 }
3201}
3202
3203void
3204terminal_window_update_copy_selection (TerminalScreen *screen,
3205 TerminalWindow *window)
3206{
3207 TerminalWindowPrivate *priv = window->priv;
3208 priv->copy_selection =
3209 terminal_profile_get_property_boolean (terminal_screen_get_profile (screen),
3210 TERMINAL_PROFILE_COPY_SELECTION"copy-selection");
3211}
3212
3213static gboolean
3214notebook_scroll_event_cb (CtkWidget *widget,
3215 CdkEventScroll *event,
3216 TerminalWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)))
3217{
3218 CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_notebook_get_type ()))))))
;
3219 CtkWidget *child, *event_widget, *action_widget;
3220
3221 child = ctk_notebook_get_nth_page (notebook, ctk_notebook_get_current_page (notebook));
3222 if (child == NULL((void*)0))
3223 return FALSE(0);
3224
3225 event_widget = ctk_get_event_widget ((CdkEvent *) event);
3226
3227 /* Ignore scroll events from the content of the page */
3228 if (event_widget == NULL((void*)0) ||
3229 event_widget == child ||
3230 ctk_widget_is_ancestor (event_widget, child))
3231 return FALSE(0);
3232
3233 /* And also from the action widgets */
3234 action_widget = ctk_notebook_get_action_widget (notebook, CTK_PACK_START);
3235 if (event_widget == action_widget ||
3236 (action_widget != NULL((void*)0) && ctk_widget_is_ancestor (event_widget, action_widget)))
3237 return FALSE(0);
3238 action_widget = ctk_notebook_get_action_widget (notebook, CTK_PACK_END);
3239 if (event_widget == action_widget ||
3240 (action_widget != NULL((void*)0) && ctk_widget_is_ancestor (event_widget, action_widget)))
3241 return FALSE(0);
3242
3243 switch (event->direction) {
3244 case CDK_SCROLL_RIGHT:
3245 case CDK_SCROLL_DOWN:
3246 ctk_notebook_next_page (notebook);
3247 break;
3248 case CDK_SCROLL_LEFT:
3249 case CDK_SCROLL_UP:
3250 ctk_notebook_prev_page (notebook);
3251 break;
3252 case CDK_SCROLL_SMOOTH:
3253 switch (ctk_notebook_get_tab_pos (notebook)) {
3254 case CTK_POS_LEFT:
3255 case CTK_POS_RIGHT:
3256 if (event->delta_y > 0)
3257 ctk_notebook_next_page (notebook);
3258 else if (event->delta_y < 0)
3259 ctk_notebook_prev_page (notebook);
3260 break;
3261 case CTK_POS_TOP:
3262 case CTK_POS_BOTTOM:
3263 if (event->delta_x > 0)
3264 ctk_notebook_next_page (notebook);
3265 else if (event->delta_x < 0)
3266 ctk_notebook_prev_page (notebook);
3267 break;
3268 }
3269 break;
3270 }
3271
3272 return TRUE(!(0));
3273}
3274
3275void
3276terminal_window_update_geometry (TerminalWindow *window)
3277{
3278 TerminalWindowPrivate *priv = window->priv;
3279 CtkWidget *widget;
3280 CdkGeometry hints;
3281 CtkBorder padding;
3282 CtkRequisition toplevel_request, vbox_request, widget_request;
3283 int grid_width, grid_height;
3284 int char_width, char_height;
3285 int chrome_width, chrome_height;
3286
3287 if (priv->active_screen == NULL((void*)0))
3288 return;
3289
3290 widget = CTK_WIDGET (priv->active_screen)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((ctk_widget_get_type ()))))))
;
3291
3292 /* We set geometry hints from the active term; best thing
3293 * I can think of to do. Other option would be to try to
3294 * get some kind of union of all hints from all terms in the
3295 * window, but that doesn't make too much sense.
3296 */
3297 terminal_screen_get_cell_size (priv->active_screen, &char_width, &char_height);
3298
3299 terminal_screen_get_size (priv->active_screen, &grid_width, &grid_height);
3300 _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)
3301 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)
3302 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)
;
3303
3304 ctk_style_context_get_padding(ctk_widget_get_style_context (widget),
3305 ctk_widget_get_state_flags (widget),
3306 &padding);
3307
3308 _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)
3309 padding.left + padding.right,do { if (0) g_printerr("padding = %dx%d px\n", padding.left +
padding.right, padding.top + padding.bottom); } while (0)
3310 padding.top + padding.bottom)do { if (0) g_printerr("padding = %dx%d px\n", padding.left +
padding.right, padding.top + padding.bottom); } while (0)
;
3311
3312 ctk_widget_get_preferred_size (priv->main_vbox, NULL((void*)0), &vbox_request);
3313 _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)
3314 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)
;
3315
3316 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);
3317 _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)
3318 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)
;
3319
3320 chrome_width = vbox_request.width - (char_width * grid_width);
3321 chrome_height = vbox_request.height - (char_height * grid_height);
3322 _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)
3323 chrome_width, chrome_height)do { if (0) g_printerr("chrome: %dx%d px\n", chrome_width, chrome_height
); } while (0)
;
3324
3325 ctk_widget_get_preferred_size (widget, NULL((void*)0), &widget_request);
3326 _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)
3327 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)
;
3328
3329 if (char_width != priv->old_char_width ||
3330 char_height != priv->old_char_height ||
3331 padding.left + padding.right != priv->old_padding_width ||
3332 padding.top + padding.bottom != priv->old_padding_height ||
3333 chrome_width != priv->old_chrome_width ||
3334 chrome_height != priv->old_chrome_height ||
3335 widget != CTK_WIDGET (priv->old_geometry_widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->old_geometry_widget)), ((ctk_widget_get_type ()
))))))
)
3336 {
3337 hints.base_width = chrome_width;
3338 hints.base_height = chrome_height;
3339
3340#define MIN_WIDTH_CHARS4 4
3341#define MIN_HEIGHT_CHARS1 1
3342
3343 hints.width_inc = char_width;
3344 hints.height_inc = char_height;
3345
3346 /* min size is min size of the whole window, remember. */
3347 hints.min_width = hints.base_width + hints.width_inc * MIN_WIDTH_CHARS4;
3348 hints.min_height = hints.base_height + hints.height_inc * MIN_HEIGHT_CHARS1;
3349
3350 ctk_window_set_geometry_hints (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3351 NULL((void*)0),
3352 &hints,
3353 CDK_HINT_RESIZE_INC |
3354 CDK_HINT_MIN_SIZE |
3355 CDK_HINT_BASE_SIZE);
3356
3357 _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)
3358 "[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)
3359 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)
3360 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)
3361 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)
3362 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)
3363 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)
3364 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)
3365 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)
;
3366
3367 priv->old_geometry_widget = widget;
3368 }
3369 else
3370 {
3371 _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
3372 "[window %p] hints: increment unchanged, not setting\n",do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
3373 window)do { if (0) g_printerr("[window %p] hints: increment unchanged, not setting\n"
, window); } while (0)
;
3374 }
3375
3376 /* We need these for the size calculation in terminal_window_update_size(),
3377 * so we set them unconditionally. */
3378 priv->old_char_width = char_width;
3379 priv->old_char_height = char_height;
3380 priv->old_chrome_width = chrome_width;
3381 priv->old_chrome_height = chrome_height;
3382 priv->old_padding_width = padding.left + padding.right;
3383 priv->old_padding_height = padding.top + padding.bottom;
3384}
3385
3386static void
3387file_new_window_callback (CtkAction *action,
3388 TerminalWindow *window)
3389{
3390 TerminalWindowPrivate *priv = window->priv;
3391 TerminalApp *app;
3392 TerminalWindow *new_window;
3393 TerminalProfile *profile;
3394 char *new_working_directory;
3395
3396 app = terminal_app_get ();
3397
3398 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");
3399 if (!profile)
3400 profile = terminal_screen_get_profile (priv->active_screen);
3401 if (!profile)
3402 profile = terminal_app_get_profile_for_new_term (app);
3403 if (!profile)
3404 return;
3405
3406 if (_terminal_profile_get_forgotten (profile))
3407 return;
3408
3409 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 ()))))))
));
3410
3411 new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
3412 terminal_app_new_terminal (app, new_window, profile,
3413 NULL((void*)0), NULL((void*)0),
3414 new_working_directory,
3415 terminal_screen_get_initial_environment (priv->active_screen),
3416 1.0);
3417 g_free (new_working_directory);
3418
3419 ctk_window_present (CTK_WINDOW (new_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((ctk_window_get_type ()))))))
);
3420}
3421
3422static void
3423file_new_tab_callback (CtkAction *action,
3424 TerminalWindow *window)
3425{
3426 TerminalWindowPrivate *priv = window->priv;
3427 TerminalApp *app;
3428 TerminalProfile *profile;
3429 char *new_working_directory;
3430
3431 app = terminal_app_get ();
3432 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");
3433 if (!profile)
3434 profile = terminal_screen_get_profile (priv->active_screen);
3435 if (!profile)
3436 profile = terminal_app_get_profile_for_new_term (app);
3437 if (!profile)
3438 return;
3439
3440 if (_terminal_profile_get_forgotten (profile))
3441 return;
3442
3443 new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
3444 terminal_app_new_terminal (app, window, profile,
3445 NULL((void*)0), NULL((void*)0),
3446 new_working_directory,
3447 terminal_screen_get_initial_environment (priv->active_screen),
3448 1.0);
3449 g_free (new_working_directory);
3450}
3451
3452static void
3453confirm_close_response_cb (CtkWidget *dialog,
3454 int response,
3455 TerminalWindow *window)
3456{
3457 TerminalScreen *screen;
3458
3459 screen = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "close-screen");
3460
3461 ctk_widget_destroy (dialog);
3462
3463 if (response != CTK_RESPONSE_ACCEPT)
3464 return;
3465
3466 if (screen)
3467 terminal_window_remove_screen (window, screen);
3468 else
3469 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3470}
3471
3472/* Returns: TRUE if closing needs to wait until user confirmation;
3473 * FALSE if the terminal or window can close immediately.
3474 */
3475static gboolean
3476confirm_close_window_or_tab (TerminalWindow *window,
3477 TerminalScreen *screen)
3478{
3479 TerminalWindowPrivate *priv = window->priv;
3480 CtkWidget *dialog;
3481 gboolean do_confirm;
3482 gboolean has_processes;
2
'has_processes' declared without an initial value
3483 int n_tabs;
3484 char *confirm_msg;
3485
3486 if (priv->confirm_close_dialog)
3
Assuming field 'confirm_close_dialog' is null
4
Taking false branch
3487 {
3488 /* WTF, already have one? It's modal, so how did that happen? */
3489 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 (
)))))))
,
3490 CTK_RESPONSE_DELETE_EVENT);
3491 }
3492
3493 do_confirm = g_settings_get_boolean (settings_global, "confirm-window-close");
3494
3495 if (!do_confirm)
5
Assuming 'do_confirm' is not equal to 0
6
Taking false branch
3496 return FALSE(0);
3497
3498 if (screen
6.1
'screen' is null
)
7
Taking false branch
3499 {
3500 has_processes = terminal_screen_has_foreground_process (screen);
3501 n_tabs = 1;
3502 }
3503 else
3504 {
3505 GList *tabs, *t;
3506
3507 tabs = terminal_window_list_screen_containers (window);
3508 n_tabs = g_list_length (tabs);
3509
3510 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 3519
3511 {
3512 TerminalScreen *terminal_screen;
3513
3514 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
()))))))
);
3515 has_processes = terminal_screen_has_foreground_process (terminal_screen);
3516 if (has_processes)
3517 break;
3518 }
3519 g_list_free (tabs);
3520 }
3521
3522
3523 if (has_processes)
10
Branch condition evaluates to a garbage value
3524 {
3525 if (n_tabs > 1)
3526 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.")
3527 "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.")
;
3528 else
3529 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.")
3530 "Closing the terminal will kill it.")gettext ("There is still a process running in this terminal. "
"Closing the terminal will kill it.")
;
3531 } else if (n_tabs > 1)
3532 confirm_msg = _("There are multiple tabs open in this window.")gettext ("There are multiple tabs open in this window.");
3533 else
3534 return FALSE(0);
3535
3536 dialog = priv->confirm_close_dialog =
3537 ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3538 CTK_DIALOG_MODAL | CTK_DIALOG_DESTROY_WITH_PARENT,
3539 CTK_MESSAGE_WARNING,
3540 CTK_BUTTONS_CANCEL,
3541 "%s", n_tabs > 1 ? _("Close this window?")gettext ("Close this window?") : _("Close this terminal?")gettext ("Close this terminal?"));
3542
3543 ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ())
)))))
,
3544 "%s", confirm_msg);
3545
3546 ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, "");
3547
3548 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);
3549 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_ACCEPT);
3550
3551 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "close-screen", screen);
3552
3553 g_signal_connect (dialog, "destroy",g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->confirm_close_dialog)
, ((void*)0), (GConnectFlags) 0)
3554 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)
;
3555 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
confirm_close_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3556 G_CALLBACK (confirm_close_response_cb), window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
confirm_close_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3557
3558 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
3559
3560 return TRUE(!(0));
3561}
3562
3563static void
3564file_close_window_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3565 TerminalWindow *window)
3566{
3567 if (confirm_close_window_or_tab (window, NULL((void*)0)))
1
Calling 'confirm_close_window_or_tab'
3568 return;
3569
3570 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
3571}
3572
3573static void
3574save_contents_dialog_on_response (CtkDialog *dialog, gint response_id, gpointer terminal)
3575{
3576 CtkWindow *parent;
3577 gchar *filename_uri = NULL((void*)0);
3578 GFile *file;
3579 GOutputStream *stream;
3580 GError *error = NULL((void*)0);
3581
3582 if (response_id != CTK_RESPONSE_ACCEPT)
3583 {
3584 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
3585 return;
3586 }
3587
3588 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 ()));
3589 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 ()))))))
);
3590
3591 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
3592
3593 if (filename_uri == NULL((void*)0))
3594 return;
3595
3596 file = g_file_new_for_uri (filename_uri);
3597 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 ())))
)))
;
3598
3599 if (stream)
3600 {
3601 /* FIXME
3602 * Should be replaced with the async version when bte implements that.
3603 */
3604 bte_terminal_write_contents_sync (terminal, stream,
3605 BTE_WRITE_DEFAULT,
3606 NULL((void*)0), &error);
3607 g_object_unref (stream);
3608 }
3609
3610 if (error)
3611 {
3612 terminal_util_show_error_dialog (parent, NULL((void*)0), error,
3613 "%s", _("Could not save contents")gettext ("Could not save contents"));
3614 g_error_free (error);
3615 }
3616
3617 g_object_unref(file);
3618 g_free(filename_uri);
3619}
3620
3621static void
3622file_save_contents_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3623 TerminalWindow *window)
3624{
3625 CtkWidget *dialog = NULL((void*)0);
3626 TerminalWindowPrivate *priv = window->priv;
3627 BteTerminal *terminal;
3628
3629 if (!priv->active_screen)
3630 return;
3631
3632 terminal = BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
;
3633 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)
;
3634
3635 dialog = ctk_file_chooser_dialog_new (_("Save as...")gettext ("Save as..."),
3636 CTK_WINDOW(window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3637 CTK_FILE_CHOOSER_ACTION_SAVE,
3638 "ctk-cancel", CTK_RESPONSE_CANCEL,
3639 "ctk-save", CTK_RESPONSE_ACCEPT,
3640 NULL((void*)0));
3641
3642 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)));
3643 /* XXX where should we save to? */
3644 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));
3645
3646 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 ()))))))
);
3647 ctk_window_set_modal (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
3648 ctk_window_set_destroy_with_parent (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
3649
3650 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)
;
3651 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)
;
3652
3653 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
3654}
3655
3656static void
3657file_close_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3658 TerminalWindow *window)
3659{
3660 TerminalWindowPrivate *priv = window->priv;
3661 TerminalScreen *active_screen = priv->active_screen;
3662
3663 if (!active_screen)
3664 return;
3665
3666 if (confirm_close_window_or_tab (window, active_screen))
3667 return;
3668
3669 terminal_window_remove_screen (window, active_screen);
3670}
3671
3672static void
3673edit_copy_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3674 TerminalWindow *window)
3675{
3676 TerminalWindowPrivate *priv = window->priv;
3677
3678 if (!priv->active_screen)
3679 return;
3680
3681 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);
3682}
3683
3684typedef struct
3685{
3686 TerminalScreen *screen;
3687 gboolean uris_as_paths;
3688} PasteData;
3689
3690static void
3691clipboard_uris_received_cb (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)),
3692 /* const */ char **uris,
3693 PasteData *data)
3694{
3695 char *text;
3696 gsize len;
3697
3698 if (!uris)
3699 {
3700 g_object_unref (data->screen);
3701 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3702 return;
3703 }
3704
3705 /* This potentially modifies the strings in |uris| but that's ok */
3706 if (data->uris_as_paths)
3707 terminal_util_transform_uris_to_quoted_fuse_paths (uris);
3708
3709 text = terminal_util_concat_uris (uris, &len);
3710 bte_terminal_feed_child (BTE_TERMINAL (data->screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->screen)), ((bte_terminal_get_type()))))))
, text, len);
3711 g_free (text);
3712
3713 g_object_unref (data->screen);
3714 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3715}
3716
3717static void
3718clipboard_targets_received_cb (CtkClipboard *clipboard,
3719 CdkAtom *targets,
3720 int n_targets,
3721 PasteData *data)
3722{
3723 if (!targets)
3724 {
3725 g_object_unref (data->screen);
3726 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3727 return;
3728 }
3729
3730 if (ctk_targets_include_uri (targets, n_targets))
3731 {
3732 ctk_clipboard_request_uris (clipboard,
3733 (CtkClipboardURIReceivedFunc) clipboard_uris_received_cb,
3734 data);
3735 return;
3736 }
3737 else /* if (ctk_targets_include_text (targets, n_targets)) */
3738 {
3739 bte_terminal_paste_clipboard (BTE_TERMINAL (data->screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->screen)), ((bte_terminal_get_type()))))))
);
3740 }
3741
3742 g_object_unref (data->screen);
3743 g_slice_free (PasteData, data)do { if (1) g_slice_free1 (sizeof (PasteData), (data)); else (
void) ((PasteData*) 0 == (data)); } while (0)
;
3744}
3745
3746static void
3747edit_paste_callback (CtkAction *action,
3748 TerminalWindow *window)
3749{
3750 TerminalWindowPrivate *priv = window->priv;
3751 CtkClipboard *clipboard;
3752 PasteData *data;
3753 const char *name;
3754
3755 if (!priv->active_screen)
3756 return;
3757
3758 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))));
3759 name = ctk_action_get_name (action);
3760
3761 data = g_slice_new (PasteData)((PasteData*) g_slice_alloc (sizeof (PasteData)));
3762 data->screen = g_object_ref (priv->active_screen)((__typeof__ (priv->active_screen)) (g_object_ref) (priv->
active_screen))
;
3763 data->uris_as_paths = (name == I_("EditPasteURIPaths")g_intern_static_string ("EditPasteURIPaths") || name == I_("PopupPasteURIPaths")g_intern_static_string ("PopupPasteURIPaths"));
3764
3765 ctk_clipboard_request_targets (clipboard,
3766 (CtkClipboardTargetsReceivedFunc) clipboard_targets_received_cb,
3767 data);
3768}
3769
3770static void
3771edit_select_all_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3772 TerminalWindow *window)
3773{
3774 TerminalWindowPrivate *priv = window->priv;
3775
3776 if (!priv->active_screen)
3777 return;
3778
3779 bte_terminal_select_all (BTE_TERMINAL (priv->active_screen)((((BteTerminal*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->active_screen)), ((bte_terminal_get_type())))))
)
);
3780}
3781
3782static void
3783edit_keybindings_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3784 TerminalWindow *window)
3785{
3786 terminal_app_edit_keybindings (terminal_app_get (),
3787 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3788}
3789
3790static void
3791edit_current_profile_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3792 TerminalWindow *window)
3793{
3794 TerminalWindowPrivate *priv = window->priv;
3795
3796 terminal_app_edit_profile (terminal_app_get (),
3797 terminal_screen_get_profile (priv->active_screen),
3798 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
3799 NULL((void*)0));
3800}
3801
3802static void
3803file_new_profile_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3804 TerminalWindow *window)
3805{
3806 TerminalWindowPrivate *priv = window->priv;
3807
3808 terminal_app_new_profile (terminal_app_get (),
3809 terminal_screen_get_profile (priv->active_screen),
3810 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3811}
3812
3813static void
3814edit_profiles_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3815 TerminalWindow *window)
3816{
3817 terminal_app_manage_profiles (terminal_app_get (),
3818 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3819}
3820
3821static void
3822view_menubar_toggled_callback (CtkToggleAction *action,
3823 TerminalWindow *window)
3824{
3825 terminal_window_set_menubar_visible (window, ctk_toggle_action_get_active (action));
3826}
3827
3828static void
3829view_fullscreen_toggled_callback (CtkToggleAction *action,
3830 TerminalWindow *window)
3831{
3832 gboolean toggle_action_check;
3833
3834 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)
;
3835
3836 toggle_action_check = ctk_toggle_action_get_active (action);
3837 if (toggle_action_check)
3838 ctk_window_fullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3839 else
3840 ctk_window_unfullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
3841}
3842
3843static const double zoom_factors[] =
3844{
3845 TERMINAL_SCALE_MINIMUM((((((double)0.5787037037037)/1.2)/1.2)/1.2)/1.2),
3846 TERMINAL_SCALE_XXXXX_SMALL(((((double)0.5787037037037)/1.2)/1.2)/1.2),
3847 TERMINAL_SCALE_XXXX_SMALL((((double)0.5787037037037)/1.2)/1.2),
3848 TERMINAL_SCALE_XXX_SMALL(((double)0.5787037037037)/1.2),
3849 PANGO_SCALE_XX_SMALL((double)0.5787037037037),
3850 PANGO_SCALE_X_SMALL((double)0.6944444444444),
3851 PANGO_SCALE_SMALL((double)0.8333333333333),
3852 PANGO_SCALE_MEDIUM((double)1.0),
3853 PANGO_SCALE_LARGE((double)1.2),
3854 PANGO_SCALE_X_LARGE((double)1.44),
3855 PANGO_SCALE_XX_LARGE((double)1.728),
3856 TERMINAL_SCALE_XXX_LARGE(((double)1.728)*1.2),
3857 TERMINAL_SCALE_XXXX_LARGE((((double)1.728)*1.2)*1.2),
3858 TERMINAL_SCALE_XXXXX_LARGE(((((double)1.728)*1.2)*1.2)*1.2),
3859 TERMINAL_SCALE_MAXIMUM((((((double)1.728)*1.2)*1.2)*1.2)*1.2)
3860};
3861
3862static gboolean
3863find_larger_zoom_factor (double current,
3864 double *found)
3865{
3866 guint i;
3867
3868 for (i = 0; i < G_N_ELEMENTS (zoom_factors)(sizeof (zoom_factors) / sizeof ((zoom_factors)[0])); ++i)
3869 {
3870 /* Find a font that's larger than this one */
3871 if ((zoom_factors[i] - current) > 1e-6)
3872 {
3873 *found = zoom_factors[i];
3874 return TRUE(!(0));
3875 }
3876 }
3877
3878 return FALSE(0);
3879}
3880
3881static gboolean
3882find_smaller_zoom_factor (double current,
3883 double *found)
3884{
3885 int i;
3886
3887 i = (int) G_N_ELEMENTS (zoom_factors)(sizeof (zoom_factors) / sizeof ((zoom_factors)[0])) - 1;
3888 while (i >= 0)
3889 {
3890 /* Find a font that's smaller than this one */
3891 if ((current - zoom_factors[i]) > 1e-6)
3892 {
3893 *found = zoom_factors[i];
3894 return TRUE(!(0));
3895 }
3896
3897 --i;
3898 }
3899
3900 return FALSE(0);
3901}
3902
3903static void
3904view_zoom_in_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3905 TerminalWindow *window)
3906{
3907 TerminalWindowPrivate *priv = window->priv;
3908 double current;
3909
3910 if (priv->active_screen == NULL((void*)0))
3911 return;
3912
3913 current = terminal_screen_get_font_scale (priv->active_screen);
3914 if (!find_larger_zoom_factor (current, &current))
3915 return;
3916
3917 terminal_screen_set_font_scale (priv->active_screen, current);
3918 terminal_window_update_zoom_sensitivity (window);
3919}
3920
3921static void
3922view_zoom_out_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3923 TerminalWindow *window)
3924{
3925 TerminalWindowPrivate *priv = window->priv;
3926 double current;
3927
3928 if (priv->active_screen == NULL((void*)0))
3929 return;
3930
3931 current = terminal_screen_get_font_scale (priv->active_screen);
3932 if (!find_smaller_zoom_factor (current, &current))
3933 return;
3934
3935 terminal_screen_set_font_scale (priv->active_screen, current);
3936 terminal_window_update_zoom_sensitivity (window);
3937}
3938
3939static void
3940view_zoom_normal_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3941 TerminalWindow *window)
3942{
3943 TerminalWindowPrivate *priv = window->priv;
3944
3945 if (priv->active_screen == NULL((void*)0))
3946 return;
3947
3948 terminal_screen_set_font_scale (priv->active_screen, PANGO_SCALE_MEDIUM((double)1.0));
3949 terminal_window_update_zoom_sensitivity (window);
3950}
3951
3952
3953static void
3954search_find_response_callback (CtkWidget *dialog,
3955 int response,
3956 gpointer user_data)
3957{
3958 TerminalWindow *window = TERMINAL_WINDOW (user_data)((((TerminalWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((terminal_window_get_type ()))))))
;
3959 TerminalWindowPrivate *priv = window->priv;
3960 TerminalSearchFlags flags;
3961 BteRegex *regex;
3962
3963 if (response != CTK_RESPONSE_ACCEPT)
3964 return;
3965
3966 if (G_UNLIKELY (!priv->active_screen)(!priv->active_screen))
3967 return;
3968
3969 regex = terminal_search_dialog_get_regex (dialog);
3970 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)
;
3971
3972 flags = terminal_search_dialog_get_search_flags (dialog);
3973
3974 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);
3975 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())))))
)
,
3976 (flags & TERMINAL_SEARCH_FLAG_WRAP_AROUND));
3977
3978 if (flags & TERMINAL_SEARCH_FLAG_BACKWARDS)
3979 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())))))
)
);
3980 else
3981 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())))))
)
);
3982
3983 terminal_window_update_search_sensitivity (priv->active_screen, window);
3984}
3985
3986static gboolean
3987search_dialog_delete_event_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
3988 CdkEventAny *event G_GNUC_UNUSED__attribute__ ((__unused__)),
3989 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
3990{
3991 /* prevent destruction */
3992 return TRUE(!(0));
3993}
3994
3995static void
3996search_find_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
3997 TerminalWindow *window)
3998{
3999 TerminalWindowPrivate *priv = window->priv;
4000
4001 if (!priv->search_find_dialog)
4002 {
4003 CtkWidget *dialog;
4004
4005 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 ()))))))
);
4006
4007 g_signal_connect (dialog, "destroy",g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&priv->search_find_dialog), (
(void*)0), (GConnectFlags) 0)
4008 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)
;
4009 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
search_find_response_callback))), (window), ((void*)0), (GConnectFlags
) 0)
4010 G_CALLBACK (search_find_response_callback), window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
search_find_response_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
4011 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)
4012 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)
;
4013 }
4014
4015 terminal_search_dialog_present (priv->search_find_dialog);
4016}
4017
4018static void
4019search_find_next_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4020 TerminalWindow *window)
4021{
4022 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4023 return;
4024
4025 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
()))))))
);
4026}
4027
4028static void
4029search_find_prev_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4030 TerminalWindow *window)
4031{
4032 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4033 return;
4034
4035 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
()))))))
);
4036}
4037
4038static void
4039search_clear_highlight_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4040 TerminalWindow *window)
4041{
4042 if (G_UNLIKELY (!window->priv->active_screen)(!window->priv->active_screen))
4043 return;
4044
4045 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);
4046}
4047
4048static void
4049terminal_next_or_previous_profile_cb (CtkAction *action,
4050 TerminalWindow *window)
4051{
4052 TerminalWindowPrivate *priv = window->priv;
4053 TerminalProfile *active_profile, *new_profile = NULL((void*)0);
4054 GList *profiles, *p;
4055
4056 const char *name;
4057 guint backwards = 0;
4058
4059 name = ctk_action_get_name (action);
4060 if (strcmp (name, "ProfilePrevious") == 0)
4061 {
4062 backwards = 1;
4063 }
4064
4065 profiles = terminal_app_get_profile_list (terminal_app_get ());
4066 if (profiles == NULL((void*)0))
4067 return;
4068
4069 if (priv->active_screen)
4070 active_profile = terminal_screen_get_profile (priv->active_screen);
4071 else
4072 return;
4073
4074 for (p = profiles; p != NULL((void*)0); p = p->next)
4075 {
4076 TerminalProfile *profile = (TerminalProfile *) p->data;
4077 if (profile == active_profile)
4078 {
4079 if (backwards) {
4080 p = p->prev;
4081 if (p == NULL((void*)0))
4082 p = g_list_last (profiles);
4083 new_profile = p->data;
4084 break;
4085 }
4086 else
4087 {
4088 p = p->next;
4089 if (p == NULL((void*)0))
4090 p = g_list_first (profiles);
4091 new_profile = p->data;
4092 break;
4093 }
4094 }
4095 }
4096
4097 if (new_profile)
4098 terminal_screen_set_profile (priv->active_screen, new_profile);
4099
4100 g_list_free (profiles);
4101}
4102
4103static void
4104terminal_set_title_dialog_response_cb (CtkWidget *dialog,
4105 int response,
4106 TerminalScreen *screen)
4107{
4108 if (response == CTK_RESPONSE_OK)
4109 {
4110 CtkEntry *entry;
4111 const char *text;
4112
4113 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 ()))))))
;
4114 text = ctk_entry_get_text (entry);
4115 terminal_screen_set_user_title (screen, text);
4116 }
4117
4118 ctk_widget_destroy (dialog);
4119}
4120
4121static void
4122terminal_set_title_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4123 TerminalWindow *window)
4124{
4125 TerminalWindowPrivate *priv = window->priv;
4126 CtkWidget *dialog, *message_area, *hbox, *label, *entry;
4127
4128 if (priv->active_screen == NULL((void*)0))
4129 return;
4130
4131 /* FIXME: hook the screen up so this dialogue closes if the terminal screen closes */
4132
4133 dialog = ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
4134 CTK_DIALOG_MODAL | CTK_DIALOG_DESTROY_WITH_PARENT,
4135 CTK_MESSAGE_OTHER,
4136 CTK_BUTTONS_OK_CANCEL,
4137 "%s", "");
4138
4139 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"));
4140 ctk_window_set_resizable (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, FALSE(0));
4141 ctk_window_set_role (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, "cafe-terminal-change-title");
4142 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_OK);
4143 /* Alternative button order was set automatically by CtkMessageDialog */
4144
4145 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)
4146 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)
;
4147 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)
4148 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)
;
4149
4150 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 ())
)))))
);
4151 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));
4152
4153 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
4154 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);
4155
4156 label = ctk_label_new_with_mnemonic (_("_Title:")gettext ("_Title:"));
4157 ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, 0.0);
4158 ctk_label_set_yalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, 0.5);
4159 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);
4160
4161 entry = ctk_entry_new ();
4162 ctk_entry_set_width_chars (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, 32);
4163 ctk_entry_set_activates_default (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, TRUE(!(0)));
4164 ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, entry);
4165 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);
4166 ctk_widget_show_all (hbox);
4167
4168 ctk_widget_grab_focus (entry);
4169 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));
4170 ctk_editable_select_region (CTK_EDITABLE (entry)((((CtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_editable_get_type ()))))))
, 0, -1);
4171 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "title-entry", entry);
4172
4173 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
4174}
4175
4176static void
4177terminal_add_encoding_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4178 TerminalWindow *window)
4179{
4180 terminal_app_edit_encodings (terminal_app_get (),
4181 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
4182}
4183
4184static void
4185terminal_reset_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4186 TerminalWindow *window)
4187{
4188 TerminalWindowPrivate *priv = window->priv;
4189
4190 if (priv->active_screen == NULL((void*)0))
4191 return;
4192
4193 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));
4194}
4195
4196static void
4197terminal_reset_clear_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4198 TerminalWindow *window)
4199{
4200 TerminalWindowPrivate *priv = window->priv;
4201
4202 if (priv->active_screen == NULL((void*)0))
4203 return;
4204
4205 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)));
4206}
4207
4208static void
4209tabs_next_or_previous_tab_cb (CtkAction *action,
4210 TerminalWindow *window)
4211{
4212 TerminalWindowPrivate *priv = window->priv;
4213 CtkNotebookClass *klass;
4214 const char *name;
4215 guint keyval = 0;
4216
4217 name = ctk_action_get_name (action);
4218 if (strcmp (name, "TabsNext") == 0)
4219 {
4220 keyval = CDK_KEY_Page_Down0xff56;
4221 }
4222 else if (strcmp (name, "TabsPrevious") == 0)
4223 {
4224 keyval = CDK_KEY_Page_Up0xff55;
4225 }
4226
4227 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
))))
;
4228 ctk_binding_set_activate (ctk_binding_set_by_class (klass),
4229 keyval,
4230 CDK_CONTROL_MASK,
4231 G_OBJECT (priv->notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), (((GType) ((20) << (2))))))))
);
4232}
4233
4234static void
4235tabs_move_left_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4236 TerminalWindow *window)
4237{
4238 TerminalWindowPrivate *priv = window->priv;
4239 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
4240 gint page_num,last_page;
4241 CtkWidget *page;
4242
4243 page_num = ctk_notebook_get_current_page (notebook);
4244 last_page = ctk_notebook_get_n_pages (notebook) - 1;
4245 page = ctk_notebook_get_nth_page (notebook, page_num);
4246
4247 ctk_notebook_reorder_child (notebook, page, page_num == 0 ? last_page : page_num - 1);
4248}
4249
4250static void
4251tabs_move_right_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4252 TerminalWindow *window)
4253{
4254 TerminalWindowPrivate *priv = window->priv;
4255 CtkNotebook *notebook = CTK_NOTEBOOK (priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->notebook)), ((ctk_notebook_get_type ()))))))
;
4256 gint page_num,last_page;
4257 CtkWidget *page;
4258
4259 page_num = ctk_notebook_get_current_page (notebook);
4260 last_page = ctk_notebook_get_n_pages (notebook) - 1;
4261 page = ctk_notebook_get_nth_page (notebook, page_num);
4262
4263 ctk_notebook_reorder_child (notebook, page, page_num == last_page ? 0 : page_num + 1);
4264}
4265
4266static void
4267tabs_detach_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4268 TerminalWindow *window)
4269{
4270 TerminalWindowPrivate *priv = window->priv;
4271 TerminalApp *app;
4272 TerminalWindow *new_window;
4273 TerminalScreen *screen;
4274
4275 app = terminal_app_get ();
4276
4277 screen = priv->active_screen;
4278
4279 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 ()))))))
));
4280
4281 terminal_window_move_screen (window, new_window, screen, -1);
4282
4283 /* FIXME: this seems wrong if tabs are shown in the window */
4284 terminal_window_update_size (new_window, screen, FALSE(0));
4285
4286 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 ());
4287}
4288
4289static void
4290help_contents_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4291 TerminalWindow *window)
4292{
4293 terminal_util_show_help (NULL((void*)0), CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
4294}
4295
4296#define ABOUT_GROUP"About" "About"
4297#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
4298
4299static void
4300help_about_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
4301 TerminalWindow *window)
4302{
4303 char *licence_text;
4304 GBytes *bytes;
4305 const guint8 *data;
4306 GKeyFile *key_file;
4307 GError *error = NULL((void*)0);
4308 char **authors, **contributors, **artists, **documenters, **array_strv;
4309 gchar *comments = NULL((void*)0);
4310 gsize data_len, n_authors = 0, n_contributors = 0, n_artists = 0, n_documenters = 0 , i;
4311 GPtrArray *array;
4312
4313
4314 bytes = g_resources_lookup_data (TERMINAL_RESOURCES_PATH_PREFIX"/org/cafe/terminal" G_DIR_SEPARATOR_S"/" "ui/terminal.about",
4315 G_RESOURCE_LOOKUP_FLAGS_NONE,
4316 &error);
4317 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 4317, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
4318
4319 data = g_bytes_get_data (bytes, &data_len);
4320 key_file = g_key_file_new ();
4321 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
4322 g_assert_no_error (error)do { if (error) g_assertion_message_error (((gchar*) 0), "terminal-window.c"
, 4322, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
4323
4324 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
4325 contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Contributors", &n_contributors, NULL((void*)0));
4326 artists = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Artists", &n_artists, NULL((void*)0));
4327 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
4328 g_key_file_free (key_file);
4329 g_bytes_unref (bytes);
4330
4331 array = g_ptr_array_new ();
4332
4333 for (i = 0; i < n_authors; ++i)
4334 g_ptr_array_add (array, EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@')));
4335 g_free (authors); /* strings are now owned by the array */
4336
4337 if (n_contributors > 0)
4338 {
4339 g_ptr_array_add (array, g_strdup ("")g_strdup_inline (""));
4340 g_ptr_array_add (array, g_strdup (_("Contributors:"))g_strdup_inline (gettext ("Contributors:")));
4341 for (i = 0; i < n_contributors; ++i)
4342 g_ptr_array_add (array, EMAILIFY (contributors[i])(g_strdelimit ((contributors[i]), "%", '@')));
4343 }
4344 g_free (contributors); /* strings are now owned by the array */
4345
4346 g_ptr_array_add (array, NULL((void*)0));
4347 array_strv = (char **) g_ptr_array_free (array, FALSE(0));
4348
4349 for (i = 0; i < n_artists; ++i)
4350 artists[i] = EMAILIFY (artists[i])(g_strdelimit ((artists[i]), "%", '@'));
4351 for (i = 0; i < n_documenters; ++i)
4352 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
4353
4354 licence_text = terminal_util_get_licence_text ();
4355
4356 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"
)
,
4357 ctk_get_major_version (), ctk_get_minor_version (), ctk_get_micro_version (),
4358 bte_get_major_version (), bte_get_minor_version (), bte_get_micro_version ());
4359
4360 ctk_show_about_dialog (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
4361 "program-name", _("CAFE Terminal")gettext ("CAFE Terminal"),
4362 "version", VERSION"2.0.0",
4363 "title", _("About CAFE Terminal")gettext ("About CAFE Terminal"),
4364 "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")
4365 "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")
4366 "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")
4367 "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")
4368 "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")
4369 "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")
4370 "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")
,
4371 "comments", comments,
4372 "authors", array_strv,
4373 "artists", artists,
4374 "documenters", documenters,
4375 "license", licence_text,
4376 "wrap-license", TRUE(!(0)),
4377 "translator-credits", _("translator-credits")gettext ("translator-credits"),
4378 "logo-icon-name", CAFE_TERMINAL_ICON_NAME"utilities-terminal",
4379 "website", "https://cafe-desktop.org",
4380 NULL((void*)0));
4381
4382 g_free (comments);
4383 g_strfreev (array_strv);
4384 g_strfreev (artists);
4385 g_strfreev (documenters);
4386 g_free (licence_text);
4387}
4388
4389CtkUIManager *
4390terminal_window_get_ui_manager (TerminalWindow *window)
4391{
4392 TerminalWindowPrivate *priv = window->priv;
4393
4394 return priv->ui_manager;
4395}
4396
4397void
4398terminal_window_save_state (TerminalWindow *window,
4399 GKeyFile *key_file,
4400 const char *group)
4401{
4402 TerminalWindowPrivate *priv = window->priv;
4403 GList *tabs, *lt;
4404 TerminalScreen *active_screen;
4405 CdkWindowState state;
4406 GPtrArray *tab_names_array;
4407 char **tab_names;
4408 gsize len;
4409
4410 //XXXif (priv->menub)//XXX
4411 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_MENUBAR_VISIBLE"MenubarVisible",
4412 priv->menubar_visible);
4413
4414 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_ROLE"Role",
4415 ctk_window_get_role (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
));
4416
4417 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 ()))))))
));
4418 if (state & CDK_WINDOW_STATE_MAXIMIZED)
4419 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_MAXIMIZED"Maximized", TRUE(!(0)));
4420 if (state & CDK_WINDOW_STATE_FULLSCREEN)
4421 g_key_file_set_boolean (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_FULLSCREEN"Fullscreen", TRUE(!(0)));
4422
4423 active_screen = terminal_window_get_active (window);
4424 tabs = terminal_window_list_screen_containers (window);
4425
4426 tab_names_array = g_ptr_array_sized_new (g_list_length (tabs) + 1);
4427
4428 for (lt = tabs; lt != NULL((void*)0); lt = lt->next)
4429 {
4430 TerminalScreen *screen;
4431 char *tab_group;
4432
4433 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
()))))))
);
4434
4435 tab_group = g_strdup_printf ("Terminal%p", screen);
4436 g_ptr_array_add (tab_names_array, tab_group);
4437
4438 terminal_screen_save_config (screen, key_file, tab_group);
4439
4440 if (screen == active_screen)
4441 {
4442 int w, h, x, y;
4443 char *geometry;
4444
4445 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_ACTIVE_TAB"ActiveTerminal", tab_group);
4446
4447 /* FIXME saving the geometry is not great :-/ */
4448 terminal_screen_get_size (screen, &w, &h);
4449 ctk_window_get_position (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, &x, &y);
4450 geometry = g_strdup_printf ("%dx%d+%d+%d", w, h, x, y);
4451 g_key_file_set_string (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_GEOMETRY"Geometry", geometry);
4452 g_free (geometry);
4453 }
4454 }
4455
4456 g_list_free (tabs);
4457
4458 len = tab_names_array->len;
4459 g_ptr_array_add (tab_names_array, NULL((void*)0));
4460 tab_names = (char **) g_ptr_array_free (tab_names_array, FALSE(0));
4461 g_key_file_set_string_list (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_TABS"Terminals", (const char * const *) tab_names, len);
4462 g_strfreev (tab_names);
4463}
4464
4465
4466TerminalWindow *
4467terminal_window_get_latest_focused (TerminalWindow *window1,
4468 TerminalWindow *window2)
4469{
4470 TerminalWindowPrivate *priv1 = NULL((void*)0);
4471 TerminalWindowPrivate *priv2 = NULL((void*)0);
4472
4473 if (!window1)
4474 return window2;
4475
4476 if (!window2)
4477 return window1;
4478
4479 priv1 = window1->priv;
4480 priv2 = window2->priv;
4481
4482 if (priv2->focus_time > priv1->focus_time)
4483 return window2;
4484
4485 return window1;
4486}