Bug Summary

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

Annotated Source Code

Press '?' to see keyboard shortcuts

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