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