[go: up one dir, main page]

File: tilda_window.h

package info (click to toggle)
tilda 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,860 kB
  • ctags: 481
  • sloc: ansic: 5,730; makefile: 115; xml: 48; sh: 35
file content (207 lines) | stat: -rw-r--r-- 5,646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * This is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Library General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TILDA_WINDOW_H
#define TILDA_WINDOW_H

#include "tilda_window.h"
#include "tilda_terminal.h"

#include <glib.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS

enum pull_action {
    PULL_UP,
    PULL_DOWN,
    PULL_TOGGLE
};

typedef struct tilda_window_ tilda_window;
typedef struct tilda_search_ tilda_search;

enum tilda_animation_state {
    STATE_UP,
    STATE_DOWN,
    STATE_GOING_UP,
    STATE_GOING_DOWN
};

struct tilda_window_
{
    GtkWidget *window;
    GtkWidget *notebook;

    GList *terms;
    GtkAccelGroup * accel_group;
    GtkBuilder *gtk_builder;
    GtkWidget *wizard_window; /* GtkDialog that contains the wizard */

    gchar *lock_file;
    gchar *config_file;
    gboolean config_writing_disabled;
    gint instance;
    gboolean have_argb_visual;

    /* Temporarily disable auto hiding */
    gboolean disable_auto_hide;
    /* Auto hide tick-function handler */
    guint auto_hide_tick_handler;
    /* Auto hide current time */
    guint32 auto_hide_current_time;
    /* Auto hide max time */
    guint32 auto_hide_max_time;
    /* Generic timer resolution */
    guint32 timer_resolution;
    /* Should Tilda hide itself on focus lost event? */
    gboolean auto_hide_on_focus_lost;
    /* Should Tilda hide itself when mouse leaves it? */
    gboolean auto_hide_on_mouse_leave;

    /* Should Tilda hide itself even if not focused */
    gboolean hide_non_focused;

	gboolean fullscreen;

    /* This field MUST be set before calling pull()! */
    enum tilda_animation_state current_state;

    gboolean focus_loss_on_keypress;

    gint unscaled_font_size;
    gdouble current_scale_factor;

    tilda_search *search;

    enum pull_action last_action;
    gint64 last_action_time;
};

struct tilda_search_
{
    GtkWidget *search_box;
    GtkWidget *entry_search;
    GtkWidget *button_next;
    GtkWidget *button_prev;
    GtkWidget *check_match_case;
    GtkWidget *check_regex;
    GtkWidget *label_search_end;
    /* Stores the result of the last search, if FALSE the last search did not find a match. */
    gboolean is_search_result;
};

enum notebook_tab_positions { NB_TOP, NB_BOTTOM, NB_LEFT, NB_RIGHT, NB_HIDDEN };

/**
 * tilda_window_add_tab ()
 *
 * Create and add a new tab at the end of the notebook
 *
 * Success: the new tab's index (>=0)
 * Failure: -1
 */
gint tilda_window_add_tab (tilda_window *tw);

/**
 * tilda_window_close_tab ()
 *
 * Closes the tab at the given tab index (starting from 0)
 *
 * Success: return 0
 * Failure: return non-zero
 */
gint tilda_window_close_tab (tilda_window *tw, gint tab_position, gboolean force_exit);

/**
 * tilda_window_next_tab ()
 *
 * Switch to next tab
 *
 * Success: return 0
 * Failure: return non-zero
 */
gint tilda_window_next_tab (tilda_window *tw);

/**
 * tilda_window_prev_tab ()
 *
 * Switch to previous tab
 *
 * Success: return 0
 * Failure: return non-zero
 */
gint tilda_window_prev_tab (tilda_window *tw);

/**
 * tilda_window_init ()
 *
 * Initalizes an already allocated tilda_window *. It will also initialize and set up
 * as much of the window as possible using the values in the configuation system.
 *
 * @param instance the instance number of this tilda_window
 *
 * Notes: The configuration system must be up and running before calling this function.
 */
gboolean tilda_window_init (const gchar *config_file, const gint instance, tilda_window *tw);

/**
 * Releases resources that are being used by the tilda window, such as the tabs
 * or the config file.
 */
gint tilda_window_free (tilda_window *tw);

/**
 * This toggles the fullscreen mode on or off. This is intended to be registered
 * as a GCallback in order to be invoked after some user action.
 */
gint toggle_fullscreen_cb (tilda_window *tw);

/**
 * This controls where the tabs are positions (e.g. top, left, bottom or
 * right).
 */
gint tilda_window_set_tab_position (tilda_window *tw, enum notebook_tab_positions pos);

/**
 * tilda_window_close_tab ()
 *
 * Closes the tab current tab
 */
void tilda_window_close_current_tab (tilda_window *tw);

/* This should be called by the wizard for each key that has changed. */
gboolean tilda_window_update_keyboard_accelerators (const gchar* path, const gchar* value);

/**
 * Toggles transparency on all terms
 */
void tilda_window_toggle_transparency(tilda_window *tw);

#define TILDA_WINDOW(data) ((tilda_window *)(data))

/* Allow scales a bit smaller and a bit larger than the usual pango ranges */
#define TERMINAL_SCALE_XXX_SMALL   (PANGO_SCALE_XX_SMALL/1.2)
#define TERMINAL_SCALE_XXXX_SMALL  (TERMINAL_SCALE_XXX_SMALL/1.2)
#define TERMINAL_SCALE_XXXXX_SMALL (TERMINAL_SCALE_XXXX_SMALL/1.2)
#define TERMINAL_SCALE_XXX_LARGE   (PANGO_SCALE_XX_LARGE*1.2)
#define TERMINAL_SCALE_XXXX_LARGE  (TERMINAL_SCALE_XXX_LARGE*1.2)
#define TERMINAL_SCALE_XXXXX_LARGE (TERMINAL_SCALE_XXXX_LARGE*1.2)
#define TERMINAL_SCALE_MINIMUM     (TERMINAL_SCALE_XXXXX_SMALL/1.2)
#define TERMINAL_SCALE_MAXIMUM     (TERMINAL_SCALE_XXXXX_LARGE*1.2)

G_END_DECLS

#endif