1 /* 2 * This is free software; you can redistribute it and/or modify it under 3 * the terms of the GNU Library General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but 8 * WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 * General Public License for more details. 11 * 12 * You should have received a copy of the GNU Library General Public 13 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 14 */ 15 16 #ifndef TILDA_WINDOW_H 17 #define TILDA_WINDOW_H 18 19 #include "tilda_terminal.h" 20 21 #include <glib.h> 22 #include <gtk/gtk.h> 23 24 #include "tilda-search-box.h" 25 26 G_BEGIN_DECLS 27 28 enum pull_action { 29 PULL_UP, 30 PULL_DOWN, 31 PULL_TOGGLE 32 }; 33 34 typedef struct tilda_window_ tilda_window; 35 36 enum tilda_animation_state { 37 STATE_UP, 38 STATE_DOWN, 39 STATE_GOING_UP, 40 STATE_GOING_DOWN 41 }; 42 43 struct tilda_window_ 44 { 45 GtkWidget *window; 46 GtkWidget *notebook; 47 GtkWidget *search; 48 49 GList *terms; 50 GtkAccelGroup * accel_group; 51 GtkBuilder *gtk_builder; 52 GtkWidget *wizard_window; /* GtkDialog that contains the wizard */ 53 54 gchar *lock_file; 55 gchar *config_file; 56 gboolean config_writing_disabled; 57 gint instance; 58 gboolean have_argb_visual; 59 60 /* Temporarily disable auto hiding */ 61 gboolean disable_auto_hide; 62 /* Auto hide tick-function handler */ 63 guint auto_hide_tick_handler; 64 /* Auto hide current time */ 65 guint32 auto_hide_current_time; 66 /* Auto hide max time */ 67 guint32 auto_hide_max_time; 68 /* Generic timer resolution */ 69 guint32 timer_resolution; 70 /* Should Tilda hide itself on focus lost event? */ 71 gboolean auto_hide_on_focus_lost; 72 /* Should Tilda hide itself when mouse leaves it? */ 73 gboolean auto_hide_on_mouse_leave; 74 75 /* Should Tilda hide itself even if not focused */ 76 gboolean hide_non_focused; 77 78 gboolean fullscreen; 79 80 /* This field MUST be set before calling pull()! */ 81 enum tilda_animation_state current_state; 82 83 gboolean focus_loss_on_keypress; 84 85 gint unscaled_font_size; 86 gdouble current_scale_factor; 87 88 enum pull_action last_action; 89 gint64 last_action_time; 90 91 /** 92 * This stores the ID of the event source which handles size updates. 93 */ 94 guint size_update_event_source; 95 }; 96 97 /* For use in get_display_dimension() */ 98 enum dimensions { HEIGHT, WIDTH }; 99 100 enum notebook_tab_positions { NB_TOP, NB_BOTTOM, NB_LEFT, NB_RIGHT, NB_HIDDEN }; 101 102 /** 103 * tilda_window_add_tab () 104 * 105 * Create and add a new tab at the end of the notebook 106 * 107 * Success: the new tab's index (>=0) 108 * Failure: -1 109 */ 110 gint tilda_window_add_tab (tilda_window *tw); 111 112 /** 113 * tilda_window_close_tab () 114 * 115 * Closes the tab at the given tab index (starting from 0) 116 * 117 * Success: return 0 118 * Failure: return non-zero 119 */ 120 gint tilda_window_close_tab (tilda_window *tw, gint tab_position, gboolean force_exit); 121 122 /** 123 * tilda_window_next_tab () 124 * 125 * Switch to next tab 126 * 127 * Success: return 0 128 * Failure: return non-zero 129 */ 130 gint tilda_window_next_tab (tilda_window *tw); 131 132 /** 133 * tilda_window_prev_tab () 134 * 135 * Switch to previous tab 136 * 137 * Success: return 0 138 * Failure: return non-zero 139 */ 140 gint tilda_window_prev_tab (tilda_window *tw); 141 142 /** 143 * tilda_window_init () 144 * 145 * Initalizes an already allocated tilda_window *. It will also initialize and set up 146 * as much of the window as possible using the values in the configuation system. 147 * 148 * @param instance the instance number of this tilda_window 149 * 150 * Notes: The configuration system must be up and running before calling this function. 151 */ 152 gboolean tilda_window_init (const gchar *config_file, const gint instance, tilda_window *tw); 153 154 /** 155 * Releases resources that are being used by the tilda window, such as the tabs 156 * or the config file. 157 */ 158 gint tilda_window_free (tilda_window *tw); 159 160 /** 161 * Applies or reapplies the current fullscreen state of the tilda window. 162 */ 163 void tilda_window_set_fullscreen(tilda_window *tw); 164 165 /** 166 * This toggles the fullscreen mode on or off. This is intended to be registered 167 * as a GCallback in order to be invoked after some user action. 168 */ 169 gint toggle_fullscreen_cb (tilda_window *tw); 170 171 /** 172 * This controls where the tabs are positions (e.g. top, left, bottom or 173 * right). 174 */ 175 gint tilda_window_set_tab_position (tilda_window *tw, enum notebook_tab_positions pos); 176 177 /** 178 * tilda_window_close_tab () 179 * 180 * Closes the tab current tab 181 */ 182 void tilda_window_close_current_tab (tilda_window *tw); 183 184 /* This should be called by the wizard for each key that has changed. */ 185 gboolean tilda_window_update_keyboard_accelerators (const gchar* path, const gchar* value); 186 187 /** 188 * Toggles transparency on all terms 189 */ 190 void tilda_window_toggle_transparency(tilda_window *tw); 191 192 /** 193 * Refreshes transparency 194 */ 195 void tilda_window_refresh_transparency(tilda_window *tw); 196 197 /** 198 * Toggles the search bar of the tilda window. 199 */ 200 void tilda_window_toggle_searchbar (tilda_window *tw); 201 202 /** 203 * Show confirm dialog before quitting (if enabled) 204 */ 205 gint tilda_window_confirm_quit (tilda_window *tw); 206 207 GdkMonitor* tilda_window_find_monitor_number(tilda_window *tw); 208 209 /** 210 * Finds the coordinate that will center the tilda window in the screen. 211 * 212 * If you want to center the tilda window on the top or bottom of the screen, 213 * pass the screen width into screen_dimension and the tilda window's width 214 * into the tilda_dimension variable. The result will be the x coordinate that 215 * should be used in order to have the tilda window centered on the screen. 216 * 217 * Centering based on y coordinate is similar, just use the screen height and 218 * tilda window height. 219 */ 220 gint tilda_window_find_centering_coordinate (tilda_window *tw, enum dimensions dimension); 221 222 void tilda_window_update_window_position (tilda_window *tw); 223 224 #define TILDA_WINDOW(data) ((tilda_window *)(data)) 225 226 /* Allow scales a bit smaller and a bit larger than the usual pango ranges */ 227 #define TERMINAL_SCALE_XXX_SMALL (PANGO_SCALE_XX_SMALL/1.2) 228 #define TERMINAL_SCALE_XXXX_SMALL (TERMINAL_SCALE_XXX_SMALL/1.2) 229 #define TERMINAL_SCALE_XXXXX_SMALL (TERMINAL_SCALE_XXXX_SMALL/1.2) 230 #define TERMINAL_SCALE_XXX_LARGE (PANGO_SCALE_XX_LARGE*1.2) 231 #define TERMINAL_SCALE_XXXX_LARGE (TERMINAL_SCALE_XXX_LARGE*1.2) 232 #define TERMINAL_SCALE_XXXXX_LARGE (TERMINAL_SCALE_XXXX_LARGE*1.2) 233 #define TERMINAL_SCALE_MINIMUM (TERMINAL_SCALE_XXXXX_SMALL/1.2) 234 #define TERMINAL_SCALE_MAXIMUM (TERMINAL_SCALE_XXXXX_LARGE*1.2) 235 236 G_END_DECLS 237 238 #endif 239