File: | lapiz/lapiz-window.c |
Warning: | line 315, column 3 String copy function overflows the destination buffer |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * lapiz-window.c | |||
3 | * This file is part of lapiz | |||
4 | * | |||
5 | * Copyright (C) 2005 - Paolo Maggi | |||
6 | * | |||
7 | * This program is free software; you can redistribute it and/or modify | |||
8 | * it under the terms of the GNU General Public License as published by | |||
9 | * the Free Software Foundation; either version 2 of the License, or | |||
10 | * (at your option) any later version. | |||
11 | * | |||
12 | * This program is distributed in the hope that it will be useful, | |||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
15 | * GNU General Public License for more details. | |||
16 | * | |||
17 | * You should have received a copy of the GNU General Public License | |||
18 | * along with this program; if not, write to the Free Software | |||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | |||
20 | * Boston, MA 02110-1301, USA. | |||
21 | */ | |||
22 | ||||
23 | /* | |||
24 | * Modified by the lapiz Team, 2005. See the AUTHORS file for a | |||
25 | * list of people on the lapiz Team. | |||
26 | * See the ChangeLog files for a list of changes. | |||
27 | * | |||
28 | * $Id$ | |||
29 | */ | |||
30 | ||||
31 | #ifdef HAVE_CONFIG_H1 | |||
32 | #include <config.h> | |||
33 | #endif | |||
34 | ||||
35 | #include <time.h> | |||
36 | #include <sys/types.h> | |||
37 | #include <string.h> | |||
38 | ||||
39 | #include <cdk/cdk.h> | |||
40 | #include <glib/gi18n.h> | |||
41 | #include <gio/gio.h> | |||
42 | #include <ctk/ctk.h> | |||
43 | #include <ctksourceview/ctksource.h> | |||
44 | #include <libbean/bean-activatable.h> | |||
45 | #include <libbean/bean-extension-set.h> | |||
46 | ||||
47 | #include "lapiz-ui.h" | |||
48 | #include "lapiz-window.h" | |||
49 | #include "lapiz-window-private.h" | |||
50 | #include "lapiz-app.h" | |||
51 | #include "lapiz-notebook.h" | |||
52 | #include "lapiz-statusbar.h" | |||
53 | #include "lapiz-utils.h" | |||
54 | #include "lapiz-commands.h" | |||
55 | #include "lapiz-debug.h" | |||
56 | #include "lapiz-language-manager.h" | |||
57 | #include "lapiz-prefs-manager-app.h" | |||
58 | #include "lapiz-prefs-manager-private.h" | |||
59 | #include "lapiz-panel.h" | |||
60 | #include "lapiz-documents-panel.h" | |||
61 | #include "lapiz-plugins-engine.h" | |||
62 | #include "lapiz-enum-types.h" | |||
63 | #include "lapiz-dirs.h" | |||
64 | #include "lapiz-status-combo-box.h" | |||
65 | ||||
66 | #define LANGUAGE_NONE(const gchar *)"LangNone" (const gchar *)"LangNone" | |||
67 | #define LAPIZ_UIFILE"lapiz-ui.xml" "lapiz-ui.xml" | |||
68 | #define TAB_WIDTH_DATA"LapizWindowTabWidthData" "LapizWindowTabWidthData" | |||
69 | #define LANGUAGE_DATA"LapizWindowLanguageData" "LapizWindowLanguageData" | |||
70 | #define FULLSCREEN_ANIMATION_SPEED4 4 | |||
71 | ||||
72 | /* Local variables */ | |||
73 | static gboolean cansave = TRUE(!(0)); | |||
74 | ||||
75 | /* Signals */ | |||
76 | enum | |||
77 | { | |||
78 | TAB_ADDED, | |||
79 | TAB_REMOVED, | |||
80 | TABS_REORDERED, | |||
81 | ACTIVE_TAB_CHANGED, | |||
82 | ACTIVE_TAB_STATE_CHANGED, | |||
83 | LAST_SIGNAL | |||
84 | }; | |||
85 | ||||
86 | static guint signals[LAST_SIGNAL] = { 0 }; | |||
87 | ||||
88 | enum | |||
89 | { | |||
90 | PROP_0, | |||
91 | PROP_STATE | |||
92 | }; | |||
93 | ||||
94 | enum | |||
95 | { | |||
96 | TARGET_URI_LIST = 100 | |||
97 | }; | |||
98 | ||||
99 | G_DEFINE_TYPE_WITH_PRIVATE (LapizWindow, lapiz_window, CTK_TYPE_WINDOW)static void lapiz_window_init (LapizWindow *self); static void lapiz_window_class_init (LapizWindowClass *klass); static GType lapiz_window_get_type_once (void); static gpointer lapiz_window_parent_class = ((void*)0); static gint LapizWindow_private_offset; static void lapiz_window_class_intern_init (gpointer klass) { lapiz_window_parent_class = g_type_class_peek_parent (klass); if (LapizWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &LapizWindow_private_offset ); lapiz_window_class_init ((LapizWindowClass*) klass); } __attribute__ ((__unused__)) static inline gpointer lapiz_window_get_instance_private (LapizWindow *self) { return (((gpointer) ((guint8*) (self) + (glong) (LapizWindow_private_offset)))); } GType lapiz_window_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = lapiz_window_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType lapiz_window_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_window_get_type ()), g_intern_static_string ("LapizWindow" ), sizeof (LapizWindowClass), (GClassInitFunc)(void (*)(void) ) lapiz_window_class_intern_init, sizeof (LapizWindow), (GInstanceInitFunc )(void (*)(void)) lapiz_window_init, (GTypeFlags) 0); { {{ LapizWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (LapizWindowPrivate )); };} } return g_define_type_id; } | |||
100 | ||||
101 | static void recent_manager_changed (CtkRecentManager *manager, | |||
102 | LapizWindow *window); | |||
103 | ||||
104 | static void | |||
105 | lapiz_window_get_property (GObject *object, | |||
106 | guint prop_id, | |||
107 | GValue *value, | |||
108 | GParamSpec *pspec) | |||
109 | { | |||
110 | LapizWindow *window = LAPIZ_WINDOW (object)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((lapiz_window_get_type())))))); | |||
111 | ||||
112 | switch (prop_id) | |||
113 | { | |||
114 | case PROP_STATE: | |||
115 | g_value_set_enum (value, | |||
116 | lapiz_window_get_state (window)); | |||
117 | break; | |||
118 | default: | |||
119 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "lapiz-window.c", 119, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
120 | break; | |||
121 | } | |||
122 | } | |||
123 | ||||
124 | static void | |||
125 | save_panes_state (LapizWindow *window) | |||
126 | { | |||
127 | gint pane_page; | |||
128 | ||||
129 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 129, ((const char*) (__func__ ))); | |||
130 | ||||
131 | if (lapiz_prefs_manager_window_size_can_set ()) | |||
132 | lapiz_prefs_manager_set_window_size (window->priv->width, | |||
133 | window->priv->height); | |||
134 | ||||
135 | if (lapiz_prefs_manager_window_state_can_set ()) | |||
136 | lapiz_prefs_manager_set_window_state (window->priv->window_state); | |||
137 | ||||
138 | if ((window->priv->side_panel_size > 0) && | |||
139 | lapiz_prefs_manager_side_panel_size_can_set ()) | |||
140 | lapiz_prefs_manager_set_side_panel_size ( | |||
141 | window->priv->side_panel_size); | |||
142 | ||||
143 | pane_page = _lapiz_panel_get_active_item_id (LAPIZ_PANEL (window->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->side_panel)), ((lapiz_panel_get_type ()))))))); | |||
144 | if (pane_page != 0 && | |||
145 | lapiz_prefs_manager_side_panel_active_page_can_set ()) | |||
146 | lapiz_prefs_manager_set_side_panel_active_page (pane_page); | |||
147 | ||||
148 | if ((window->priv->bottom_panel_size > 0) && | |||
149 | lapiz_prefs_manager_bottom_panel_size_can_set ()) | |||
150 | lapiz_prefs_manager_set_bottom_panel_size ( | |||
151 | window->priv->bottom_panel_size); | |||
152 | ||||
153 | pane_page = _lapiz_panel_get_active_item_id (LAPIZ_PANEL (window->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->bottom_panel)), ((lapiz_panel_get_type ()))))))); | |||
154 | if (pane_page != 0 && | |||
155 | lapiz_prefs_manager_bottom_panel_active_page_can_set ()) | |||
156 | lapiz_prefs_manager_set_bottom_panel_active_page (pane_page); | |||
157 | } | |||
158 | ||||
159 | static void | |||
160 | lapiz_window_dispose (GObject *object) | |||
161 | { | |||
162 | LapizWindow *window; | |||
163 | ||||
164 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 164, ((const char*) (__func__ ))); | |||
165 | ||||
166 | window = LAPIZ_WINDOW (object)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((lapiz_window_get_type())))))); | |||
167 | ||||
168 | /* Stop tracking removal of panes otherwise we always | |||
169 | * end up with thinking we had no pane active, since they | |||
170 | * should all be removed below */ | |||
171 | if (window->priv->bottom_panel_item_removed_handler_id != 0) | |||
172 | { | |||
173 | g_signal_handler_disconnect (window->priv->bottom_panel, | |||
174 | window->priv->bottom_panel_item_removed_handler_id); | |||
175 | window->priv->bottom_panel_item_removed_handler_id = 0; | |||
176 | } | |||
177 | ||||
178 | /* First of all, force collection so that plugins | |||
179 | * really drop some of the references. | |||
180 | */ | |||
181 | bean_engine_garbage_collect (BEAN_ENGINE (lapiz_plugins_engine_get_default ())((((BeanEngine*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_plugins_engine_get_default ())), ((bean_engine_get_type ()))))))); | |||
182 | ||||
183 | /* save the panes position and make sure to deactivate plugins | |||
184 | * for this window, but only once */ | |||
185 | if (!window->priv->dispose_has_run) | |||
186 | { | |||
187 | save_panes_state (window); | |||
188 | ||||
189 | /* Note that unreffing the extensions will automatically remove | |||
190 | all extensions which in turn will deactivate the extension */ | |||
191 | g_object_unref (window->priv->extensions); | |||
192 | ||||
193 | bean_engine_garbage_collect (BEAN_ENGINE (lapiz_plugins_engine_get_default ())((((BeanEngine*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_plugins_engine_get_default ())), ((bean_engine_get_type ()))))))); | |||
194 | ||||
195 | window->priv->dispose_has_run = TRUE(!(0)); | |||
196 | } | |||
197 | ||||
198 | if (window->priv->fullscreen_animation_timeout_id != 0) | |||
199 | { | |||
200 | g_source_remove (window->priv->fullscreen_animation_timeout_id); | |||
201 | window->priv->fullscreen_animation_timeout_id = 0; | |||
202 | } | |||
203 | ||||
204 | if (window->priv->fullscreen_controls != NULL((void*)0)) | |||
205 | { | |||
206 | ctk_widget_destroy (window->priv->fullscreen_controls); | |||
207 | ||||
208 | window->priv->fullscreen_controls = NULL((void*)0); | |||
209 | } | |||
210 | ||||
211 | if (window->priv->recents_handler_id != 0) | |||
212 | { | |||
213 | CtkRecentManager *recent_manager; | |||
214 | ||||
215 | recent_manager = ctk_recent_manager_get_default (); | |||
216 | g_signal_handler_disconnect (recent_manager, | |||
217 | window->priv->recents_handler_id); | |||
218 | window->priv->recents_handler_id = 0; | |||
219 | } | |||
220 | ||||
221 | if (window->priv->manager != NULL((void*)0)) | |||
222 | { | |||
223 | g_object_unref (window->priv->manager); | |||
224 | window->priv->manager = NULL((void*)0); | |||
225 | } | |||
226 | ||||
227 | if (window->priv->message_bus != NULL((void*)0)) | |||
228 | { | |||
229 | g_object_unref (window->priv->message_bus); | |||
230 | window->priv->message_bus = NULL((void*)0); | |||
231 | } | |||
232 | ||||
233 | if (window->priv->window_group != NULL((void*)0)) | |||
234 | { | |||
235 | g_object_unref (window->priv->window_group); | |||
236 | window->priv->window_group = NULL((void*)0); | |||
237 | } | |||
238 | ||||
239 | /* Now that there have broken some reference loops, | |||
240 | * force collection again. | |||
241 | */ | |||
242 | bean_engine_garbage_collect (BEAN_ENGINE (lapiz_plugins_engine_get_default ())((((BeanEngine*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_plugins_engine_get_default ())), ((bean_engine_get_type ()))))))); | |||
243 | ||||
244 | G_OBJECT_CLASS (lapiz_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((lapiz_window_parent_class)), (((GType) ((20) << (2 ))))))))->dispose (object); | |||
245 | } | |||
246 | ||||
247 | static void | |||
248 | lapiz_window_finalize (GObject *object) | |||
249 | { | |||
250 | LapizWindow *window; | |||
251 | ||||
252 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 252, ((const char*) (__func__ ))); | |||
253 | ||||
254 | window = LAPIZ_WINDOW (object)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((lapiz_window_get_type())))))); | |||
255 | ||||
256 | if (window->priv->default_location != NULL((void*)0)) | |||
257 | g_object_unref (window->priv->default_location); | |||
258 | ||||
259 | G_OBJECT_CLASS (lapiz_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((lapiz_window_parent_class)), (((GType) ((20) << (2 ))))))))->finalize (object); | |||
260 | } | |||
261 | ||||
262 | static gboolean | |||
263 | lapiz_window_window_state_event (CtkWidget *widget, | |||
264 | CdkEventWindowState *event) | |||
265 | { | |||
266 | LapizWindow *window = LAPIZ_WINDOW (widget)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((lapiz_window_get_type())))))); | |||
267 | ||||
268 | window->priv->window_state = event->new_window_state; | |||
269 | ||||
270 | return CTK_WIDGET_CLASS (lapiz_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((lapiz_window_parent_class)), ((ctk_widget_get_type ()))) )))->window_state_event (widget, event); | |||
271 | } | |||
272 | ||||
273 | static gboolean | |||
274 | lapiz_window_configure_event (CtkWidget *widget, | |||
275 | CdkEventConfigure *event) | |||
276 | { | |||
277 | LapizWindow *window = LAPIZ_WINDOW (widget)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((lapiz_window_get_type())))))); | |||
278 | ||||
279 | window->priv->width = event->width; | |||
280 | window->priv->height = event->height; | |||
281 | ||||
282 | return CTK_WIDGET_CLASS (lapiz_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((lapiz_window_parent_class)), ((ctk_widget_get_type ()))) )))->configure_event (widget, event); | |||
283 | } | |||
284 | ||||
285 | /* | |||
286 | * CtkWindow catches keybindings for the menu items _before_ passing them to | |||
287 | * the focused widget. This is unfortunate and means that pressing ctrl+V | |||
288 | * in an entry on a panel ends up pasting text in the TextView. | |||
289 | * Here we override CtkWindow's handler to do the same things that it | |||
290 | * does, but in the opposite order and then we chain up to the grand | |||
291 | * parent handler, skipping ctk_window_key_press_event. | |||
292 | */ | |||
293 | static gboolean | |||
294 | lapiz_window_key_press_event (CtkWidget *widget, | |||
295 | CdkEventKey *event) | |||
296 | { | |||
297 | static gpointer grand_parent_class = NULL((void*)0); | |||
298 | CtkWindow *window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); | |||
299 | gboolean handled = FALSE(0); | |||
300 | ||||
301 | if (event->state & CDK_CONTROL_MASK) | |||
| ||||
302 | { | |||
303 | gchar *font; | |||
304 | gchar *tempsize; | |||
305 | gint nsize; | |||
306 | ||||
307 | font = g_settings_get_string (lapiz_prefs_manager->settings, "editor-font"); | |||
308 | tempsize = g_strdup (font)g_strdup_inline (font); | |||
309 | ||||
310 | g_strreverse (tempsize); | |||
311 | g_strcanon (tempsize, "1234567890", '\0'); | |||
312 | g_strreverse (tempsize); | |||
313 | ||||
314 | gchar tempfont [strlen (font)]; | |||
315 | strcpy (tempfont, font); | |||
| ||||
316 | tempfont [strlen (font) - strlen (tempsize)] = 0; | |||
317 | ||||
318 | sscanf (tempsize, "%d", &nsize); | |||
319 | ||||
320 | if ((event->keyval == CDK_KEY_plus0x02b) || (event->keyval == CDK_KEY_KP_Add0xffab)) | |||
321 | { | |||
322 | nsize = nsize + 1; | |||
323 | sprintf (tempsize, "%d", nsize); | |||
324 | ||||
325 | if (!g_settings_get_boolean (lapiz_prefs_manager->settings, "use-default-font") && (nsize < 73)) | |||
326 | { | |||
327 | gchar *tmp = g_strconcat (tempfont, tempsize, NULL((void*)0)); | |||
328 | g_settings_set_string (lapiz_prefs_manager->settings, "editor-font", tmp); | |||
329 | g_free (tmp); | |||
330 | } | |||
331 | } | |||
332 | else if ((event->keyval == CDK_KEY_minus0x02d) || (event->keyval == CDK_KEY_KP_Subtract0xffad)) | |||
333 | { | |||
334 | nsize = nsize - 1; | |||
335 | sprintf (tempsize, "%d", nsize); | |||
336 | ||||
337 | if (!g_settings_get_boolean (lapiz_prefs_manager->settings, "use-default-font") && (nsize > 5)) | |||
338 | { | |||
339 | gchar *tmp = g_strconcat (tempfont, tempsize, NULL((void*)0)); | |||
340 | g_settings_set_string (lapiz_prefs_manager->settings, "editor-font", tmp); | |||
341 | g_free (tmp); | |||
342 | } | |||
343 | } | |||
344 | ||||
345 | if (g_settings_get_boolean (lapiz_prefs_manager->settings, "ctrl-tab-switch-tabs")) | |||
346 | { | |||
347 | CtkNotebook *notebook = CTK_NOTEBOOK (_lapiz_window_get_notebook (LAPIZ_WINDOW (window)))((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((_lapiz_window_get_notebook (((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((lapiz_window_get_type()))))) )))), ((ctk_notebook_get_type ())))))); | |||
348 | ||||
349 | int pages = ctk_notebook_get_n_pages (notebook); | |||
350 | int page_num = ctk_notebook_get_current_page (notebook); | |||
351 | ||||
352 | if (event->keyval == CDK_KEY_ISO_Left_Tab0xfe20) | |||
353 | { | |||
354 | if (page_num != 0) | |||
355 | ctk_notebook_prev_page (notebook); | |||
356 | else | |||
357 | ctk_notebook_set_current_page (notebook, (pages - 1)); | |||
358 | handled = TRUE(!(0)); | |||
359 | } | |||
360 | ||||
361 | if (event->keyval == CDK_KEY_Tab0xff09) | |||
362 | { | |||
363 | if (page_num != (pages -1)) | |||
364 | ctk_notebook_next_page (notebook); | |||
365 | else | |||
366 | ctk_notebook_set_current_page (notebook, 0); | |||
367 | handled = TRUE(!(0)); | |||
368 | } | |||
369 | } | |||
370 | g_free (font); | |||
371 | g_free (tempsize); | |||
372 | } | |||
373 | ||||
374 | if (grand_parent_class == NULL((void*)0)) | |||
375 | grand_parent_class = g_type_class_peek_parent (lapiz_window_parent_class); | |||
376 | ||||
377 | /* handle focus widget key events */ | |||
378 | if (!handled) | |||
379 | handled = ctk_window_propagate_key_event (window, event); | |||
380 | ||||
381 | /* handle mnemonics and accelerators */ | |||
382 | if (!handled) | |||
383 | handled = ctk_window_activate_key (window, event); | |||
384 | ||||
385 | /* Chain up, invokes binding set */ | |||
386 | if (!handled) | |||
387 | handled = CTK_WIDGET_CLASS (grand_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((grand_parent_class)), ((ctk_widget_get_type ()))))))->key_press_event (widget, event); | |||
388 | ||||
389 | return handled; | |||
390 | } | |||
391 | ||||
392 | static void | |||
393 | lapiz_window_tab_removed (LapizWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
394 | LapizTab *tab G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
395 | { | |||
396 | bean_engine_garbage_collect (BEAN_ENGINE (lapiz_plugins_engine_get_default ())((((BeanEngine*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_plugins_engine_get_default ())), ((bean_engine_get_type ()))))))); | |||
397 | } | |||
398 | ||||
399 | static void | |||
400 | lapiz_window_class_init (LapizWindowClass *klass) | |||
401 | { | |||
402 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
403 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); | |||
404 | ||||
405 | klass->tab_removed = lapiz_window_tab_removed; | |||
406 | ||||
407 | object_class->dispose = lapiz_window_dispose; | |||
408 | object_class->finalize = lapiz_window_finalize; | |||
409 | object_class->get_property = lapiz_window_get_property; | |||
410 | ||||
411 | widget_class->window_state_event = lapiz_window_window_state_event; | |||
412 | widget_class->configure_event = lapiz_window_configure_event; | |||
413 | widget_class->key_press_event = lapiz_window_key_press_event; | |||
414 | ||||
415 | signals[TAB_ADDED] = | |||
416 | g_signal_new ("tab_added", | |||
417 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), | |||
418 | G_SIGNAL_RUN_FIRST, | |||
419 | G_STRUCT_OFFSET (LapizWindowClass, tab_added)((glong) __builtin_offsetof(LapizWindowClass, tab_added)), | |||
420 | NULL((void*)0), NULL((void*)0), | |||
421 | g_cclosure_marshal_VOID__OBJECT, | |||
422 | G_TYPE_NONE((GType) ((1) << (2))), | |||
423 | 1, | |||
424 | LAPIZ_TYPE_TAB(lapiz_tab_get_type())); | |||
425 | signals[TAB_REMOVED] = | |||
426 | g_signal_new ("tab_removed", | |||
427 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), | |||
428 | G_SIGNAL_RUN_FIRST, | |||
429 | G_STRUCT_OFFSET (LapizWindowClass, tab_removed)((glong) __builtin_offsetof(LapizWindowClass, tab_removed)), | |||
430 | NULL((void*)0), NULL((void*)0), | |||
431 | g_cclosure_marshal_VOID__OBJECT, | |||
432 | G_TYPE_NONE((GType) ((1) << (2))), | |||
433 | 1, | |||
434 | LAPIZ_TYPE_TAB(lapiz_tab_get_type())); | |||
435 | signals[TABS_REORDERED] = | |||
436 | g_signal_new ("tabs_reordered", | |||
437 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), | |||
438 | G_SIGNAL_RUN_FIRST, | |||
439 | G_STRUCT_OFFSET (LapizWindowClass, tabs_reordered)((glong) __builtin_offsetof(LapizWindowClass, tabs_reordered) ), | |||
440 | NULL((void*)0), NULL((void*)0), | |||
441 | g_cclosure_marshal_VOID__VOID, | |||
442 | G_TYPE_NONE((GType) ((1) << (2))), | |||
443 | 0); | |||
444 | signals[ACTIVE_TAB_CHANGED] = | |||
445 | g_signal_new ("active_tab_changed", | |||
446 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), | |||
447 | G_SIGNAL_RUN_FIRST, | |||
448 | G_STRUCT_OFFSET (LapizWindowClass, active_tab_changed)((glong) __builtin_offsetof(LapizWindowClass, active_tab_changed )), | |||
449 | NULL((void*)0), NULL((void*)0), | |||
450 | g_cclosure_marshal_VOID__OBJECT, | |||
451 | G_TYPE_NONE((GType) ((1) << (2))), | |||
452 | 1, | |||
453 | LAPIZ_TYPE_TAB(lapiz_tab_get_type())); | |||
454 | signals[ACTIVE_TAB_STATE_CHANGED] = | |||
455 | g_signal_new ("active_tab_state_changed", | |||
456 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), | |||
457 | G_SIGNAL_RUN_FIRST, | |||
458 | G_STRUCT_OFFSET (LapizWindowClass, active_tab_state_changed)((glong) __builtin_offsetof(LapizWindowClass, active_tab_state_changed )), | |||
459 | NULL((void*)0), NULL((void*)0), | |||
460 | g_cclosure_marshal_VOID__VOID, | |||
461 | G_TYPE_NONE((GType) ((1) << (2))), | |||
462 | 0); | |||
463 | ||||
464 | g_object_class_install_property (object_class, | |||
465 | PROP_STATE, | |||
466 | g_param_spec_flags ("state", | |||
467 | "State", | |||
468 | "The window's state", | |||
469 | LAPIZ_TYPE_WINDOW_STATE(lapiz_window_state_get_type()), | |||
470 | LAPIZ_WINDOW_STATE_NORMAL, | |||
471 | G_PARAM_READABLE | | |||
472 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB ))); | |||
473 | } | |||
474 | ||||
475 | static void | |||
476 | menu_item_select_cb (CtkMenuItem *proxy, | |||
477 | LapizWindow *window) | |||
478 | { | |||
479 | CtkAction *action; | |||
480 | char *message; | |||
481 | ||||
482 | action = ctk_activatable_get_related_action (CTK_ACTIVATABLE (proxy)((((CtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((proxy)), ((ctk_activatable_get_type ()))))))); | |||
483 | g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action != NULL") ; return; } } while (0); | |||
484 | ||||
485 | g_object_get (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "tooltip", &message, NULL((void*)0)); | |||
486 | if (message) | |||
487 | { | |||
488 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | |||
489 | window->priv->tip_message_cid, message); | |||
490 | g_free (message); | |||
491 | } | |||
492 | } | |||
493 | ||||
494 | static void | |||
495 | menu_item_deselect_cb (CtkMenuItem *proxy G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
496 | LapizWindow *window) | |||
497 | { | |||
498 | ctk_statusbar_pop (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | |||
499 | window->priv->tip_message_cid); | |||
500 | } | |||
501 | ||||
502 | static void | |||
503 | connect_proxy_cb (CtkUIManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
504 | CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
505 | CtkWidget *proxy, | |||
506 | LapizWindow *window) | |||
507 | { | |||
508 | if (CTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (proxy)); GType __t = ((ctk_menu_item_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; }))))) | |||
509 | { | |||
510 | g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
511 | G_CALLBACK (menu_item_select_cb), window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
512 | g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
513 | G_CALLBACK (menu_item_deselect_cb), window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
514 | } | |||
515 | } | |||
516 | ||||
517 | static void | |||
518 | disconnect_proxy_cb (CtkUIManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
519 | CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
520 | CtkWidget *proxy, | |||
521 | LapizWindow *window) | |||
522 | { | |||
523 | if (CTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (proxy)); GType __t = ((ctk_menu_item_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; }))))) | |||
524 | { | |||
525 | g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_select_cb))), (window)) | |||
526 | (proxy, G_CALLBACK (menu_item_select_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_select_cb))), (window)); | |||
527 | g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_deselect_cb))), (window)) | |||
528 | (proxy, G_CALLBACK (menu_item_deselect_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_deselect_cb))), (window)); | |||
529 | } | |||
530 | } | |||
531 | ||||
532 | static void | |||
533 | apply_toolbar_style (LapizWindow *window, | |||
534 | CtkWidget *toolbar) | |||
535 | { | |||
536 | switch (window->priv->toolbar_style) | |||
537 | { | |||
538 | case LAPIZ_TOOLBAR_SYSTEM: | |||
539 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 539, ((const char*) (__func__ )), "LAPIZ: SYSTEM"); | |||
540 | ctk_toolbar_unset_style ( | |||
541 | CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ()))))))); | |||
542 | break; | |||
543 | ||||
544 | case LAPIZ_TOOLBAR_ICONS: | |||
545 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 545, ((const char*) (__func__ )), "LAPIZ: ICONS"); | |||
546 | ctk_toolbar_set_style ( | |||
547 | CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), | |||
548 | CTK_TOOLBAR_ICONS); | |||
549 | break; | |||
550 | ||||
551 | case LAPIZ_TOOLBAR_ICONS_AND_TEXT: | |||
552 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 552, ((const char*) (__func__ )), "LAPIZ: ICONS_AND_TEXT"); | |||
553 | ctk_toolbar_set_style ( | |||
554 | CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), | |||
555 | CTK_TOOLBAR_BOTH); | |||
556 | break; | |||
557 | ||||
558 | case LAPIZ_TOOLBAR_ICONS_BOTH_HORIZ: | |||
559 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 559, ((const char*) (__func__ )), "LAPIZ: ICONS_BOTH_HORIZ"); | |||
560 | ctk_toolbar_set_style ( | |||
561 | CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), | |||
562 | CTK_TOOLBAR_BOTH_HORIZ); | |||
563 | break; | |||
564 | } | |||
565 | } | |||
566 | ||||
567 | /* Returns TRUE if toolbar is visible */ | |||
568 | static gboolean | |||
569 | set_toolbar_style (LapizWindow *window, | |||
570 | LapizWindow *origin) | |||
571 | { | |||
572 | gboolean visible; | |||
573 | LapizToolbarSetting style; | |||
574 | CtkAction *action; | |||
575 | ||||
576 | if (origin == NULL((void*)0)) | |||
577 | visible = lapiz_prefs_manager_get_toolbar_visible (); | |||
578 | else | |||
579 | visible = ctk_widget_get_visible (origin->priv->toolbar); | |||
580 | ||||
581 | /* Set visibility */ | |||
582 | if (visible) | |||
583 | ctk_widget_show (window->priv->toolbar); | |||
584 | else | |||
585 | ctk_widget_hide (window->priv->toolbar); | |||
586 | ||||
587 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
588 | "ViewToolbar"); | |||
589 | ||||
590 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
591 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
592 | ||||
593 | /* Set style */ | |||
594 | if (origin == NULL((void*)0)) | |||
595 | style = lapiz_prefs_manager_get_toolbar_buttons_style (); | |||
596 | else | |||
597 | style = origin->priv->toolbar_style; | |||
598 | ||||
599 | window->priv->toolbar_style = style; | |||
600 | ||||
601 | apply_toolbar_style (window, window->priv->toolbar); | |||
602 | ||||
603 | return visible; | |||
604 | } | |||
605 | ||||
606 | static void | |||
607 | update_next_prev_doc_sensitivity (LapizWindow *window, | |||
608 | LapizTab *tab) | |||
609 | { | |||
610 | gint tab_number; | |||
611 | CtkNotebook *notebook; | |||
612 | CtkAction *action; | |||
613 | ||||
614 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 614, ((const char*) (__func__ ))); | |||
615 | ||||
616 | notebook = CTK_NOTEBOOK (_lapiz_window_get_notebook (window))((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((_lapiz_window_get_notebook (window))), ((ctk_notebook_get_type ())))))); | |||
617 | ||||
618 | tab_number = ctk_notebook_page_num (notebook, CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((ctk_widget_get_type ()))))))); | |||
619 | g_return_if_fail (tab_number >= 0)do { if ((tab_number >= 0)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "tab_number >= 0" ); return; } } while (0); | |||
620 | ||||
621 | action = ctk_action_group_get_action (window->priv->action_group, | |||
622 | "DocumentsPreviousDocument"); | |||
623 | ctk_action_set_sensitive (action, tab_number != 0); | |||
624 | ||||
625 | action = ctk_action_group_get_action (window->priv->action_group, | |||
626 | "DocumentsNextDocument"); | |||
627 | ctk_action_set_sensitive (action, | |||
628 | tab_number < ctk_notebook_get_n_pages (notebook) - 1); | |||
629 | } | |||
630 | ||||
631 | static void | |||
632 | update_next_prev_doc_sensitivity_per_window (LapizWindow *window) | |||
633 | { | |||
634 | LapizTab *tab; | |||
635 | CtkAction *action; | |||
636 | ||||
637 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 637, ((const char*) (__func__ ))); | |||
638 | ||||
639 | tab = lapiz_window_get_active_tab (window); | |||
640 | if (tab != NULL((void*)0)) | |||
641 | { | |||
642 | update_next_prev_doc_sensitivity (window, tab); | |||
643 | ||||
644 | return; | |||
645 | } | |||
646 | ||||
647 | action = ctk_action_group_get_action (window->priv->action_group, | |||
648 | "DocumentsPreviousDocument"); | |||
649 | ctk_action_set_sensitive (action, FALSE(0)); | |||
650 | ||||
651 | action = ctk_action_group_get_action (window->priv->action_group, | |||
652 | "DocumentsNextDocument"); | |||
653 | ctk_action_set_sensitive (action, FALSE(0)); | |||
654 | ||||
655 | } | |||
656 | ||||
657 | static void | |||
658 | received_clipboard_contents (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
659 | CtkSelectionData *selection_data, | |||
660 | LapizWindow *window) | |||
661 | { | |||
662 | gboolean sens; | |||
663 | CtkAction *action; | |||
664 | ||||
665 | /* getting clipboard contents is async, so we need to | |||
666 | * get the current tab and its state */ | |||
667 | ||||
668 | if (window->priv->active_tab != NULL((void*)0)) | |||
669 | { | |||
670 | LapizTabState state; | |||
671 | gboolean state_normal; | |||
672 | ||||
673 | state = lapiz_tab_get_state (window->priv->active_tab); | |||
674 | state_normal = (state == LAPIZ_TAB_STATE_NORMAL); | |||
675 | ||||
676 | sens = state_normal && | |||
677 | ctk_selection_data_targets_include_text (selection_data); | |||
678 | } | |||
679 | else | |||
680 | { | |||
681 | sens = FALSE(0); | |||
682 | } | |||
683 | ||||
684 | action = ctk_action_group_get_action (window->priv->action_group, | |||
685 | "EditPaste"); | |||
686 | ||||
687 | ctk_action_set_sensitive (action, sens); | |||
688 | ||||
689 | g_object_unref (window); | |||
690 | } | |||
691 | ||||
692 | static void | |||
693 | set_paste_sensitivity_according_to_clipboard (LapizWindow *window, | |||
694 | CtkClipboard *clipboard) | |||
695 | { | |||
696 | CdkDisplay *display; | |||
697 | ||||
698 | display = ctk_clipboard_get_display (clipboard); | |||
699 | ||||
700 | if (cdk_display_supports_selection_notification (display)) | |||
701 | { | |||
702 | ctk_clipboard_request_contents (clipboard, | |||
703 | cdk_atom_intern_static_string ("TARGETS"), | |||
704 | (CtkClipboardReceivedFunc) received_clipboard_contents, | |||
705 | g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window))); | |||
706 | } | |||
707 | else | |||
708 | { | |||
709 | CtkAction *action; | |||
710 | ||||
711 | action = ctk_action_group_get_action (window->priv->action_group, | |||
712 | "EditPaste"); | |||
713 | ||||
714 | /* XFIXES extension not availbale, make | |||
715 | * Paste always sensitive */ | |||
716 | ctk_action_set_sensitive (action, TRUE(!(0))); | |||
717 | } | |||
718 | } | |||
719 | ||||
720 | static void | |||
721 | set_sensitivity_according_to_tab (LapizWindow *window, | |||
722 | LapizTab *tab) | |||
723 | { | |||
724 | LapizDocument *doc; | |||
725 | LapizView *view; | |||
726 | CtkAction *action; | |||
727 | gboolean b; | |||
728 | gboolean state_normal; | |||
729 | gboolean editable; | |||
730 | LapizTabState state; | |||
731 | CtkClipboard *clipboard; | |||
732 | LapizLockdownMask lockdown; | |||
733 | ||||
734 | g_return_if_fail (LAPIZ_TAB (tab))do { if ((((((LapizTab*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((tab)), ((lapiz_tab_get_type())))))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__ )), "LAPIZ_TAB (tab)"); return; } } while (0); | |||
735 | ||||
736 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 736, ((const char*) (__func__ ))); | |||
737 | ||||
738 | lockdown = lapiz_app_get_lockdown (lapiz_app_get_default ()); | |||
739 | ||||
740 | state = lapiz_tab_get_state (tab); | |||
741 | state_normal = (state == LAPIZ_TAB_STATE_NORMAL); | |||
742 | ||||
743 | view = lapiz_tab_get_view (tab); | |||
744 | editable = ctk_text_view_get_editable (CTK_TEXT_VIEW (view)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_text_view_get_type ()))))))); | |||
745 | ||||
746 | doc = LAPIZ_DOCUMENT (ctk_text_view_get_buffer (CTK_TEXT_VIEW (view)))((((LapizDocument*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_text_view_get_buffer (((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), ((ctk_text_view_get_type ()))))) )))), ((lapiz_document_get_type())))))); | |||
747 | ||||
748 | clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | |||
749 | CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69)))); | |||
750 | ||||
751 | action = ctk_action_group_get_action (window->priv->action_group, | |||
752 | "FileSave"); | |||
753 | ||||
754 | if (state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) { | |||
755 | ctk_text_buffer_set_modified (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))), TRUE(!(0))); | |||
756 | } | |||
757 | ||||
758 | ctk_action_set_sensitive (action, | |||
759 | (state_normal || | |||
760 | (state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) || | |||
761 | (state == LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW)) && | |||
762 | !lapiz_document_get_readonly (doc) && | |||
763 | !(lockdown & LAPIZ_LOCKDOWN_SAVE_TO_DISK) && | |||
764 | (cansave) && | |||
765 | (editable)); | |||
766 | ||||
767 | action = ctk_action_group_get_action (window->priv->action_group, | |||
768 | "FileSaveAs"); | |||
769 | ctk_action_set_sensitive (action, | |||
770 | (state_normal || | |||
771 | (state == LAPIZ_TAB_STATE_SAVING_ERROR) || | |||
772 | (state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) || | |||
773 | (state == LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW)) && | |||
774 | !(lockdown & LAPIZ_LOCKDOWN_SAVE_TO_DISK)); | |||
775 | ||||
776 | action = ctk_action_group_get_action (window->priv->action_group, | |||
777 | "FileRevert"); | |||
778 | ctk_action_set_sensitive (action, | |||
779 | (state_normal || | |||
780 | (state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)) && | |||
781 | !lapiz_document_is_untitled (doc)); | |||
782 | ||||
783 | action = ctk_action_group_get_action (window->priv->action_group, | |||
784 | "FilePrintPreview"); | |||
785 | ctk_action_set_sensitive (action, | |||
786 | state_normal && | |||
787 | !(lockdown & LAPIZ_LOCKDOWN_PRINTING)); | |||
788 | ||||
789 | action = ctk_action_group_get_action (window->priv->action_group, | |||
790 | "FilePrint"); | |||
791 | ctk_action_set_sensitive (action, | |||
792 | (state_normal || | |||
793 | (state == LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW)) && | |||
794 | !(lockdown & LAPIZ_LOCKDOWN_PRINTING)); | |||
795 | ||||
796 | action = ctk_action_group_get_action (window->priv->close_action_group, | |||
797 | "FileClose"); | |||
798 | ||||
799 | ctk_action_set_sensitive (action, | |||
800 | (state != LAPIZ_TAB_STATE_CLOSING) && | |||
801 | (state != LAPIZ_TAB_STATE_SAVING) && | |||
802 | (state != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW) && | |||
803 | (state != LAPIZ_TAB_STATE_PRINTING) && | |||
804 | (state != LAPIZ_TAB_STATE_PRINT_PREVIEWING) && | |||
805 | (state != LAPIZ_TAB_STATE_SAVING_ERROR)); | |||
806 | ||||
807 | action = ctk_action_group_get_action (window->priv->action_group, | |||
808 | "EditUndo"); | |||
809 | ctk_action_set_sensitive (action, | |||
810 | state_normal && | |||
811 | ctk_source_buffer_can_undo (CTK_SOURCE_BUFFER (doc)((((CtkSourceBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_source_buffer_get_type ())))))))); | |||
812 | ||||
813 | action = ctk_action_group_get_action (window->priv->action_group, | |||
814 | "EditRedo"); | |||
815 | ctk_action_set_sensitive (action, | |||
816 | state_normal && | |||
817 | ctk_source_buffer_can_redo (CTK_SOURCE_BUFFER (doc)((((CtkSourceBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_source_buffer_get_type ())))))))); | |||
818 | ||||
819 | action = ctk_action_group_get_action (window->priv->action_group, | |||
820 | "EditCut"); | |||
821 | ctk_action_set_sensitive (action, | |||
822 | state_normal && | |||
823 | editable && | |||
824 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
825 | ||||
826 | action = ctk_action_group_get_action (window->priv->action_group, | |||
827 | "EditCopy"); | |||
828 | ctk_action_set_sensitive (action, | |||
829 | (state_normal || | |||
830 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && | |||
831 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
832 | ||||
833 | action = ctk_action_group_get_action (window->priv->action_group, | |||
834 | "EditPaste"); | |||
835 | if (state_normal && editable) | |||
836 | { | |||
837 | set_paste_sensitivity_according_to_clipboard (window, | |||
838 | clipboard); | |||
839 | } | |||
840 | else | |||
841 | { | |||
842 | ctk_action_set_sensitive (action, FALSE(0)); | |||
843 | } | |||
844 | ||||
845 | action = ctk_action_group_get_action (window->priv->action_group, | |||
846 | "EditDelete"); | |||
847 | ctk_action_set_sensitive (action, | |||
848 | state_normal && | |||
849 | editable && | |||
850 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
851 | ||||
852 | action = ctk_action_group_get_action (window->priv->action_group, | |||
853 | "SearchFind"); | |||
854 | ctk_action_set_sensitive (action, | |||
855 | (state_normal || | |||
856 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)); | |||
857 | ||||
858 | action = ctk_action_group_get_action (window->priv->action_group, | |||
859 | "SearchIncrementalSearch"); | |||
860 | ctk_action_set_sensitive (action, | |||
861 | (state_normal || | |||
862 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)); | |||
863 | ||||
864 | action = ctk_action_group_get_action (window->priv->action_group, | |||
865 | "SearchReplace"); | |||
866 | ctk_action_set_sensitive (action, | |||
867 | state_normal && | |||
868 | editable); | |||
869 | ||||
870 | b = lapiz_document_get_can_search_again (doc); | |||
871 | action = ctk_action_group_get_action (window->priv->action_group, | |||
872 | "SearchFindNext"); | |||
873 | ctk_action_set_sensitive (action, | |||
874 | (state_normal || | |||
875 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b); | |||
876 | ||||
877 | action = ctk_action_group_get_action (window->priv->action_group, | |||
878 | "SearchFindPrevious"); | |||
879 | ctk_action_set_sensitive (action, | |||
880 | (state_normal || | |||
881 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b); | |||
882 | ||||
883 | action = ctk_action_group_get_action (window->priv->action_group, | |||
884 | "SearchClearHighlight"); | |||
885 | ctk_action_set_sensitive (action, | |||
886 | (state_normal || | |||
887 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b); | |||
888 | ||||
889 | action = ctk_action_group_get_action (window->priv->action_group, | |||
890 | "SearchGoToLine"); | |||
891 | ctk_action_set_sensitive (action, | |||
892 | (state_normal || | |||
893 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)); | |||
894 | ||||
895 | action = ctk_action_group_get_action (window->priv->action_group, | |||
896 | "ViewHighlightMode"); | |||
897 | ctk_action_set_sensitive (action, | |||
898 | (state != LAPIZ_TAB_STATE_CLOSING) && | |||
899 | lapiz_prefs_manager_get_enable_syntax_highlighting ()); | |||
900 | ||||
901 | update_next_prev_doc_sensitivity (window, tab); | |||
902 | ||||
903 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
904 | } | |||
905 | ||||
906 | static void | |||
907 | language_toggled (CtkToggleAction *action, | |||
908 | LapizWindow *window) | |||
909 | { | |||
910 | LapizDocument *doc; | |||
911 | CtkSourceLanguage *lang; | |||
912 | const gchar *lang_id; | |||
913 | ||||
914 | if (ctk_toggle_action_get_active (action) == FALSE(0)) | |||
915 | return; | |||
916 | ||||
917 | doc = lapiz_window_get_active_document (window); | |||
918 | if (doc == NULL((void*)0)) | |||
919 | return; | |||
920 | ||||
921 | lang_id = ctk_action_get_name (CTK_ACTION (action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_action_get_type ()))))))); | |||
922 | ||||
923 | if (strcmp (lang_id, LANGUAGE_NONE(const gchar *)"LangNone") == 0) | |||
924 | { | |||
925 | /* Normal (no highlighting) */ | |||
926 | lang = NULL((void*)0); | |||
927 | } | |||
928 | else | |||
929 | { | |||
930 | lang = ctk_source_language_manager_get_language ( | |||
931 | lapiz_get_language_manager (), | |||
932 | lang_id); | |||
933 | if (lang == NULL((void*)0)) | |||
934 | { | |||
935 | g_warning ("Could not get language %s\n", lang_id); | |||
936 | } | |||
937 | } | |||
938 | ||||
939 | lapiz_document_set_language (doc, lang); | |||
940 | } | |||
941 | ||||
942 | static gchar * | |||
943 | escape_section_name (const gchar *name) | |||
944 | { | |||
945 | gchar *ret; | |||
946 | ||||
947 | ret = g_markup_escape_text (name, -1); | |||
948 | ||||
949 | /* Replace '/' with '-' to avoid problems in xml paths */ | |||
950 | g_strdelimit (ret, "/", '-'); | |||
951 | ||||
952 | return ret; | |||
953 | } | |||
954 | ||||
955 | static void | |||
956 | create_language_menu_item (CtkSourceLanguage *lang, | |||
957 | gint index, | |||
958 | guint ui_id, | |||
959 | LapizWindow *window) | |||
960 | { | |||
961 | CtkAction *section_action; | |||
962 | CtkRadioAction *action; | |||
963 | CtkAction *normal_action; | |||
964 | GSList *group; | |||
965 | const gchar *section; | |||
966 | gchar *escaped_section; | |||
967 | const gchar *lang_id; | |||
968 | const gchar *lang_name; | |||
969 | gchar *escaped_lang_name; | |||
970 | gchar *tip; | |||
971 | gchar *path; | |||
972 | ||||
973 | section = ctk_source_language_get_section (lang); | |||
974 | escaped_section = escape_section_name (section); | |||
975 | ||||
976 | /* check if the section submenu exists or create it */ | |||
977 | section_action = ctk_action_group_get_action (window->priv->languages_action_group, | |||
978 | escaped_section); | |||
979 | ||||
980 | if (section_action == NULL((void*)0)) | |||
981 | { | |||
982 | gchar *section_name; | |||
983 | ||||
984 | section_name = lapiz_utils_escape_underscores (section, -1); | |||
985 | ||||
986 | section_action = ctk_action_new (escaped_section, | |||
987 | section_name, | |||
988 | NULL((void*)0), | |||
989 | NULL((void*)0)); | |||
990 | ||||
991 | g_free (section_name); | |||
992 | ||||
993 | ctk_action_group_add_action (window->priv->languages_action_group, | |||
994 | section_action); | |||
995 | g_object_unref (section_action); | |||
996 | ||||
997 | ctk_ui_manager_add_ui (window->priv->manager, | |||
998 | ui_id, | |||
999 | "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder", | |||
1000 | escaped_section, | |||
1001 | escaped_section, | |||
1002 | CTK_UI_MANAGER_MENU, | |||
1003 | FALSE(0)); | |||
1004 | } | |||
1005 | ||||
1006 | /* now add the language item to the section */ | |||
1007 | lang_name = ctk_source_language_get_name (lang); | |||
1008 | lang_id = ctk_source_language_get_id (lang); | |||
1009 | ||||
1010 | escaped_lang_name = lapiz_utils_escape_underscores (lang_name, -1); | |||
1011 | ||||
1012 | tip = g_strdup_printf (_("Use %s highlight mode")gettext ("Use %s highlight mode"), lang_name); | |||
1013 | path = g_strdup_printf ("/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder/%s", | |||
1014 | escaped_section); | |||
1015 | ||||
1016 | action = ctk_radio_action_new (lang_id, | |||
1017 | escaped_lang_name, | |||
1018 | tip, | |||
1019 | NULL((void*)0), | |||
1020 | index); | |||
1021 | ||||
1022 | g_free (escaped_lang_name); | |||
1023 | ||||
1024 | /* Action is added with a NULL accel to make the accel overridable */ | |||
1025 | ctk_action_group_add_action_with_accel (window->priv->languages_action_group, | |||
1026 | CTK_ACTION (action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_action_get_type ())))))), | |||
1027 | NULL((void*)0)); | |||
1028 | g_object_unref (action); | |||
1029 | ||||
1030 | /* add the action to the same radio group of the "Normal" action */ | |||
1031 | normal_action = ctk_action_group_get_action (window->priv->languages_action_group, | |||
1032 | LANGUAGE_NONE(const gchar *)"LangNone"); | |||
1033 | group = ctk_radio_action_get_group (CTK_RADIO_ACTION (normal_action)((((CtkRadioAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((normal_action)), ((ctk_radio_action_get_type ()))))))); | |||
1034 | ctk_radio_action_set_group (action, group); | |||
1035 | ||||
1036 | g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) ( language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1037 | "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) ( language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1038 | G_CALLBACK (language_toggled),g_signal_connect_data ((action), ("activate"), (((GCallback) ( language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1039 | window)g_signal_connect_data ((action), ("activate"), (((GCallback) ( language_toggled))), (window), ((void*)0), (GConnectFlags) 0); | |||
1040 | ||||
1041 | ctk_ui_manager_add_ui (window->priv->manager, | |||
1042 | ui_id, | |||
1043 | path, | |||
1044 | lang_id, | |||
1045 | lang_id, | |||
1046 | CTK_UI_MANAGER_MENUITEM, | |||
1047 | FALSE(0)); | |||
1048 | ||||
1049 | g_free (path); | |||
1050 | g_free (tip); | |||
1051 | g_free (escaped_section); | |||
1052 | } | |||
1053 | ||||
1054 | static void | |||
1055 | create_languages_menu (LapizWindow *window) | |||
1056 | { | |||
1057 | CtkRadioAction *action_none; | |||
1058 | GSList *languages; | |||
1059 | GSList *l; | |||
1060 | guint id; | |||
1061 | gint i; | |||
1062 | ||||
1063 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 1063, ((const char*) (__func__ ))); | |||
1064 | ||||
1065 | /* add the "Plain Text" item before all the others */ | |||
1066 | ||||
1067 | /* Translators: "Plain Text" means that no highlight mode is selected in the | |||
1068 | * "View->Highlight Mode" submenu and so syntax highlighting is disabled */ | |||
1069 | action_none = ctk_radio_action_new (LANGUAGE_NONE(const gchar *)"LangNone", _("Plain Text")gettext ("Plain Text"), | |||
1070 | _("Disable syntax highlighting")gettext ("Disable syntax highlighting"), | |||
1071 | NULL((void*)0), | |||
1072 | -1); | |||
1073 | ||||
1074 | ctk_action_group_add_action (window->priv->languages_action_group, | |||
1075 | CTK_ACTION (action_none)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action_none)), ((ctk_action_get_type ()))))))); | |||
1076 | g_object_unref (action_none); | |||
1077 | ||||
1078 | g_signal_connect (action_none,g_signal_connect_data ((action_none), ("activate"), (((GCallback ) (language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1079 | "activate",g_signal_connect_data ((action_none), ("activate"), (((GCallback ) (language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1080 | G_CALLBACK (language_toggled),g_signal_connect_data ((action_none), ("activate"), (((GCallback ) (language_toggled))), (window), ((void*)0), (GConnectFlags) 0) | |||
1081 | window)g_signal_connect_data ((action_none), ("activate"), (((GCallback ) (language_toggled))), (window), ((void*)0), (GConnectFlags) 0); | |||
1082 | ||||
1083 | id = ctk_ui_manager_new_merge_id (window->priv->manager); | |||
1084 | ||||
1085 | ctk_ui_manager_add_ui (window->priv->manager, | |||
1086 | id, | |||
1087 | "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder", | |||
1088 | LANGUAGE_NONE(const gchar *)"LangNone", | |||
1089 | LANGUAGE_NONE(const gchar *)"LangNone", | |||
1090 | CTK_UI_MANAGER_MENUITEM, | |||
1091 | TRUE(!(0))); | |||
1092 | ||||
1093 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action_none)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action_none)), ((ctk_toggle_action_get_type ())))))), TRUE(!(0))); | |||
1094 | ||||
1095 | /* now add all the known languages */ | |||
1096 | languages = lapiz_language_manager_list_languages_sorted ( | |||
1097 | lapiz_get_language_manager (), | |||
1098 | FALSE(0)); | |||
1099 | ||||
1100 | for (l = languages, i = 0; l != NULL((void*)0); l = l->next, ++i) | |||
1101 | { | |||
1102 | create_language_menu_item (l->data, | |||
1103 | i, | |||
1104 | id, | |||
1105 | window); | |||
1106 | } | |||
1107 | ||||
1108 | g_slist_free (languages); | |||
1109 | } | |||
1110 | ||||
1111 | static void | |||
1112 | update_languages_menu (LapizWindow *window) | |||
1113 | { | |||
1114 | LapizDocument *doc; | |||
1115 | GList *actions; | |||
1116 | GList *l; | |||
1117 | CtkAction *action; | |||
1118 | CtkSourceLanguage *lang; | |||
1119 | const gchar *lang_id; | |||
1120 | ||||
1121 | doc = lapiz_window_get_active_document (window); | |||
1122 | if (doc == NULL((void*)0)) | |||
1123 | return; | |||
1124 | ||||
1125 | lang = lapiz_document_get_language (doc); | |||
1126 | if (lang != NULL((void*)0)) | |||
1127 | lang_id = ctk_source_language_get_id (lang); | |||
1128 | else | |||
1129 | lang_id = LANGUAGE_NONE(const gchar *)"LangNone"; | |||
1130 | ||||
1131 | actions = ctk_action_group_list_actions (window->priv->languages_action_group); | |||
1132 | ||||
1133 | /* prevent recursion */ | |||
1134 | for (l = actions; l != NULL((void*)0); l = l->next) | |||
1135 | { | |||
1136 | g_signal_handlers_block_by_func (CTK_ACTION (l->data),g_signal_handlers_block_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )) | |||
1137 | G_CALLBACK (language_toggled),g_signal_handlers_block_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )) | |||
1138 | window)g_signal_handlers_block_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )); | |||
1139 | } | |||
1140 | ||||
1141 | action = ctk_action_group_get_action (window->priv->languages_action_group, | |||
1142 | lang_id); | |||
1143 | ||||
1144 | 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))); | |||
1145 | ||||
1146 | for (l = actions; l != NULL((void*)0); l = l->next) | |||
1147 | { | |||
1148 | g_signal_handlers_unblock_by_func (CTK_ACTION (l->data),g_signal_handlers_unblock_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )) | |||
1149 | G_CALLBACK (language_toggled),g_signal_handlers_unblock_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )) | |||
1150 | window)g_signal_handlers_unblock_matched ((((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((l->data)), ((ctk_action_get_type ())) ))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (((GCallback) (language_toggled))), (window )); | |||
1151 | } | |||
1152 | ||||
1153 | g_list_free (actions); | |||
1154 | } | |||
1155 | ||||
1156 | void | |||
1157 | _lapiz_recent_add (LapizWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1158 | const gchar *uri, | |||
1159 | const gchar *mime) | |||
1160 | { | |||
1161 | CtkRecentManager *recent_manager; | |||
1162 | CtkRecentData recent_data; | |||
1163 | ||||
1164 | static gchar *groups[2] = { | |||
1165 | "lapiz", | |||
1166 | NULL((void*)0) | |||
1167 | }; | |||
1168 | ||||
1169 | recent_manager = ctk_recent_manager_get_default (); | |||
1170 | ||||
1171 | recent_data.display_name = NULL((void*)0); | |||
1172 | recent_data.description = NULL((void*)0); | |||
1173 | recent_data.mime_type = (gchar *) mime; | |||
1174 | recent_data.app_name = (gchar *) g_get_application_name (); | |||
1175 | recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL((void*)0)); | |||
1176 | recent_data.groups = groups; | |||
1177 | recent_data.is_private = FALSE(0); | |||
1178 | ||||
1179 | ctk_recent_manager_add_full (recent_manager, | |||
1180 | uri, | |||
1181 | &recent_data); | |||
1182 | ||||
1183 | g_free (recent_data.app_exec); | |||
1184 | } | |||
1185 | ||||
1186 | void | |||
1187 | _lapiz_recent_remove (LapizWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1188 | const gchar *uri) | |||
1189 | { | |||
1190 | CtkRecentManager *recent_manager; | |||
1191 | ||||
1192 | recent_manager = ctk_recent_manager_get_default (); | |||
1193 | ||||
1194 | ctk_recent_manager_remove_item (recent_manager, uri, NULL((void*)0)); | |||
1195 | } | |||
1196 | ||||
1197 | static void | |||
1198 | open_recent_file (const gchar *uri, | |||
1199 | LapizWindow *window) | |||
1200 | { | |||
1201 | GSList *uris = NULL((void*)0); | |||
1202 | ||||
1203 | uris = g_slist_prepend (uris, (gpointer) uri); | |||
1204 | ||||
1205 | if (lapiz_commands_load_uris (window, uris, NULL((void*)0), 0) != 1) | |||
1206 | { | |||
1207 | _lapiz_recent_remove (window, uri); | |||
1208 | } | |||
1209 | ||||
1210 | g_slist_free (uris); | |||
1211 | } | |||
1212 | ||||
1213 | static void | |||
1214 | recent_chooser_item_activated (CtkRecentChooser *chooser, | |||
1215 | LapizWindow *window) | |||
1216 | { | |||
1217 | gchar *uri; | |||
1218 | ||||
1219 | uri = ctk_recent_chooser_get_current_uri (chooser); | |||
1220 | ||||
1221 | open_recent_file (uri, window); | |||
1222 | ||||
1223 | g_free (uri); | |||
1224 | } | |||
1225 | ||||
1226 | static void | |||
1227 | recents_menu_activate (CtkAction *action, | |||
1228 | LapizWindow *window) | |||
1229 | { | |||
1230 | CtkRecentInfo *info; | |||
1231 | const gchar *uri; | |||
1232 | ||||
1233 | info = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "ctk-recent-info"); | |||
1234 | g_return_if_fail (info != NULL)do { if ((info != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "info != NULL"); return ; } } while (0); | |||
1235 | ||||
1236 | uri = ctk_recent_info_get_uri (info); | |||
1237 | ||||
1238 | open_recent_file (uri, window); | |||
1239 | } | |||
1240 | ||||
1241 | static gint | |||
1242 | sort_recents_mru (CtkRecentInfo *a, CtkRecentInfo *b) | |||
1243 | { | |||
1244 | return (g_date_time_to_unix (ctk_recent_info_get_modified (b)) - g_date_time_to_unix (ctk_recent_info_get_modified (a))); | |||
1245 | } | |||
1246 | ||||
1247 | static void update_recent_files_menu (LapizWindow *window); | |||
1248 | ||||
1249 | static void | |||
1250 | recent_manager_changed (CtkRecentManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1251 | LapizWindow *window) | |||
1252 | { | |||
1253 | /* regenerate the menu when the model changes */ | |||
1254 | update_recent_files_menu (window); | |||
1255 | } | |||
1256 | ||||
1257 | /* | |||
1258 | * Manually construct the inline recents list in the File menu. | |||
1259 | * Hopefully ctk 2.12 will add support for it. | |||
1260 | */ | |||
1261 | static void | |||
1262 | update_recent_files_menu (LapizWindow *window) | |||
1263 | { | |||
1264 | LapizWindowPrivate *p = window->priv; | |||
1265 | CtkRecentManager *recent_manager; | |||
1266 | gint max_recents; | |||
1267 | GList *actions, *l, *items; | |||
1268 | GList *filtered_items = NULL((void*)0); | |||
1269 | gint i; | |||
1270 | ||||
1271 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 1271, ((const char*) (__func__ ))); | |||
1272 | ||||
1273 | max_recents = lapiz_prefs_manager_get_max_recents (); | |||
1274 | ||||
1275 | g_return_if_fail (p->recents_action_group != NULL)do { if ((p->recents_action_group != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__ )), "p->recents_action_group != NULL"); return; } } while ( 0); | |||
1276 | ||||
1277 | if (p->recents_menu_ui_id != 0) | |||
1278 | ctk_ui_manager_remove_ui (p->manager, | |||
1279 | p->recents_menu_ui_id); | |||
1280 | ||||
1281 | actions = ctk_action_group_list_actions (p->recents_action_group); | |||
1282 | for (l = actions; l != NULL((void*)0); l = l->next) | |||
1283 | { | |||
1284 | g_signal_handlers_disconnect_by_func (CTK_ACTION (l->data),g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (recents_menu_activate ))), (window)) | |||
1285 | G_CALLBACK (recents_menu_activate),g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (recents_menu_activate ))), (window)) | |||
1286 | window)g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (recents_menu_activate ))), (window)); | |||
1287 | ctk_action_group_remove_action (p->recents_action_group, | |||
1288 | CTK_ACTION (l->data)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_action_get_type ()))))))); | |||
1289 | } | |||
1290 | g_list_free (actions); | |||
1291 | ||||
1292 | p->recents_menu_ui_id = ctk_ui_manager_new_merge_id (p->manager); | |||
1293 | ||||
1294 | recent_manager = ctk_recent_manager_get_default (); | |||
1295 | items = ctk_recent_manager_get_items (recent_manager); | |||
1296 | ||||
1297 | /* filter */ | |||
1298 | for (l = items; l != NULL((void*)0); l = l->next) | |||
1299 | { | |||
1300 | CtkRecentInfo *info = l->data; | |||
1301 | ||||
1302 | if (!ctk_recent_info_has_group (info, "lapiz")) | |||
1303 | continue; | |||
1304 | ||||
1305 | filtered_items = g_list_prepend (filtered_items, info); | |||
1306 | } | |||
1307 | ||||
1308 | /* sort */ | |||
1309 | filtered_items = g_list_sort (filtered_items, | |||
1310 | (GCompareFunc) sort_recents_mru); | |||
1311 | ||||
1312 | i = 0; | |||
1313 | for (l = filtered_items; l != NULL((void*)0); l = l->next) | |||
1314 | { | |||
1315 | gchar *action_name; | |||
1316 | const gchar *display_name; | |||
1317 | gchar *escaped; | |||
1318 | gchar *label; | |||
1319 | gchar *uri; | |||
1320 | gchar *ruri; | |||
1321 | gchar *tip; | |||
1322 | CtkAction *action; | |||
1323 | CtkRecentInfo *info = l->data; | |||
1324 | ||||
1325 | /* clamp */ | |||
1326 | if (i >= max_recents) | |||
1327 | break; | |||
1328 | ||||
1329 | i++; | |||
1330 | ||||
1331 | action_name = g_strdup_printf ("recent-info-%d", i); | |||
1332 | ||||
1333 | display_name = ctk_recent_info_get_display_name (info); | |||
1334 | escaped = lapiz_utils_escape_underscores (display_name, -1); | |||
1335 | if (i >= 10) | |||
1336 | label = g_strdup_printf ("%d. %s", | |||
1337 | i, | |||
1338 | escaped); | |||
1339 | else | |||
1340 | label = g_strdup_printf ("_%d. %s", | |||
1341 | i, | |||
1342 | escaped); | |||
1343 | g_free (escaped); | |||
1344 | ||||
1345 | /* ctk_recent_info_get_uri_display (info) is buggy and | |||
1346 | * works only for local files */ | |||
1347 | uri = lapiz_utils_uri_for_display (ctk_recent_info_get_uri (info)); | |||
1348 | ruri = lapiz_utils_replace_home_dir_with_tilde (uri); | |||
1349 | g_free (uri); | |||
1350 | ||||
1351 | /* Translators: %s is a URI */ | |||
1352 | tip = g_strdup_printf (_("Open '%s'")gettext ("Open '%s'"), ruri); | |||
1353 | g_free (ruri); | |||
1354 | ||||
1355 | action = ctk_action_new (action_name, | |||
1356 | label, | |||
1357 | tip, | |||
1358 | NULL((void*)0)); | |||
1359 | ||||
1360 | g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), | |||
1361 | "ctk-recent-info", | |||
1362 | ctk_recent_info_ref (info), | |||
1363 | (GDestroyNotify) ctk_recent_info_unref); | |||
1364 | ||||
1365 | g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) ( recents_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1366 | "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) ( recents_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1367 | G_CALLBACK (recents_menu_activate),g_signal_connect_data ((action), ("activate"), (((GCallback) ( recents_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1368 | window)g_signal_connect_data ((action), ("activate"), (((GCallback) ( recents_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0); | |||
1369 | ||||
1370 | ctk_action_group_add_action (p->recents_action_group, | |||
1371 | action); | |||
1372 | g_object_unref (action); | |||
1373 | ||||
1374 | ctk_ui_manager_add_ui (p->manager, | |||
1375 | p->recents_menu_ui_id, | |||
1376 | "/MenuBar/FileMenu/FileRecentsPlaceholder", | |||
1377 | action_name, | |||
1378 | action_name, | |||
1379 | CTK_UI_MANAGER_MENUITEM, | |||
1380 | FALSE(0)); | |||
1381 | ||||
1382 | g_free (action_name); | |||
1383 | g_free (label); | |||
1384 | g_free (tip); | |||
1385 | } | |||
1386 | ||||
1387 | g_list_free (filtered_items); | |||
1388 | ||||
1389 | g_list_foreach (items, (GFunc) ctk_recent_info_unref, NULL((void*)0)); | |||
1390 | g_list_free (items); | |||
1391 | } | |||
1392 | ||||
1393 | static void | |||
1394 | set_non_homogeneus (CtkWidget *widget, | |||
1395 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
1396 | { | |||
1397 | ctk_tool_item_set_homogeneous (CTK_TOOL_ITEM (widget)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tool_item_get_type ())))))), FALSE(0)); | |||
1398 | } | |||
1399 | ||||
1400 | static void | |||
1401 | toolbar_visibility_changed (CtkWidget *toolbar, | |||
1402 | LapizWindow *window) | |||
1403 | { | |||
1404 | gboolean visible; | |||
1405 | CtkAction *action; | |||
1406 | ||||
1407 | visible = ctk_widget_get_visible (toolbar); | |||
1408 | ||||
1409 | if (lapiz_prefs_manager_toolbar_visible_can_set ()) | |||
1410 | lapiz_prefs_manager_set_toolbar_visible (visible); | |||
1411 | ||||
1412 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
1413 | "ViewToolbar"); | |||
1414 | ||||
1415 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
1416 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
1417 | } | |||
1418 | ||||
1419 | static CtkWidget * | |||
1420 | setup_toolbar_open_button (LapizWindow *window, | |||
1421 | CtkWidget *toolbar) | |||
1422 | { | |||
1423 | CtkRecentManager *recent_manager; | |||
1424 | CtkRecentFilter *filter; | |||
1425 | CtkWidget *toolbar_recent_menu; | |||
1426 | CtkToolItem *open_button; | |||
1427 | CtkAction *action; | |||
1428 | ||||
1429 | recent_manager = ctk_recent_manager_get_default (); | |||
1430 | ||||
1431 | /* recent files menu tool button */ | |||
1432 | toolbar_recent_menu = ctk_recent_chooser_menu_new_for_manager (recent_manager); | |||
1433 | ||||
1434 | ctk_recent_chooser_set_local_only (CTK_RECENT_CHOOSER (toolbar_recent_menu)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((toolbar_recent_menu)), ((ctk_recent_chooser_get_type ())))))), | |||
1435 | FALSE(0)); | |||
1436 | ctk_recent_chooser_set_sort_type (CTK_RECENT_CHOOSER (toolbar_recent_menu)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((toolbar_recent_menu)), ((ctk_recent_chooser_get_type ())))))), | |||
1437 | CTK_RECENT_SORT_MRU); | |||
1438 | ctk_recent_chooser_set_limit (CTK_RECENT_CHOOSER (toolbar_recent_menu)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((toolbar_recent_menu)), ((ctk_recent_chooser_get_type ())))))), | |||
1439 | lapiz_prefs_manager_get_max_recents ()); | |||
1440 | ||||
1441 | filter = ctk_recent_filter_new (); | |||
1442 | ctk_recent_filter_add_group (filter, "lapiz"); | |||
1443 | ctk_recent_chooser_set_filter (CTK_RECENT_CHOOSER (toolbar_recent_menu)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((toolbar_recent_menu)), ((ctk_recent_chooser_get_type ())))))), | |||
1444 | filter); | |||
1445 | ||||
1446 | g_signal_connect (toolbar_recent_menu,g_signal_connect_data ((toolbar_recent_menu), ("item_activated" ), (((GCallback) (recent_chooser_item_activated))), (window), ((void*)0), (GConnectFlags) 0) | |||
1447 | "item_activated",g_signal_connect_data ((toolbar_recent_menu), ("item_activated" ), (((GCallback) (recent_chooser_item_activated))), (window), ((void*)0), (GConnectFlags) 0) | |||
1448 | G_CALLBACK (recent_chooser_item_activated),g_signal_connect_data ((toolbar_recent_menu), ("item_activated" ), (((GCallback) (recent_chooser_item_activated))), (window), ((void*)0), (GConnectFlags) 0) | |||
1449 | window)g_signal_connect_data ((toolbar_recent_menu), ("item_activated" ), (((GCallback) (recent_chooser_item_activated))), (window), ((void*)0), (GConnectFlags) 0); | |||
1450 | ||||
1451 | /* add the custom Open button to the toolbar */ | |||
1452 | open_button = ctk_menu_tool_button_new (ctk_image_new_from_icon_name ("document-open", | |||
1453 | CTK_ICON_SIZE_MENU), | |||
1454 | _("Open a file")gettext ("Open a file")); | |||
1455 | ||||
1456 | ctk_menu_tool_button_set_menu (CTK_MENU_TOOL_BUTTON (open_button)((((CtkMenuToolButton*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((open_button)), ((ctk_menu_tool_button_get_type ())))))), | |||
1457 | toolbar_recent_menu); | |||
1458 | ||||
1459 | ctk_menu_tool_button_set_arrow_tooltip_text (CTK_MENU_TOOL_BUTTON (open_button)((((CtkMenuToolButton*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((open_button)), ((ctk_menu_tool_button_get_type ())))))), | |||
1460 | _("Open a recently used file")gettext ("Open a recently used file")); | |||
1461 | ||||
1462 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
1463 | "FileOpen"); | |||
1464 | g_object_set (action, | |||
1465 | "is_important", TRUE(!(0)), | |||
1466 | "short_label", _("Open")gettext ("Open"), | |||
1467 | NULL((void*)0)); | |||
1468 | ctk_activatable_set_related_action (CTK_ACTIVATABLE (open_button)((((CtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((open_button)), ((ctk_activatable_get_type ())))))), | |||
1469 | action); | |||
1470 | ||||
1471 | ctk_toolbar_insert (CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), | |||
1472 | open_button, | |||
1473 | 1); | |||
1474 | ||||
1475 | return toolbar_recent_menu; | |||
1476 | } | |||
1477 | ||||
1478 | static void | |||
1479 | create_menu_bar_and_toolbar (LapizWindow *window, | |||
1480 | CtkWidget *main_box) | |||
1481 | { | |||
1482 | CtkActionGroup *action_group; | |||
1483 | CtkAction *action; | |||
1484 | CtkUIManager *manager; | |||
1485 | CtkRecentManager *recent_manager; | |||
1486 | GError *error = NULL((void*)0); | |||
1487 | gchar *ui_file; | |||
1488 | ||||
1489 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 1489, ((const char*) (__func__ ))); | |||
1490 | ||||
1491 | manager = ctk_ui_manager_new (); | |||
1492 | window->priv->manager = manager; | |||
1493 | ||||
1494 | ctk_window_add_accel_group (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
1495 | ctk_ui_manager_get_accel_group (manager)); | |||
1496 | ||||
1497 | action_group = ctk_action_group_new ("LapizWindowAlwaysSensitiveActions"); | |||
1498 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1499 | ctk_action_group_add_actions (action_group, | |||
1500 | lapiz_always_sensitive_menu_entries, | |||
1501 | G_N_ELEMENTS (lapiz_always_sensitive_menu_entries)(sizeof (lapiz_always_sensitive_menu_entries) / sizeof ((lapiz_always_sensitive_menu_entries )[0])), | |||
1502 | window); | |||
1503 | ctk_action_group_add_toggle_actions (action_group, | |||
1504 | lapiz_always_sensitive_toggle_menu_entries, | |||
1505 | G_N_ELEMENTS (lapiz_always_sensitive_toggle_menu_entries)(sizeof (lapiz_always_sensitive_toggle_menu_entries) / sizeof ((lapiz_always_sensitive_toggle_menu_entries)[0])), | |||
1506 | window); | |||
1507 | ||||
1508 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1509 | g_object_unref (action_group); | |||
1510 | window->priv->always_sensitive_action_group = action_group; | |||
1511 | ||||
1512 | action_group = ctk_action_group_new ("LapizWindowActions"); | |||
1513 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1514 | ctk_action_group_add_actions (action_group, | |||
1515 | lapiz_menu_entries, | |||
1516 | G_N_ELEMENTS (lapiz_menu_entries)(sizeof (lapiz_menu_entries) / sizeof ((lapiz_menu_entries)[0 ])), | |||
1517 | window); | |||
1518 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1519 | g_object_unref (action_group); | |||
1520 | window->priv->action_group = action_group; | |||
1521 | ||||
1522 | /* set short labels to use in the toolbar */ | |||
1523 | action = ctk_action_group_get_action (action_group, "FileSave"); | |||
1524 | g_object_set (action, "short_label", _("Save")gettext ("Save"), NULL((void*)0)); | |||
1525 | action = ctk_action_group_get_action (action_group, "FilePrint"); | |||
1526 | g_object_set (action, "short_label", _("Print")gettext ("Print"), NULL((void*)0)); | |||
1527 | action = ctk_action_group_get_action (action_group, "SearchFind"); | |||
1528 | g_object_set (action, "short_label", _("Find")gettext ("Find"), NULL((void*)0)); | |||
1529 | action = ctk_action_group_get_action (action_group, "SearchReplace"); | |||
1530 | g_object_set (action, "short_label", _("Replace")gettext ("Replace"), NULL((void*)0)); | |||
1531 | ||||
1532 | /* set which actions should have priority on the toolbar */ | |||
1533 | action = ctk_action_group_get_action (action_group, "FileSave"); | |||
1534 | g_object_set (action, "is_important", TRUE(!(0)), NULL((void*)0)); | |||
1535 | action = ctk_action_group_get_action (action_group, "EditUndo"); | |||
1536 | g_object_set (action, "is_important", TRUE(!(0)), NULL((void*)0)); | |||
1537 | ||||
1538 | action_group = ctk_action_group_new ("LapizQuitWindowActions"); | |||
1539 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1540 | ctk_action_group_add_actions (action_group, | |||
1541 | lapiz_quit_menu_entries, | |||
1542 | G_N_ELEMENTS (lapiz_quit_menu_entries)(sizeof (lapiz_quit_menu_entries) / sizeof ((lapiz_quit_menu_entries )[0])), | |||
1543 | window); | |||
1544 | ||||
1545 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1546 | g_object_unref (action_group); | |||
1547 | window->priv->quit_action_group = action_group; | |||
1548 | ||||
1549 | action_group = ctk_action_group_new ("LapizCloseWindowActions"); | |||
1550 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1551 | ctk_action_group_add_actions (action_group, | |||
1552 | lapiz_close_menu_entries, | |||
1553 | G_N_ELEMENTS (lapiz_close_menu_entries)(sizeof (lapiz_close_menu_entries) / sizeof ((lapiz_close_menu_entries )[0])), | |||
1554 | window); | |||
1555 | ||||
1556 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1557 | g_object_unref (action_group); | |||
1558 | window->priv->close_action_group = action_group; | |||
1559 | ||||
1560 | action_group = ctk_action_group_new ("LapizWindowPanesActions"); | |||
1561 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1562 | ctk_action_group_add_toggle_actions (action_group, | |||
1563 | lapiz_panes_toggle_menu_entries, | |||
1564 | G_N_ELEMENTS (lapiz_panes_toggle_menu_entries)(sizeof (lapiz_panes_toggle_menu_entries) / sizeof ((lapiz_panes_toggle_menu_entries )[0])), | |||
1565 | window); | |||
1566 | ||||
1567 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1568 | g_object_unref (action_group); | |||
1569 | window->priv->panes_action_group = action_group; | |||
1570 | ||||
1571 | /* now load the UI definition */ | |||
1572 | ui_file = lapiz_dirs_get_ui_file (LAPIZ_UIFILE"lapiz-ui.xml"); | |||
1573 | ctk_ui_manager_add_ui_from_file (manager, ui_file, &error); | |||
1574 | if (error != NULL((void*)0)) | |||
1575 | { | |||
1576 | g_warning ("Could not merge %s: %s", ui_file, error->message); | |||
1577 | g_error_free (error); | |||
1578 | } | |||
1579 | g_free (ui_file); | |||
1580 | ||||
1581 | /* show tooltips in the statusbar */ | |||
1582 | g_signal_connect (manager,g_signal_connect_data ((manager), ("connect_proxy"), (((GCallback ) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
1583 | "connect_proxy",g_signal_connect_data ((manager), ("connect_proxy"), (((GCallback ) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
1584 | G_CALLBACK (connect_proxy_cb),g_signal_connect_data ((manager), ("connect_proxy"), (((GCallback ) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
1585 | window)g_signal_connect_data ((manager), ("connect_proxy"), (((GCallback ) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0); | |||
1586 | g_signal_connect (manager,g_signal_connect_data ((manager), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1587 | "disconnect_proxy",g_signal_connect_data ((manager), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1588 | G_CALLBACK (disconnect_proxy_cb),g_signal_connect_data ((manager), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1589 | window)g_signal_connect_data ((manager), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
1590 | ||||
1591 | /* recent files menu */ | |||
1592 | action_group = ctk_action_group_new ("RecentFilesActions"); | |||
1593 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1594 | window->priv->recents_action_group = action_group; | |||
1595 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1596 | g_object_unref (action_group); | |||
1597 | ||||
1598 | recent_manager = ctk_recent_manager_get_default (); | |||
1599 | window->priv->recents_handler_id = g_signal_connect (recent_manager,g_signal_connect_data ((recent_manager), ("changed"), (((GCallback ) (recent_manager_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1600 | "changed",g_signal_connect_data ((recent_manager), ("changed"), (((GCallback ) (recent_manager_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1601 | G_CALLBACK (recent_manager_changed),g_signal_connect_data ((recent_manager), ("changed"), (((GCallback ) (recent_manager_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1602 | window)g_signal_connect_data ((recent_manager), ("changed"), (((GCallback ) (recent_manager_changed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
1603 | update_recent_files_menu (window); | |||
1604 | ||||
1605 | /* languages menu */ | |||
1606 | action_group = ctk_action_group_new ("LanguagesActions"); | |||
1607 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1608 | window->priv->languages_action_group = action_group; | |||
1609 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1610 | g_object_unref (action_group); | |||
1611 | create_languages_menu (window); | |||
1612 | ||||
1613 | /* list of open documents menu */ | |||
1614 | action_group = ctk_action_group_new ("DocumentsListActions"); | |||
1615 | ctk_action_group_set_translation_domain (action_group, NULL((void*)0)); | |||
1616 | window->priv->documents_list_action_group = action_group; | |||
1617 | ctk_ui_manager_insert_action_group (manager, action_group, 0); | |||
1618 | g_object_unref (action_group); | |||
1619 | ||||
1620 | window->priv->menubar = ctk_ui_manager_get_widget (manager, "/MenuBar"); | |||
1621 | ctk_box_pack_start (CTK_BOX (main_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_box)), ((ctk_box_get_type ())))))), | |||
1622 | window->priv->menubar, | |||
1623 | FALSE(0), | |||
1624 | FALSE(0), | |||
1625 | 0); | |||
1626 | ||||
1627 | window->priv->toolbar = ctk_ui_manager_get_widget (manager, "/ToolBar"); | |||
1628 | ctk_style_context_add_class (ctk_widget_get_style_context (window->priv->toolbar), | |||
1629 | CTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar"); | |||
1630 | ctk_box_pack_start (CTK_BOX (main_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_box)), ((ctk_box_get_type ())))))), | |||
1631 | window->priv->toolbar, | |||
1632 | FALSE(0), | |||
1633 | FALSE(0), | |||
1634 | 0); | |||
1635 | ||||
1636 | set_toolbar_style (window, NULL((void*)0)); | |||
1637 | ||||
1638 | window->priv->toolbar_recent_menu = setup_toolbar_open_button (window, | |||
1639 | window->priv->toolbar); | |||
1640 | ||||
1641 | ctk_container_foreach (CTK_CONTAINER (window->priv->toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->toolbar)), ((ctk_container_get_type ( ))))))), | |||
1642 | (CtkCallback)set_non_homogeneus, | |||
1643 | NULL((void*)0)); | |||
1644 | ||||
1645 | g_signal_connect_after (G_OBJECT (window->priv->toolbar),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("show"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1646 | "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("show"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1647 | G_CALLBACK (toolbar_visibility_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("show"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1648 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("show"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER); | |||
1649 | g_signal_connect_after (G_OBJECT (window->priv->toolbar),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("hide"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1650 | "hide",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("hide"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1651 | G_CALLBACK (toolbar_visibility_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("hide"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
1652 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->toolbar)), (((GType) ((20) << (2))))))))), ("hide"), (((GCallback) (toolbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER); | |||
1653 | } | |||
1654 | ||||
1655 | static void | |||
1656 | documents_list_menu_activate (CtkToggleAction *action, | |||
1657 | LapizWindow *window) | |||
1658 | { | |||
1659 | gint n; | |||
1660 | ||||
1661 | if (ctk_toggle_action_get_active (action) == FALSE(0)) | |||
1662 | return; | |||
1663 | ||||
1664 | n = ctk_radio_action_get_current_value (CTK_RADIO_ACTION (action)((((CtkRadioAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_radio_action_get_type ()))))))); | |||
1665 | ctk_notebook_set_current_page (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), n); | |||
1666 | } | |||
1667 | ||||
1668 | static gchar * | |||
1669 | get_menu_tip_for_tab (LapizTab *tab) | |||
1670 | { | |||
1671 | LapizDocument *doc; | |||
1672 | gchar *uri; | |||
1673 | gchar *ruri; | |||
1674 | gchar *tip; | |||
1675 | ||||
1676 | doc = lapiz_tab_get_document (tab); | |||
1677 | ||||
1678 | uri = lapiz_document_get_uri_for_display (doc); | |||
1679 | ruri = lapiz_utils_replace_home_dir_with_tilde (uri); | |||
1680 | g_free (uri); | |||
1681 | ||||
1682 | /* Translators: %s is a URI */ | |||
1683 | tip = g_strdup_printf (_("Activate '%s'")gettext ("Activate '%s'"), ruri); | |||
1684 | g_free (ruri); | |||
1685 | ||||
1686 | return tip; | |||
1687 | } | |||
1688 | ||||
1689 | static void | |||
1690 | update_documents_list_menu (LapizWindow *window) | |||
1691 | { | |||
1692 | LapizWindowPrivate *p = window->priv; | |||
1693 | GList *actions, *l; | |||
1694 | gint n, i; | |||
1695 | guint id; | |||
1696 | GSList *group = NULL((void*)0); | |||
1697 | ||||
1698 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 1698, ((const char*) (__func__ ))); | |||
1699 | ||||
1700 | g_return_if_fail (p->documents_list_action_group != NULL)do { if ((p->documents_list_action_group != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char *) (__func__)), "p->documents_list_action_group != NULL"); return; } } while (0); | |||
1701 | ||||
1702 | if (p->documents_list_menu_ui_id != 0) | |||
1703 | ctk_ui_manager_remove_ui (p->manager, | |||
1704 | p->documents_list_menu_ui_id); | |||
1705 | ||||
1706 | actions = ctk_action_group_list_actions (p->documents_list_action_group); | |||
1707 | for (l = actions; l != NULL((void*)0); l = l->next) | |||
1708 | { | |||
1709 | g_signal_handlers_disconnect_by_func (CTK_ACTION (l->data),g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (documents_list_menu_activate ))), (window)) | |||
1710 | G_CALLBACK (documents_list_menu_activate),g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (documents_list_menu_activate ))), (window)) | |||
1711 | window)g_signal_handlers_disconnect_matched ((((((CtkAction*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((l->data)) , ((ctk_action_get_type ()))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (documents_list_menu_activate ))), (window)); | |||
1712 | ctk_action_group_remove_action (p->documents_list_action_group, | |||
1713 | CTK_ACTION (l->data)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_action_get_type ()))))))); | |||
1714 | } | |||
1715 | g_list_free (actions); | |||
1716 | ||||
1717 | n = ctk_notebook_get_n_pages (CTK_NOTEBOOK (p->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p->notebook)), ((ctk_notebook_get_type ()))))))); | |||
1718 | ||||
1719 | id = (n > 0) ? ctk_ui_manager_new_merge_id (p->manager) : 0; | |||
1720 | ||||
1721 | for (i = 0; i < n; i++) | |||
1722 | { | |||
1723 | CtkWidget *tab; | |||
1724 | CtkRadioAction *action; | |||
1725 | gchar *action_name; | |||
1726 | gchar *tab_name; | |||
1727 | gchar *name; | |||
1728 | gchar *tip; | |||
1729 | gchar *accel; | |||
1730 | ||||
1731 | tab = ctk_notebook_get_nth_page (CTK_NOTEBOOK (p->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p->notebook)), ((ctk_notebook_get_type ())))))), i); | |||
1732 | ||||
1733 | /* NOTE: the action is associated to the position of the tab in | |||
1734 | * the notebook not to the tab itself! This is needed to work | |||
1735 | * around the ctk+ bug #170727: ctk leaves around the accels | |||
1736 | * of the action. Since the accel depends on the tab position | |||
1737 | * the problem is worked around, action with the same name always | |||
1738 | * get the same accel. | |||
1739 | */ | |||
1740 | action_name = g_strdup_printf ("Tab_%d", i); | |||
1741 | tab_name = _lapiz_tab_get_name (LAPIZ_TAB (tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((lapiz_tab_get_type()))))))); | |||
1742 | name = lapiz_utils_escape_underscores (tab_name, -1); | |||
1743 | tip = get_menu_tip_for_tab (LAPIZ_TAB (tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((lapiz_tab_get_type()))))))); | |||
1744 | ||||
1745 | /* alt + 1, 2, 3... 0 to switch to the first ten tabs */ | |||
1746 | accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL((void*)0); | |||
1747 | ||||
1748 | action = ctk_radio_action_new (action_name, | |||
1749 | name, | |||
1750 | tip, | |||
1751 | NULL((void*)0), | |||
1752 | i); | |||
1753 | ||||
1754 | if (group != NULL((void*)0)) | |||
1755 | ctk_radio_action_set_group (action, group); | |||
1756 | ||||
1757 | /* note that group changes each time we add an action, so it must be updated */ | |||
1758 | group = ctk_radio_action_get_group (action); | |||
1759 | ||||
1760 | ctk_action_group_add_action_with_accel (p->documents_list_action_group, | |||
1761 | CTK_ACTION (action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_action_get_type ())))))), | |||
1762 | accel); | |||
1763 | ||||
1764 | g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) ( documents_list_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1765 | "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) ( documents_list_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1766 | G_CALLBACK (documents_list_menu_activate),g_signal_connect_data ((action), ("activate"), (((GCallback) ( documents_list_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0) | |||
1767 | window)g_signal_connect_data ((action), ("activate"), (((GCallback) ( documents_list_menu_activate))), (window), ((void*)0), (GConnectFlags ) 0); | |||
1768 | ||||
1769 | ctk_ui_manager_add_ui (p->manager, | |||
1770 | id, | |||
1771 | "/MenuBar/DocumentsMenu/DocumentsListPlaceholder", | |||
1772 | action_name, action_name, | |||
1773 | CTK_UI_MANAGER_MENUITEM, | |||
1774 | FALSE(0)); | |||
1775 | ||||
1776 | if (LAPIZ_TAB (tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((lapiz_tab_get_type())))))) == p->active_tab) | |||
1777 | 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))); | |||
1778 | ||||
1779 | g_object_unref (action); | |||
1780 | ||||
1781 | g_free (action_name); | |||
1782 | g_free (tab_name); | |||
1783 | g_free (name); | |||
1784 | g_free (tip); | |||
1785 | g_free (accel); | |||
1786 | } | |||
1787 | ||||
1788 | p->documents_list_menu_ui_id = id; | |||
1789 | } | |||
1790 | ||||
1791 | /* Returns TRUE if status bar is visible */ | |||
1792 | static gboolean | |||
1793 | set_statusbar_style (LapizWindow *window, | |||
1794 | LapizWindow *origin) | |||
1795 | { | |||
1796 | CtkAction *action; | |||
1797 | ||||
1798 | gboolean visible; | |||
1799 | ||||
1800 | if (origin == NULL((void*)0)) | |||
1801 | visible = lapiz_prefs_manager_get_statusbar_visible (); | |||
1802 | else | |||
1803 | visible = ctk_widget_get_visible (origin->priv->statusbar); | |||
1804 | ||||
1805 | if (visible) | |||
1806 | ctk_widget_show (window->priv->statusbar); | |||
1807 | else | |||
1808 | ctk_widget_hide (window->priv->statusbar); | |||
1809 | ||||
1810 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
1811 | "ViewStatusbar"); | |||
1812 | ||||
1813 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
1814 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
1815 | ||||
1816 | return visible; | |||
1817 | } | |||
1818 | ||||
1819 | static void | |||
1820 | statusbar_visibility_changed (CtkWidget *statusbar, | |||
1821 | LapizWindow *window) | |||
1822 | { | |||
1823 | gboolean visible; | |||
1824 | CtkAction *action; | |||
1825 | ||||
1826 | visible = ctk_widget_get_visible (statusbar); | |||
1827 | ||||
1828 | if (lapiz_prefs_manager_statusbar_visible_can_set ()) | |||
1829 | lapiz_prefs_manager_set_statusbar_visible (visible); | |||
1830 | ||||
1831 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
1832 | "ViewStatusbar"); | |||
1833 | ||||
1834 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
1835 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
1836 | } | |||
1837 | ||||
1838 | static void | |||
1839 | tab_width_combo_changed (LapizStatusComboBox *combo G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1840 | CtkMenuItem *item, | |||
1841 | LapizWindow *window) | |||
1842 | { | |||
1843 | LapizView *view; | |||
1844 | guint width_data = 0; | |||
1845 | ||||
1846 | view = lapiz_window_get_active_view (window); | |||
1847 | ||||
1848 | if (!view) | |||
1849 | return; | |||
1850 | ||||
1851 | width_data = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), TAB_WIDTH_DATA))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((item)), (((GType) ((20) << (2))))) ))), "LapizWindowTabWidthData"))); | |||
1852 | ||||
1853 | if (width_data == 0) | |||
1854 | return; | |||
1855 | ||||
1856 | g_signal_handler_block (view, window->priv->tab_width_id); | |||
1857 | ctk_source_view_set_tab_width (CTK_SOURCE_VIEW (view)((((CtkSourceView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_source_view_get_type ())))))), width_data); | |||
1858 | g_signal_handler_unblock (view, window->priv->tab_width_id); | |||
1859 | } | |||
1860 | ||||
1861 | static void | |||
1862 | use_spaces_toggled (CtkCheckMenuItem *item, | |||
1863 | LapizWindow *window) | |||
1864 | { | |||
1865 | LapizView *view; | |||
1866 | ||||
1867 | view = lapiz_window_get_active_view (window); | |||
1868 | ||||
1869 | g_signal_handler_block (view, window->priv->spaces_instead_of_tabs_id); | |||
1870 | ctk_source_view_set_insert_spaces_instead_of_tabs ( | |||
1871 | CTK_SOURCE_VIEW (view)((((CtkSourceView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_source_view_get_type ())))))), | |||
1872 | ctk_check_menu_item_get_active (item)); | |||
1873 | g_signal_handler_unblock (view, window->priv->spaces_instead_of_tabs_id); | |||
1874 | } | |||
1875 | ||||
1876 | static void | |||
1877 | language_combo_changed (LapizStatusComboBox *combo G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1878 | CtkMenuItem *item, | |||
1879 | LapizWindow *window) | |||
1880 | { | |||
1881 | LapizDocument *doc; | |||
1882 | CtkSourceLanguage *language; | |||
1883 | ||||
1884 | doc = lapiz_window_get_active_document (window); | |||
1885 | ||||
1886 | if (!doc) | |||
1887 | return; | |||
1888 | ||||
1889 | language = CTK_SOURCE_LANGUAGE (g_object_get_data (G_OBJECT (item), LANGUAGE_DATA))((((CtkSourceLanguage*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((item)), (((GType) ((20) << (2))))) ))), "LapizWindowLanguageData"))), ((ctk_source_language_get_type ())))))); | |||
1890 | ||||
1891 | g_signal_handler_block (doc, window->priv->language_changed_id); | |||
1892 | lapiz_document_set_language (doc, language); | |||
1893 | g_signal_handler_unblock (doc, window->priv->language_changed_id); | |||
1894 | } | |||
1895 | ||||
1896 | typedef struct | |||
1897 | { | |||
1898 | const gchar *label; | |||
1899 | guint width; | |||
1900 | } TabWidthDefinition; | |||
1901 | ||||
1902 | static void | |||
1903 | fill_tab_width_combo (LapizWindow *window) | |||
1904 | { | |||
1905 | static TabWidthDefinition defs[] = { | |||
1906 | {"2", 2}, | |||
1907 | {"4", 4}, | |||
1908 | {"8", 8}, | |||
1909 | {"", 0}, /* custom size */ | |||
1910 | {NULL((void*)0), 0} | |||
1911 | }; | |||
1912 | ||||
1913 | LapizStatusComboBox *combo = LAPIZ_STATUS_COMBO_BOX (window->priv->tab_width_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( (lapiz_status_combo_box_get_type ())))))); | |||
1914 | guint i = 0; | |||
1915 | CtkWidget *item; | |||
1916 | ||||
1917 | while (defs[i].label != NULL((void*)0)) | |||
1918 | { | |||
1919 | item = ctk_menu_item_new_with_label (defs[i].label); | |||
1920 | g_object_set_data (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), (((GType) ((20) << (2)))))))), TAB_WIDTH_DATA"LapizWindowTabWidthData", GINT_TO_POINTER (defs[i].width)((gpointer) (glong) (defs[i].width))); | |||
1921 | ||||
1922 | lapiz_status_combo_box_add_item (combo, | |||
1923 | CTK_MENU_ITEM (item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_menu_item_get_type ())))))), | |||
1924 | defs[i].label); | |||
1925 | ||||
1926 | if (defs[i].width != 0) | |||
1927 | ctk_widget_show (item); | |||
1928 | ||||
1929 | ++i; | |||
1930 | } | |||
1931 | ||||
1932 | item = ctk_separator_menu_item_new (); | |||
1933 | lapiz_status_combo_box_add_item (combo, CTK_MENU_ITEM (item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_menu_item_get_type ())))))), NULL((void*)0)); | |||
1934 | ctk_widget_show (item); | |||
1935 | ||||
1936 | item = ctk_check_menu_item_new_with_label (_("Use Spaces")gettext ("Use Spaces")); | |||
1937 | lapiz_status_combo_box_add_item (combo, CTK_MENU_ITEM (item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_menu_item_get_type ())))))), NULL((void*)0)); | |||
1938 | ctk_widget_show (item); | |||
1939 | ||||
1940 | g_signal_connect (item,g_signal_connect_data ((item), ("toggled"), (((GCallback) (use_spaces_toggled ))), (window), ((void*)0), (GConnectFlags) 0) | |||
1941 | "toggled",g_signal_connect_data ((item), ("toggled"), (((GCallback) (use_spaces_toggled ))), (window), ((void*)0), (GConnectFlags) 0) | |||
1942 | G_CALLBACK (use_spaces_toggled),g_signal_connect_data ((item), ("toggled"), (((GCallback) (use_spaces_toggled ))), (window), ((void*)0), (GConnectFlags) 0) | |||
1943 | window)g_signal_connect_data ((item), ("toggled"), (((GCallback) (use_spaces_toggled ))), (window), ((void*)0), (GConnectFlags) 0); | |||
1944 | } | |||
1945 | ||||
1946 | static void | |||
1947 | fill_language_combo (LapizWindow *window) | |||
1948 | { | |||
1949 | CtkSourceLanguageManager *manager; | |||
1950 | GSList *languages; | |||
1951 | GSList *item; | |||
1952 | CtkWidget *menu_item; | |||
1953 | const gchar *name; | |||
1954 | ||||
1955 | manager = lapiz_get_language_manager (); | |||
1956 | languages = lapiz_language_manager_list_languages_sorted (manager, FALSE(0)); | |||
1957 | ||||
1958 | name = _("Plain Text")gettext ("Plain Text"); | |||
1959 | menu_item = ctk_menu_item_new_with_label (name); | |||
1960 | ctk_widget_show (menu_item); | |||
1961 | ||||
1962 | g_object_set_data (G_OBJECT (menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), (((GType) ((20) << (2)))))))), LANGUAGE_DATA"LapizWindowLanguageData", NULL((void*)0)); | |||
1963 | lapiz_status_combo_box_add_item (LAPIZ_STATUS_COMBO_BOX (window->priv->language_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( lapiz_status_combo_box_get_type ())))))), | |||
1964 | CTK_MENU_ITEM (menu_item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), ((ctk_menu_item_get_type ())))))), | |||
1965 | name); | |||
1966 | ||||
1967 | for (item = languages; item; item = item->next) | |||
1968 | { | |||
1969 | CtkSourceLanguage *lang = CTK_SOURCE_LANGUAGE (item->data)((((CtkSourceLanguage*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((item->data)), ((ctk_source_language_get_type ())))))); | |||
1970 | ||||
1971 | name = ctk_source_language_get_name (lang); | |||
1972 | menu_item = ctk_menu_item_new_with_label (name); | |||
1973 | ctk_widget_show (menu_item); | |||
1974 | ||||
1975 | g_object_set_data_full (G_OBJECT (menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), (((GType) ((20) << (2)))))))), | |||
1976 | LANGUAGE_DATA"LapizWindowLanguageData", | |||
1977 | g_object_ref (lang)((__typeof__ (lang)) (g_object_ref) (lang)), | |||
1978 | (GDestroyNotify)g_object_unref); | |||
1979 | ||||
1980 | lapiz_status_combo_box_add_item (LAPIZ_STATUS_COMBO_BOX (window->priv->language_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( lapiz_status_combo_box_get_type ())))))), | |||
1981 | CTK_MENU_ITEM (menu_item)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), ((ctk_menu_item_get_type ())))))), | |||
1982 | name); | |||
1983 | } | |||
1984 | ||||
1985 | g_slist_free (languages); | |||
1986 | } | |||
1987 | ||||
1988 | static void | |||
1989 | create_statusbar (LapizWindow *window, | |||
1990 | CtkWidget *main_box) | |||
1991 | { | |||
1992 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 1992, ((const char*) (__func__ ))); | |||
1993 | ||||
1994 | window->priv->statusbar = lapiz_statusbar_new (); | |||
1995 | ||||
1996 | window->priv->generic_message_cid = ctk_statusbar_get_context_id | |||
1997 | (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), "generic_message"); | |||
1998 | window->priv->tip_message_cid = ctk_statusbar_get_context_id | |||
1999 | (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), "tip_message"); | |||
2000 | ||||
2001 | ctk_box_pack_end (CTK_BOX (main_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_box)), ((ctk_box_get_type ())))))), | |||
2002 | window->priv->statusbar, | |||
2003 | FALSE(0), | |||
2004 | TRUE(!(0)), | |||
2005 | 0); | |||
2006 | ||||
2007 | window->priv->tab_width_combo = lapiz_status_combo_box_new (_("Tab Width")gettext ("Tab Width")); | |||
2008 | ctk_widget_show (window->priv->tab_width_combo); | |||
2009 | ctk_box_pack_end (CTK_BOX (window->priv->statusbar)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_box_get_type ())) )))), | |||
2010 | window->priv->tab_width_combo, | |||
2011 | FALSE(0), | |||
2012 | TRUE(!(0)), | |||
2013 | 0); | |||
2014 | ||||
2015 | fill_tab_width_combo (window); | |||
2016 | ||||
2017 | g_signal_connect (G_OBJECT (window->priv->tab_width_combo),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( ((GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (tab_width_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2018 | "changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( ((GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (tab_width_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2019 | G_CALLBACK (tab_width_combo_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( ((GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (tab_width_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2020 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( ((GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (tab_width_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
2021 | ||||
2022 | window->priv->language_combo = lapiz_status_combo_box_new (NULL((void*)0)); | |||
2023 | ctk_widget_show (window->priv->language_combo); | |||
2024 | ctk_box_pack_end (CTK_BOX (window->priv->statusbar)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_box_get_type ())) )))), | |||
2025 | window->priv->language_combo, | |||
2026 | FALSE(0), | |||
2027 | TRUE(!(0)), | |||
2028 | 0); | |||
2029 | ||||
2030 | fill_language_combo (window); | |||
2031 | ||||
2032 | g_signal_connect (G_OBJECT (window->priv->language_combo),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( (GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (language_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2033 | "changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( (GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (language_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2034 | G_CALLBACK (language_combo_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( (GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (language_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2035 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( (GType) ((20) << (2))))))))), ("changed"), (((GCallback ) (language_combo_changed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
2036 | ||||
2037 | g_signal_connect_after (G_OBJECT (window->priv->statusbar),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("show"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2038 | "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("show"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2039 | G_CALLBACK (statusbar_visibility_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("show"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2040 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("show"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER); | |||
2041 | g_signal_connect_after (G_OBJECT (window->priv->statusbar),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("hide"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2042 | "hide",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("hide"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2043 | G_CALLBACK (statusbar_visibility_changed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("hide"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER) | |||
2044 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->statusbar)), (((GType ) ((20) << (2))))))))), ("hide"), (((GCallback) (statusbar_visibility_changed ))), (window), ((void*)0), G_CONNECT_AFTER); | |||
2045 | ||||
2046 | set_statusbar_style (window, NULL((void*)0)); | |||
2047 | } | |||
2048 | ||||
2049 | static LapizWindow * | |||
2050 | clone_window (LapizWindow *origin) | |||
2051 | { | |||
2052 | LapizWindow *window; | |||
2053 | CdkScreen *screen; | |||
2054 | LapizApp *app; | |||
2055 | gint panel_page; | |||
2056 | ||||
2057 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 2057, ((const char*) (__func__ ))); | |||
2058 | ||||
2059 | app = lapiz_app_get_default (); | |||
2060 | ||||
2061 | screen = ctk_window_get_screen (CTK_WINDOW (origin)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((origin)), ((ctk_window_get_type ()))))))); | |||
2062 | window = lapiz_app_create_window (app, screen); | |||
2063 | ||||
2064 | if ((origin->priv->window_state & CDK_WINDOW_STATE_MAXIMIZED) != 0) | |||
2065 | { | |||
2066 | gint w, h; | |||
2067 | ||||
2068 | lapiz_prefs_manager_get_default_window_size (&w, &h); | |||
2069 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), w, h); | |||
2070 | ctk_window_maximize (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2071 | } | |||
2072 | else | |||
2073 | { | |||
2074 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
2075 | origin->priv->width, | |||
2076 | origin->priv->height); | |||
2077 | ||||
2078 | ctk_window_unmaximize (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2079 | } | |||
2080 | ||||
2081 | if ((origin->priv->window_state & CDK_WINDOW_STATE_STICKY ) != 0) | |||
2082 | ctk_window_stick (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2083 | else | |||
2084 | ctk_window_unstick (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2085 | ||||
2086 | /* set the panes size, the paned position will be set when | |||
2087 | * they are mapped */ | |||
2088 | window->priv->side_panel_size = origin->priv->side_panel_size; | |||
2089 | window->priv->bottom_panel_size = origin->priv->bottom_panel_size; | |||
2090 | ||||
2091 | panel_page = _lapiz_panel_get_active_item_id (LAPIZ_PANEL (origin->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((origin->priv->side_panel)), ((lapiz_panel_get_type ()))))))); | |||
2092 | _lapiz_panel_set_active_item_by_id (LAPIZ_PANEL (window->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->side_panel)), ((lapiz_panel_get_type ())))))), | |||
2093 | panel_page); | |||
2094 | ||||
2095 | panel_page = _lapiz_panel_get_active_item_id (LAPIZ_PANEL (origin->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((origin->priv->bottom_panel)), ((lapiz_panel_get_type ()))))))); | |||
2096 | _lapiz_panel_set_active_item_by_id (LAPIZ_PANEL (window->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->bottom_panel)), ((lapiz_panel_get_type ())))))), | |||
2097 | panel_page); | |||
2098 | ||||
2099 | if (ctk_widget_get_visible (origin->priv->side_panel)) | |||
2100 | ctk_widget_show (window->priv->side_panel); | |||
2101 | else | |||
2102 | ctk_widget_hide (window->priv->side_panel); | |||
2103 | ||||
2104 | if (ctk_widget_get_visible (origin->priv->bottom_panel)) | |||
2105 | ctk_widget_show (window->priv->bottom_panel); | |||
2106 | else | |||
2107 | ctk_widget_hide (window->priv->bottom_panel); | |||
2108 | ||||
2109 | set_statusbar_style (window, origin); | |||
2110 | set_toolbar_style (window, origin); | |||
2111 | ||||
2112 | return window; | |||
2113 | } | |||
2114 | ||||
2115 | static void | |||
2116 | update_cursor_position_statusbar (CtkTextBuffer *buffer, | |||
2117 | LapizWindow *window) | |||
2118 | { | |||
2119 | gint row, col; | |||
2120 | CtkTextIter iter; | |||
2121 | CtkTextIter start; | |||
2122 | guint tab_size; | |||
2123 | LapizView *view; | |||
2124 | ||||
2125 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 2125, ((const char*) (__func__ ))); | |||
2126 | ||||
2127 | if (buffer != CTK_TEXT_BUFFER (lapiz_window_get_active_document (window))((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_window_get_active_document (window))), ((ctk_text_buffer_get_type ()))))))) | |||
2128 | return; | |||
2129 | ||||
2130 | view = lapiz_window_get_active_view (window); | |||
2131 | ||||
2132 | ctk_text_buffer_get_iter_at_mark (buffer, | |||
2133 | &iter, | |||
2134 | ctk_text_buffer_get_insert (buffer)); | |||
2135 | ||||
2136 | row = ctk_text_iter_get_line (&iter); | |||
2137 | ||||
2138 | start = iter; | |||
2139 | ctk_text_iter_set_line_offset (&start, 0); | |||
2140 | col = 0; | |||
2141 | ||||
2142 | tab_size = ctk_source_view_get_tab_width (CTK_SOURCE_VIEW (view)((((CtkSourceView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_source_view_get_type ()))))))); | |||
2143 | ||||
2144 | while (!ctk_text_iter_equal (&start, &iter)) | |||
2145 | { | |||
2146 | /* FIXME: Are we Unicode compliant here? */ | |||
2147 | if (ctk_text_iter_get_char (&start) == '\t') | |||
2148 | ||||
2149 | col += (tab_size - (col % tab_size)); | |||
2150 | else | |||
2151 | ++col; | |||
2152 | ||||
2153 | ctk_text_iter_forward_char (&start); | |||
2154 | } | |||
2155 | ||||
2156 | lapiz_statusbar_set_cursor_position ( | |||
2157 | LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
2158 | row + 1, | |||
2159 | col + 1); | |||
2160 | } | |||
2161 | ||||
2162 | static void | |||
2163 | update_overwrite_mode_statusbar (CtkTextView *view, | |||
2164 | LapizWindow *window) | |||
2165 | { | |||
2166 | if (view != CTK_TEXT_VIEW (lapiz_window_get_active_view (window))((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_window_get_active_view (window))), ((ctk_text_view_get_type ()))))))) | |||
2167 | return; | |||
2168 | ||||
2169 | /* Note that we have to use !ctk_text_view_get_overwrite since we | |||
2170 | are in the in the signal handler of "toggle overwrite" that is | |||
2171 | G_SIGNAL_RUN_LAST | |||
2172 | */ | |||
2173 | lapiz_statusbar_set_overwrite ( | |||
2174 | LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
2175 | !ctk_text_view_get_overwrite (view)); | |||
2176 | } | |||
2177 | ||||
2178 | #define MAX_TITLE_LENGTH 100 | |||
2179 | ||||
2180 | static void | |||
2181 | set_title (LapizWindow *window) | |||
2182 | { | |||
2183 | LapizDocument *doc = NULL((void*)0); | |||
2184 | gchar *name; | |||
2185 | gchar *dirname = NULL((void*)0); | |||
2186 | gchar *title = NULL((void*)0); | |||
2187 | gint len; | |||
2188 | CtkAction *action; | |||
2189 | ||||
2190 | if (window->priv->active_tab == NULL((void*)0)) | |||
2191 | { | |||
2192 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), "Lapiz"); | |||
2193 | return; | |||
2194 | } | |||
2195 | ||||
2196 | doc = lapiz_tab_get_document (window->priv->active_tab); | |||
2197 | g_return_if_fail (doc != NULL)do { if ((doc != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "doc != NULL"); return ; } } while (0); | |||
2198 | ||||
2199 | name = lapiz_document_get_short_name_for_display (doc); | |||
2200 | ||||
2201 | len = g_utf8_strlen (name, -1); | |||
2202 | ||||
2203 | /* if the name is awfully long, truncate it and be done with it, | |||
2204 | * otherwise also show the directory (ellipsized if needed) | |||
2205 | */ | |||
2206 | if (len > MAX_TITLE_LENGTH) | |||
2207 | { | |||
2208 | gchar *tmp; | |||
2209 | ||||
2210 | tmp = lapiz_utils_str_middle_truncate (name, | |||
2211 | MAX_TITLE_LENGTH); | |||
2212 | g_free (name); | |||
2213 | name = tmp; | |||
2214 | } | |||
2215 | else | |||
2216 | { | |||
2217 | GFile *file; | |||
2218 | ||||
2219 | file = lapiz_document_get_location (doc); | |||
2220 | if (file != NULL((void*)0)) | |||
2221 | { | |||
2222 | gchar *str; | |||
2223 | ||||
2224 | str = lapiz_utils_location_get_dirname_for_display (file); | |||
2225 | g_object_unref (file); | |||
2226 | ||||
2227 | /* use the remaining space for the dir, but use a min of 20 chars | |||
2228 | * so that we do not end up with a dirname like "(a...b)". | |||
2229 | * This means that in the worst case when the filename is long 99 | |||
2230 | * we have a title long 99 + 20, but I think it's a rare enough | |||
2231 | * case to be acceptable. It's justa darn title afterall :) | |||
2232 | */ | |||
2233 | dirname = lapiz_utils_str_middle_truncate (str, | |||
2234 | MAX (20, MAX_TITLE_LENGTH - len)(((20) > (MAX_TITLE_LENGTH - len)) ? (20) : (MAX_TITLE_LENGTH - len))); | |||
2235 | g_free (str); | |||
2236 | } | |||
2237 | } | |||
2238 | ||||
2239 | if (ctk_text_buffer_get_modified (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))) | |||
2240 | { | |||
2241 | gchar *tmp_name; | |||
2242 | ||||
2243 | tmp_name = g_strdup_printf ("*%s", name); | |||
2244 | g_free (name); | |||
2245 | ||||
2246 | name = tmp_name; | |||
2247 | cansave = TRUE(!(0)); | |||
2248 | } | |||
2249 | else | |||
2250 | cansave = FALSE(0); | |||
2251 | ||||
2252 | if (lapiz_document_get_readonly (doc)) | |||
2253 | { | |||
2254 | if (dirname != NULL((void*)0)) | |||
2255 | title = g_strdup_printf ("%s [%s] (%s) - Lapiz", | |||
2256 | name, | |||
2257 | _("Read-Only")gettext ("Read-Only"), | |||
2258 | dirname); | |||
2259 | else | |||
2260 | title = g_strdup_printf ("%s [%s] - Lapiz", | |||
2261 | name, | |||
2262 | _("Read-Only")gettext ("Read-Only")); | |||
2263 | } | |||
2264 | else | |||
2265 | { | |||
2266 | if (dirname != NULL((void*)0)) | |||
2267 | title = g_strdup_printf ("%s (%s) - Lapiz", | |||
2268 | name, | |||
2269 | dirname); | |||
2270 | else | |||
2271 | title = g_strdup_printf ("%s - Lapiz", | |||
2272 | name); | |||
2273 | } | |||
2274 | ||||
2275 | action = ctk_action_group_get_action (window->priv->action_group, | |||
2276 | "FileSave"); | |||
2277 | ctk_action_set_sensitive (action, cansave); | |||
2278 | ||||
2279 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), title); | |||
2280 | ||||
2281 | g_free (dirname); | |||
2282 | g_free (name); | |||
2283 | g_free (title); | |||
2284 | } | |||
2285 | ||||
2286 | #undef MAX_TITLE_LENGTH | |||
2287 | ||||
2288 | static void | |||
2289 | set_tab_width_item_blocked (LapizWindow *window, | |||
2290 | CtkMenuItem *item) | |||
2291 | { | |||
2292 | g_signal_handlers_block_by_func (window->priv->tab_width_combo,g_signal_handlers_block_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)) | |||
2293 | tab_width_combo_changed,g_signal_handlers_block_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)) | |||
2294 | window)g_signal_handlers_block_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)); | |||
2295 | ||||
2296 | lapiz_status_combo_box_set_item (LAPIZ_STATUS_COMBO_BOX (window->priv->tab_width_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( (lapiz_status_combo_box_get_type ())))))), | |||
2297 | item); | |||
2298 | ||||
2299 | g_signal_handlers_unblock_by_func (window->priv->tab_width_combo,g_signal_handlers_unblock_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)) | |||
2300 | tab_width_combo_changed,g_signal_handlers_unblock_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)) | |||
2301 | window)g_signal_handlers_unblock_matched ((window->priv->tab_width_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (tab_width_combo_changed), (window)); | |||
2302 | } | |||
2303 | ||||
2304 | static void | |||
2305 | spaces_instead_of_tabs_changed (GObject *object, | |||
2306 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2307 | LapizWindow *window) | |||
2308 | { | |||
2309 | LapizView *view = LAPIZ_VIEW (object)((((LapizView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((lapiz_view_get_type ())))))); | |||
2310 | gboolean active = ctk_source_view_get_insert_spaces_instead_of_tabs ( | |||
2311 | CTK_SOURCE_VIEW (view)((((CtkSourceView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_source_view_get_type ()))))))); | |||
2312 | GList *children = lapiz_status_combo_box_get_items ( | |||
2313 | LAPIZ_STATUS_COMBO_BOX (window->priv->tab_width_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( (lapiz_status_combo_box_get_type ()))))))); | |||
2314 | CtkCheckMenuItem *item; | |||
2315 | ||||
2316 | item = CTK_CHECK_MENU_ITEM (g_list_last (children)->data)((((CtkCheckMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((g_list_last (children)->data)), ((ctk_check_menu_item_get_type ())))))); | |||
2317 | ||||
2318 | ctk_check_menu_item_set_active (item, active); | |||
2319 | ||||
2320 | g_list_free (children); | |||
2321 | } | |||
2322 | ||||
2323 | static void | |||
2324 | tab_width_changed (GObject *object, | |||
2325 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2326 | LapizWindow *window) | |||
2327 | { | |||
2328 | GList *items; | |||
2329 | GList *item; | |||
2330 | LapizStatusComboBox *combo = LAPIZ_STATUS_COMBO_BOX (window->priv->tab_width_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tab_width_combo)), ( (lapiz_status_combo_box_get_type ())))))); | |||
2331 | guint new_tab_width; | |||
2332 | gboolean found = FALSE(0); | |||
2333 | ||||
2334 | items = lapiz_status_combo_box_get_items (combo); | |||
2335 | ||||
2336 | new_tab_width = ctk_source_view_get_tab_width (CTK_SOURCE_VIEW (object)((((CtkSourceView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_source_view_get_type ()))))))); | |||
2337 | ||||
2338 | for (item = items; item; item = item->next) | |||
2339 | { | |||
2340 | guint tab_width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), TAB_WIDTH_DATA))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((item->data)), (((GType) ((20) << (2)))))))), "LapizWindowTabWidthData"))); | |||
2341 | ||||
2342 | if (tab_width == new_tab_width) | |||
2343 | { | |||
2344 | set_tab_width_item_blocked (window, CTK_MENU_ITEM (item->data)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_menu_item_get_type ()))))))); | |||
2345 | found = TRUE(!(0)); | |||
2346 | } | |||
2347 | ||||
2348 | if (CTK_IS_SEPARATOR_MENU_ITEM (item->next->data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (item->next->data)); GType __t = ((ctk_separator_menu_item_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; }))))) | |||
2349 | { | |||
2350 | if (!found) | |||
2351 | { | |||
2352 | /* Set for the last item the custom thing */ | |||
2353 | gchar *text; | |||
2354 | ||||
2355 | text = g_strdup_printf ("%u", new_tab_width); | |||
2356 | lapiz_status_combo_box_set_item_text (combo, | |||
2357 | CTK_MENU_ITEM (item->data)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_menu_item_get_type ())))))), | |||
2358 | text); | |||
2359 | ||||
2360 | ctk_label_set_text (CTK_LABEL (ctk_bin_get_child (CTK_BIN (item->data)))((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_bin_get_child (((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((item->data)), ((ctk_bin_get_type ())) ))))))), ((ctk_label_get_type ())))))), | |||
2361 | text); | |||
2362 | ||||
2363 | set_tab_width_item_blocked (window, CTK_MENU_ITEM (item->data)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_menu_item_get_type ()))))))); | |||
2364 | ctk_widget_show (CTK_WIDGET (item->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_widget_get_type ()))))))); | |||
2365 | } | |||
2366 | else | |||
2367 | { | |||
2368 | ctk_widget_hide (CTK_WIDGET (item->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_widget_get_type ()))))))); | |||
2369 | } | |||
2370 | ||||
2371 | break; | |||
2372 | } | |||
2373 | } | |||
2374 | ||||
2375 | g_list_free (items); | |||
2376 | } | |||
2377 | ||||
2378 | static void | |||
2379 | language_changed (GObject *object, | |||
2380 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2381 | LapizWindow *window) | |||
2382 | { | |||
2383 | GList *items; | |||
2384 | GList *item; | |||
2385 | LapizStatusComboBox *combo = LAPIZ_STATUS_COMBO_BOX (window->priv->language_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( lapiz_status_combo_box_get_type ())))))); | |||
2386 | CtkSourceLanguage *new_language; | |||
2387 | const gchar *new_id; | |||
2388 | ||||
2389 | items = lapiz_status_combo_box_get_items (combo); | |||
2390 | ||||
2391 | new_language = ctk_source_buffer_get_language (CTK_SOURCE_BUFFER (object)((((CtkSourceBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_source_buffer_get_type ()))))))); | |||
2392 | ||||
2393 | if (new_language) | |||
2394 | new_id = ctk_source_language_get_id (new_language); | |||
2395 | else | |||
2396 | new_id = NULL((void*)0); | |||
2397 | ||||
2398 | for (item = items; item; item = item->next) | |||
2399 | { | |||
2400 | CtkSourceLanguage *lang = g_object_get_data (G_OBJECT (item->data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), (((GType) ((20) << (2)))))))), LANGUAGE_DATA"LapizWindowLanguageData"); | |||
2401 | ||||
2402 | if ((new_id == NULL((void*)0) && lang == NULL((void*)0)) || | |||
2403 | (new_id != NULL((void*)0) && lang != NULL((void*)0) && strcmp (ctk_source_language_get_id (lang), | |||
2404 | new_id) == 0)) | |||
2405 | { | |||
2406 | g_signal_handlers_block_by_func (window->priv->language_combo,g_signal_handlers_block_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)) | |||
2407 | language_combo_changed,g_signal_handlers_block_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)) | |||
2408 | window)g_signal_handlers_block_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)); | |||
2409 | ||||
2410 | lapiz_status_combo_box_set_item (LAPIZ_STATUS_COMBO_BOX (window->priv->language_combo)((((LapizStatusComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->language_combo)), (( lapiz_status_combo_box_get_type ())))))), | |||
2411 | CTK_MENU_ITEM (item->data)((((CtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item->data)), ((ctk_menu_item_get_type ()))))))); | |||
2412 | ||||
2413 | g_signal_handlers_unblock_by_func (window->priv->language_combo,g_signal_handlers_unblock_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)) | |||
2414 | language_combo_changed,g_signal_handlers_unblock_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)) | |||
2415 | window)g_signal_handlers_unblock_matched ((window->priv->language_combo ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (language_combo_changed), (window)); | |||
2416 | } | |||
2417 | } | |||
2418 | ||||
2419 | g_list_free (items); | |||
2420 | } | |||
2421 | ||||
2422 | static void | |||
2423 | notebook_switch_page (CtkNotebook *book, | |||
2424 | CtkWidget *pg G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2425 | gint page_num, | |||
2426 | LapizWindow *window) | |||
2427 | { | |||
2428 | LapizView *view; | |||
2429 | LapizTab *tab; | |||
2430 | CtkAction *action; | |||
2431 | gchar *action_name; | |||
2432 | ||||
2433 | /* CHECK: I don't know why but it seems notebook_switch_page is called | |||
2434 | two times every time the user change the active tab */ | |||
2435 | ||||
2436 | tab = LAPIZ_TAB (ctk_notebook_get_nth_page (book, page_num))((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_notebook_get_nth_page (book, page_num))), ((lapiz_tab_get_type ())))))); | |||
2437 | if (tab == window->priv->active_tab) | |||
2438 | return; | |||
2439 | ||||
2440 | if (window->priv->active_tab) | |||
2441 | { | |||
2442 | if (window->priv->tab_width_id) | |||
2443 | { | |||
2444 | g_signal_handler_disconnect (lapiz_tab_get_view (window->priv->active_tab), | |||
2445 | window->priv->tab_width_id); | |||
2446 | ||||
2447 | window->priv->tab_width_id = 0; | |||
2448 | } | |||
2449 | ||||
2450 | if (window->priv->spaces_instead_of_tabs_id) | |||
2451 | { | |||
2452 | g_signal_handler_disconnect (lapiz_tab_get_view (window->priv->active_tab), | |||
2453 | window->priv->spaces_instead_of_tabs_id); | |||
2454 | ||||
2455 | window->priv->spaces_instead_of_tabs_id = 0; | |||
2456 | } | |||
2457 | } | |||
2458 | ||||
2459 | /* set the active tab */ | |||
2460 | window->priv->active_tab = tab; | |||
2461 | ||||
2462 | set_title (window); | |||
2463 | set_sensitivity_according_to_tab (window, tab); | |||
2464 | ||||
2465 | /* activate the right item in the documents menu */ | |||
2466 | action_name = g_strdup_printf ("Tab_%d", page_num); | |||
2467 | action = ctk_action_group_get_action (window->priv->documents_list_action_group, | |||
2468 | action_name); | |||
2469 | ||||
2470 | /* sometimes the action doesn't exist yet, and the proper action | |||
2471 | * is set active during the documents list menu creation | |||
2472 | * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal? | |||
2473 | */ | |||
2474 | if (action != NULL((void*)0)) | |||
2475 | 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))); | |||
2476 | ||||
2477 | g_free (action_name); | |||
2478 | ||||
2479 | /* update the syntax menu */ | |||
2480 | update_languages_menu (window); | |||
2481 | ||||
2482 | view = lapiz_tab_get_view (tab); | |||
2483 | ||||
2484 | /* sync the statusbar */ | |||
2485 | update_cursor_position_statusbar (CTK_TEXT_BUFFER (lapiz_tab_get_document (tab))((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_document (tab))), ((ctk_text_buffer_get_type ())))))), | |||
2486 | window); | |||
2487 | lapiz_statusbar_set_overwrite (LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
2488 | ctk_text_view_get_overwrite (CTK_TEXT_VIEW (view)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_text_view_get_type ())))))))); | |||
2489 | ||||
2490 | ctk_widget_show (window->priv->tab_width_combo); | |||
2491 | ctk_widget_show (window->priv->language_combo); | |||
2492 | ||||
2493 | window->priv->tab_width_id = g_signal_connect (view,g_signal_connect_data ((view), ("notify::tab-width"), (((GCallback ) (tab_width_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2494 | "notify::tab-width",g_signal_connect_data ((view), ("notify::tab-width"), (((GCallback ) (tab_width_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2495 | G_CALLBACK (tab_width_changed),g_signal_connect_data ((view), ("notify::tab-width"), (((GCallback ) (tab_width_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2496 | window)g_signal_connect_data ((view), ("notify::tab-width"), (((GCallback ) (tab_width_changed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
2497 | window->priv->spaces_instead_of_tabs_id = g_signal_connect (view,g_signal_connect_data ((view), ("notify::insert-spaces-instead-of-tabs" ), (((GCallback) (spaces_instead_of_tabs_changed))), (window) , ((void*)0), (GConnectFlags) 0) | |||
2498 | "notify::insert-spaces-instead-of-tabs",g_signal_connect_data ((view), ("notify::insert-spaces-instead-of-tabs" ), (((GCallback) (spaces_instead_of_tabs_changed))), (window) , ((void*)0), (GConnectFlags) 0) | |||
2499 | G_CALLBACK (spaces_instead_of_tabs_changed),g_signal_connect_data ((view), ("notify::insert-spaces-instead-of-tabs" ), (((GCallback) (spaces_instead_of_tabs_changed))), (window) , ((void*)0), (GConnectFlags) 0) | |||
2500 | window)g_signal_connect_data ((view), ("notify::insert-spaces-instead-of-tabs" ), (((GCallback) (spaces_instead_of_tabs_changed))), (window) , ((void*)0), (GConnectFlags) 0); | |||
2501 | ||||
2502 | window->priv->language_changed_id = g_signal_connect (lapiz_tab_get_document (tab),g_signal_connect_data ((lapiz_tab_get_document (tab)), ("notify::language" ), (((GCallback) (language_changed))), (window), ((void*)0), ( GConnectFlags) 0) | |||
2503 | "notify::language",g_signal_connect_data ((lapiz_tab_get_document (tab)), ("notify::language" ), (((GCallback) (language_changed))), (window), ((void*)0), ( GConnectFlags) 0) | |||
2504 | G_CALLBACK (language_changed),g_signal_connect_data ((lapiz_tab_get_document (tab)), ("notify::language" ), (((GCallback) (language_changed))), (window), ((void*)0), ( GConnectFlags) 0) | |||
2505 | window)g_signal_connect_data ((lapiz_tab_get_document (tab)), ("notify::language" ), (((GCallback) (language_changed))), (window), ((void*)0), ( GConnectFlags) 0); | |||
2506 | ||||
2507 | /* call it for the first time */ | |||
2508 | tab_width_changed (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), NULL((void*)0), window); | |||
2509 | spaces_instead_of_tabs_changed (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), NULL((void*)0), window); | |||
2510 | language_changed (G_OBJECT (lapiz_tab_get_document (tab))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_document (tab))), (((GType) ((20) << (2)))))))), NULL((void*)0), window); | |||
2511 | ||||
2512 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | |||
2513 | signals[ACTIVE_TAB_CHANGED], | |||
2514 | 0, | |||
2515 | window->priv->active_tab); | |||
2516 | } | |||
2517 | ||||
2518 | static void | |||
2519 | set_sensitivity_according_to_window_state (LapizWindow *window) | |||
2520 | { | |||
2521 | CtkAction *action; | |||
2522 | LapizLockdownMask lockdown; | |||
2523 | ||||
2524 | lockdown = lapiz_app_get_lockdown (lapiz_app_get_default ()); | |||
2525 | ||||
2526 | /* We disable File->Quit/SaveAll/CloseAll while printing to avoid to have two | |||
2527 | operations (save and print/print preview) that uses the message area at | |||
2528 | the same time (may be we can remove this limitation in the future) */ | |||
2529 | /* We disable File->Quit/CloseAll if state is saving since saving cannot be | |||
2530 | cancelled (may be we can remove this limitation in the future) */ | |||
2531 | ctk_action_group_set_sensitive (window->priv->quit_action_group, | |||
2532 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && | |||
2533 | !(window->priv->state & LAPIZ_WINDOW_STATE_PRINTING)); | |||
2534 | ||||
2535 | action = ctk_action_group_get_action (window->priv->action_group, | |||
2536 | "FileCloseAll"); | |||
2537 | ctk_action_set_sensitive (action, | |||
2538 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && | |||
2539 | !(window->priv->state & LAPIZ_WINDOW_STATE_PRINTING)); | |||
2540 | ||||
2541 | action = ctk_action_group_get_action (window->priv->action_group, | |||
2542 | "FileSaveAll"); | |||
2543 | ctk_action_set_sensitive (action, | |||
2544 | !(window->priv->state & LAPIZ_WINDOW_STATE_PRINTING) && | |||
2545 | !(lockdown & LAPIZ_LOCKDOWN_SAVE_TO_DISK)); | |||
2546 | ||||
2547 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
2548 | "FileNew"); | |||
2549 | ctk_action_set_sensitive (action, | |||
2550 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)); | |||
2551 | ||||
2552 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
2553 | "FileOpen"); | |||
2554 | ctk_action_set_sensitive (action, | |||
2555 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)); | |||
2556 | ||||
2557 | ctk_action_group_set_sensitive (window->priv->recents_action_group, | |||
2558 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)); | |||
2559 | ||||
2560 | lapiz_notebook_set_close_buttons_sensitive (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
2561 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)); | |||
2562 | ||||
2563 | lapiz_notebook_set_tab_drag_and_drop_enabled (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
2564 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)); | |||
2565 | ||||
2566 | if ((window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) != 0) | |||
2567 | { | |||
2568 | /* TODO: If we really care, Find could be active | |||
2569 | * when in SAVING_SESSION state */ | |||
2570 | ||||
2571 | if (ctk_action_group_get_sensitive (window->priv->action_group)) | |||
2572 | ctk_action_group_set_sensitive (window->priv->action_group, | |||
2573 | FALSE(0)); | |||
2574 | if (ctk_action_group_get_sensitive (window->priv->quit_action_group)) | |||
2575 | ctk_action_group_set_sensitive (window->priv->quit_action_group, | |||
2576 | FALSE(0)); | |||
2577 | if (ctk_action_group_get_sensitive (window->priv->close_action_group)) | |||
2578 | ctk_action_group_set_sensitive (window->priv->close_action_group, | |||
2579 | FALSE(0)); | |||
2580 | } | |||
2581 | else | |||
2582 | { | |||
2583 | if (!ctk_action_group_get_sensitive (window->priv->action_group)) | |||
2584 | ctk_action_group_set_sensitive (window->priv->action_group, | |||
2585 | window->priv->num_tabs > 0); | |||
2586 | if (!ctk_action_group_get_sensitive (window->priv->quit_action_group)) | |||
2587 | ctk_action_group_set_sensitive (window->priv->quit_action_group, | |||
2588 | window->priv->num_tabs > 0); | |||
2589 | if (!ctk_action_group_get_sensitive (window->priv->close_action_group)) | |||
2590 | { | |||
2591 | ctk_action_group_set_sensitive (window->priv->close_action_group, | |||
2592 | window->priv->num_tabs > 0); | |||
2593 | } | |||
2594 | } | |||
2595 | } | |||
2596 | ||||
2597 | static void | |||
2598 | update_tab_autosave (CtkWidget *widget, | |||
2599 | gpointer data) | |||
2600 | { | |||
2601 | LapizTab *tab = LAPIZ_TAB (widget)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((lapiz_tab_get_type())))))); | |||
2602 | gboolean *enabled = (gboolean *) data; | |||
2603 | ||||
2604 | lapiz_tab_set_auto_save_enabled (tab, *enabled); | |||
2605 | } | |||
2606 | ||||
2607 | void | |||
2608 | _lapiz_window_set_lockdown (LapizWindow *window, | |||
2609 | LapizLockdownMask lockdown) | |||
2610 | { | |||
2611 | LapizTab *tab; | |||
2612 | CtkAction *action; | |||
2613 | gboolean autosave; | |||
2614 | ||||
2615 | /* start/stop autosave in each existing tab */ | |||
2616 | autosave = lapiz_prefs_manager_get_auto_save (); | |||
2617 | ctk_container_foreach (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ())))))), | |||
2618 | update_tab_autosave, | |||
2619 | &autosave); | |||
2620 | ||||
2621 | /* update menues wrt the current active tab */ | |||
2622 | tab = lapiz_window_get_active_tab (window); | |||
2623 | ||||
2624 | set_sensitivity_according_to_tab (window, tab); | |||
2625 | ||||
2626 | action = ctk_action_group_get_action (window->priv->action_group, | |||
2627 | "FileSaveAll"); | |||
2628 | ctk_action_set_sensitive (action, | |||
2629 | !(window->priv->state & LAPIZ_WINDOW_STATE_PRINTING) && | |||
2630 | !(lockdown & LAPIZ_LOCKDOWN_SAVE_TO_DISK)); | |||
2631 | ||||
2632 | } | |||
2633 | ||||
2634 | static void | |||
2635 | analyze_tab_state (LapizTab *tab, | |||
2636 | LapizWindow *window) | |||
2637 | { | |||
2638 | LapizTabState ts; | |||
2639 | ||||
2640 | ts = lapiz_tab_get_state (tab); | |||
2641 | ||||
2642 | switch (ts) | |||
2643 | { | |||
2644 | case LAPIZ_TAB_STATE_LOADING: | |||
2645 | case LAPIZ_TAB_STATE_REVERTING: | |||
2646 | window->priv->state |= LAPIZ_WINDOW_STATE_LOADING; | |||
2647 | break; | |||
2648 | ||||
2649 | case LAPIZ_TAB_STATE_SAVING: | |||
2650 | window->priv->state |= LAPIZ_WINDOW_STATE_SAVING; | |||
2651 | break; | |||
2652 | ||||
2653 | case LAPIZ_TAB_STATE_PRINTING: | |||
2654 | case LAPIZ_TAB_STATE_PRINT_PREVIEWING: | |||
2655 | window->priv->state |= LAPIZ_WINDOW_STATE_PRINTING; | |||
2656 | break; | |||
2657 | ||||
2658 | case LAPIZ_TAB_STATE_LOADING_ERROR: | |||
2659 | case LAPIZ_TAB_STATE_REVERTING_ERROR: | |||
2660 | case LAPIZ_TAB_STATE_SAVING_ERROR: | |||
2661 | case LAPIZ_TAB_STATE_GENERIC_ERROR: | |||
2662 | window->priv->state |= LAPIZ_WINDOW_STATE_ERROR; | |||
2663 | ++window->priv->num_tabs_with_error; | |||
2664 | default: | |||
2665 | /* NOP */ | |||
2666 | break; | |||
2667 | } | |||
2668 | } | |||
2669 | ||||
2670 | static void | |||
2671 | update_window_state (LapizWindow *window) | |||
2672 | { | |||
2673 | LapizWindowState old_ws; | |||
2674 | gint old_num_of_errors; | |||
2675 | ||||
2676 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 2676, ((const char*) (__func__ )), "Old state: %x", window->priv->state); | |||
2677 | ||||
2678 | old_ws = window->priv->state; | |||
2679 | old_num_of_errors = window->priv->num_tabs_with_error; | |||
2680 | ||||
2681 | window->priv->state = old_ws & LAPIZ_WINDOW_STATE_SAVING_SESSION; | |||
2682 | ||||
2683 | window->priv->num_tabs_with_error = 0; | |||
2684 | ||||
2685 | ctk_container_foreach (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ())))))), | |||
2686 | (CtkCallback)analyze_tab_state, | |||
2687 | window); | |||
2688 | ||||
2689 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 2689, ((const char*) (__func__ )), "New state: %x", window->priv->state); | |||
2690 | ||||
2691 | if (old_ws != window->priv->state) | |||
2692 | { | |||
2693 | set_sensitivity_according_to_window_state (window); | |||
2694 | ||||
2695 | lapiz_statusbar_set_window_state (LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
2696 | window->priv->state, | |||
2697 | window->priv->num_tabs_with_error); | |||
2698 | ||||
2699 | g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), "state"); | |||
2700 | } | |||
2701 | else if (old_num_of_errors != window->priv->num_tabs_with_error) | |||
2702 | { | |||
2703 | lapiz_statusbar_set_window_state (LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
2704 | window->priv->state, | |||
2705 | window->priv->num_tabs_with_error); | |||
2706 | } | |||
2707 | } | |||
2708 | ||||
2709 | static void | |||
2710 | sync_state (LapizTab *tab, | |||
2711 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2712 | LapizWindow *window) | |||
2713 | { | |||
2714 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 2714, ((const char*) (__func__ ))); | |||
2715 | ||||
2716 | update_window_state (window); | |||
2717 | ||||
2718 | if (tab != window->priv->active_tab) | |||
2719 | return; | |||
2720 | ||||
2721 | set_sensitivity_according_to_tab (window, tab); | |||
2722 | ||||
2723 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), signals[ACTIVE_TAB_STATE_CHANGED], 0); | |||
2724 | } | |||
2725 | ||||
2726 | static void | |||
2727 | sync_name (LapizTab *tab, | |||
2728 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2729 | LapizWindow *window) | |||
2730 | { | |||
2731 | CtkAction *action; | |||
2732 | gchar *action_name; | |||
2733 | gchar *tab_name; | |||
2734 | gchar *escaped_name; | |||
2735 | gchar *tip; | |||
2736 | gint n; | |||
2737 | LapizDocument *doc; | |||
2738 | ||||
2739 | if (tab == window->priv->active_tab) | |||
2740 | { | |||
2741 | set_title (window); | |||
2742 | ||||
2743 | doc = lapiz_tab_get_document (tab); | |||
2744 | action = ctk_action_group_get_action (window->priv->action_group, | |||
2745 | "FileRevert"); | |||
2746 | ctk_action_set_sensitive (action, | |||
2747 | !lapiz_document_is_untitled (doc)); | |||
2748 | } | |||
2749 | ||||
2750 | /* sync the item in the documents list menu */ | |||
2751 | n = ctk_notebook_page_num (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), | |||
2752 | CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((ctk_widget_get_type ()))))))); | |||
2753 | action_name = g_strdup_printf ("Tab_%d", n); | |||
2754 | action = ctk_action_group_get_action (window->priv->documents_list_action_group, | |||
2755 | action_name); | |||
2756 | g_free (action_name); | |||
2757 | g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action != NULL") ; return; } } while (0); | |||
2758 | ||||
2759 | tab_name = _lapiz_tab_get_name (tab); | |||
2760 | escaped_name = lapiz_utils_escape_underscores (tab_name, -1); | |||
2761 | tip = get_menu_tip_for_tab (tab); | |||
2762 | ||||
2763 | g_object_set (action, "label", escaped_name, NULL((void*)0)); | |||
2764 | g_object_set (action, "tooltip", tip, NULL((void*)0)); | |||
2765 | ||||
2766 | g_free (tab_name); | |||
2767 | g_free (escaped_name); | |||
2768 | g_free (tip); | |||
2769 | ||||
2770 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
2771 | } | |||
2772 | ||||
2773 | static LapizWindow * | |||
2774 | get_drop_window (CtkWidget *widget) | |||
2775 | { | |||
2776 | CtkWidget *target_window; | |||
2777 | ||||
2778 | target_window = ctk_widget_get_toplevel (widget); | |||
2779 | g_return_val_if_fail (LAPIZ_IS_WINDOW (target_window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((target_window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (target_window)"); return (((void*)0)); } } while (0); | |||
2780 | ||||
2781 | if ((LAPIZ_WINDOW(target_window)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((target_window)), ((lapiz_window_get_type()))))))->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) != 0) | |||
2782 | return NULL((void*)0); | |||
2783 | ||||
2784 | return LAPIZ_WINDOW (target_window)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((target_window)), ((lapiz_window_get_type())))))); | |||
2785 | } | |||
2786 | ||||
2787 | static void | |||
2788 | load_uris_from_drop (LapizWindow *window, | |||
2789 | gchar **uri_list) | |||
2790 | { | |||
2791 | GSList *uris = NULL((void*)0); | |||
2792 | gint i; | |||
2793 | ||||
2794 | if (uri_list == NULL((void*)0)) | |||
2795 | return; | |||
2796 | ||||
2797 | for (i = 0; uri_list[i] != NULL((void*)0); ++i) | |||
2798 | { | |||
2799 | uris = g_slist_prepend (uris, uri_list[i]); | |||
2800 | } | |||
2801 | ||||
2802 | uris = g_slist_reverse (uris); | |||
2803 | lapiz_commands_load_uris (window, | |||
2804 | uris, | |||
2805 | NULL((void*)0), | |||
2806 | 0); | |||
2807 | ||||
2808 | g_slist_free (uris); | |||
2809 | } | |||
2810 | ||||
2811 | /* Handle drops on the LapizWindow */ | |||
2812 | static void | |||
2813 | drag_data_received_cb (CtkWidget *widget, | |||
2814 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2815 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2816 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2817 | CtkSelectionData *selection_data, | |||
2818 | guint info, | |||
2819 | guint timestamp G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2820 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
2821 | { | |||
2822 | LapizWindow *window; | |||
2823 | gchar **uri_list; | |||
2824 | ||||
2825 | window = get_drop_window (widget); | |||
2826 | ||||
2827 | if (window == NULL((void*)0)) | |||
2828 | return; | |||
2829 | ||||
2830 | if (info == TARGET_URI_LIST) | |||
2831 | { | |||
2832 | uri_list = lapiz_utils_drop_get_uris(selection_data); | |||
2833 | load_uris_from_drop (window, uri_list); | |||
2834 | g_strfreev (uri_list); | |||
2835 | } | |||
2836 | } | |||
2837 | ||||
2838 | /* Handle drops on the LapizView */ | |||
2839 | static void | |||
2840 | drop_uris_cb (CtkWidget *widget, | |||
2841 | gchar **uri_list) | |||
2842 | { | |||
2843 | LapizWindow *window; | |||
2844 | ||||
2845 | window = get_drop_window (widget); | |||
2846 | ||||
2847 | if (window == NULL((void*)0)) | |||
2848 | return; | |||
2849 | ||||
2850 | load_uris_from_drop (window, uri_list); | |||
2851 | } | |||
2852 | ||||
2853 | static void | |||
2854 | fullscreen_controls_show (LapizWindow *window) | |||
2855 | { | |||
2856 | CdkScreen *screen; | |||
2857 | CdkDisplay *display; | |||
2858 | CdkRectangle fs_rect; | |||
2859 | gint w, h; | |||
2860 | ||||
2861 | screen = ctk_window_get_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2862 | display = cdk_screen_get_display (screen); | |||
2863 | ||||
2864 | cdk_monitor_get_geometry (cdk_display_get_monitor_at_window (display, | |||
2865 | ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))), | |||
2866 | &fs_rect); | |||
2867 | ||||
2868 | ctk_window_get_size (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), &w, &h); | |||
2869 | ||||
2870 | ctk_window_resize (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2871 | fs_rect.width, h); | |||
2872 | ||||
2873 | ctk_window_move (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2874 | fs_rect.x, fs_rect.y - h + 1); | |||
2875 | ||||
2876 | ctk_widget_show_all (window->priv->fullscreen_controls); | |||
2877 | } | |||
2878 | ||||
2879 | static gboolean | |||
2880 | run_fullscreen_animation (gpointer data) | |||
2881 | { | |||
2882 | LapizWindow *window = LAPIZ_WINDOW (data)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((lapiz_window_get_type())))))); | |||
2883 | CdkScreen *screen; | |||
2884 | CdkDisplay *display; | |||
2885 | CdkRectangle fs_rect; | |||
2886 | gint x, y; | |||
2887 | ||||
2888 | screen = ctk_window_get_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2889 | display = cdk_screen_get_display (screen); | |||
2890 | ||||
2891 | cdk_monitor_get_geometry (cdk_display_get_monitor_at_window (display, | |||
2892 | ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))), | |||
2893 | &fs_rect); | |||
2894 | ||||
2895 | ctk_window_get_position (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2896 | &x, &y); | |||
2897 | ||||
2898 | if (window->priv->fullscreen_animation_enter) | |||
2899 | { | |||
2900 | if (y == fs_rect.y) | |||
2901 | { | |||
2902 | window->priv->fullscreen_animation_timeout_id = 0; | |||
2903 | return FALSE(0); | |||
2904 | } | |||
2905 | else | |||
2906 | { | |||
2907 | ctk_window_move (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2908 | x, y + 1); | |||
2909 | return TRUE(!(0)); | |||
2910 | } | |||
2911 | } | |||
2912 | else | |||
2913 | { | |||
2914 | gint w, h; | |||
2915 | ||||
2916 | ctk_window_get_size (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2917 | &w, &h); | |||
2918 | ||||
2919 | if (y == fs_rect.y - h + 1) | |||
2920 | { | |||
2921 | window->priv->fullscreen_animation_timeout_id = 0; | |||
2922 | return FALSE(0); | |||
2923 | } | |||
2924 | else | |||
2925 | { | |||
2926 | ctk_window_move (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2927 | x, y - 1); | |||
2928 | return TRUE(!(0)); | |||
2929 | } | |||
2930 | } | |||
2931 | } | |||
2932 | ||||
2933 | static void | |||
2934 | show_hide_fullscreen_toolbar (LapizWindow *window, | |||
2935 | gboolean show, | |||
2936 | gint height) | |||
2937 | { | |||
2938 | CtkSettings *settings; | |||
2939 | gboolean enable_animations; | |||
2940 | ||||
2941 | settings = ctk_widget_get_settings (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
2942 | g_object_get (G_OBJECT (settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((settings)), (((GType) ((20) << (2)))))))), | |||
2943 | "ctk-enable-animations", | |||
2944 | &enable_animations, | |||
2945 | NULL((void*)0)); | |||
2946 | ||||
2947 | if (enable_animations) | |||
2948 | { | |||
2949 | window->priv->fullscreen_animation_enter = show; | |||
2950 | ||||
2951 | if (window->priv->fullscreen_animation_timeout_id == 0) | |||
2952 | { | |||
2953 | window->priv->fullscreen_animation_timeout_id = | |||
2954 | g_timeout_add (FULLSCREEN_ANIMATION_SPEED4, | |||
2955 | (GSourceFunc) run_fullscreen_animation, | |||
2956 | window); | |||
2957 | } | |||
2958 | } | |||
2959 | else | |||
2960 | { | |||
2961 | CdkRectangle fs_rect; | |||
2962 | CdkScreen *screen; | |||
2963 | CdkDisplay *display; | |||
2964 | ||||
2965 | screen = ctk_window_get_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
2966 | display = cdk_screen_get_display (screen); | |||
2967 | ||||
2968 | cdk_monitor_get_geometry (cdk_display_get_monitor_at_window (display, | |||
2969 | ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))), | |||
2970 | &fs_rect); | |||
2971 | ||||
2972 | if (show) | |||
2973 | ctk_window_move (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2974 | fs_rect.x, fs_rect.y); | |||
2975 | else | |||
2976 | ctk_window_move (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), | |||
2977 | fs_rect.x, fs_rect.y - height + 1); | |||
2978 | } | |||
2979 | ||||
2980 | } | |||
2981 | ||||
2982 | static gboolean | |||
2983 | on_fullscreen_controls_enter_notify_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2984 | CdkEventCrossing *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2985 | LapizWindow *window) | |||
2986 | { | |||
2987 | show_hide_fullscreen_toolbar (window, TRUE(!(0)), 0); | |||
2988 | ||||
2989 | return FALSE(0); | |||
2990 | } | |||
2991 | ||||
2992 | static gboolean | |||
2993 | on_fullscreen_controls_leave_notify_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2994 | CdkEventCrossing *event, | |||
2995 | LapizWindow *window) | |||
2996 | { | |||
2997 | CdkDevice *device; | |||
2998 | gint w, h; | |||
2999 | gint x, y; | |||
3000 | ||||
3001 | device = cdk_event_get_device ((CdkEvent *)event); | |||
3002 | ||||
3003 | ctk_window_get_size (CTK_WINDOW (window->priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->fullscreen_controls)), ((ctk_window_get_type ())))))), &w, &h); | |||
3004 | cdk_device_get_position (device, NULL((void*)0), &x, &y); | |||
3005 | ||||
3006 | /* ctk seems to emit leave notify when clicking on tool items, | |||
3007 | * work around it by checking the coordinates | |||
3008 | */ | |||
3009 | if (y >= h) | |||
3010 | { | |||
3011 | show_hide_fullscreen_toolbar (window, FALSE(0), h); | |||
3012 | } | |||
3013 | ||||
3014 | return FALSE(0); | |||
3015 | } | |||
3016 | ||||
3017 | static void | |||
3018 | fullscreen_controls_build (LapizWindow *window) | |||
3019 | { | |||
3020 | LapizWindowPrivate *priv = window->priv; | |||
3021 | CtkWidget *toolbar; | |||
3022 | CtkAction *action; | |||
3023 | ||||
3024 | if (priv->fullscreen_controls != NULL((void*)0)) | |||
3025 | return; | |||
3026 | ||||
3027 | priv->fullscreen_controls = ctk_window_new (CTK_WINDOW_POPUP); | |||
3028 | ||||
3029 | ctk_window_set_transient_for (CTK_WINDOW (priv->fullscreen_controls)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->fullscreen_controls)), ((ctk_window_get_type () )))))), | |||
3030 | &window->window); | |||
3031 | ||||
3032 | /* popup toolbar */ | |||
3033 | toolbar = ctk_ui_manager_get_widget (priv->manager, "/FullscreenToolBar"); | |||
3034 | ctk_container_add (CTK_CONTAINER (priv->fullscreen_controls)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->fullscreen_controls)), ((ctk_container_get_type ())))))), | |||
3035 | toolbar); | |||
3036 | ||||
3037 | action = ctk_action_group_get_action (priv->always_sensitive_action_group, | |||
3038 | "LeaveFullscreen"); | |||
3039 | g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0)); | |||
3040 | ||||
3041 | setup_toolbar_open_button (window, toolbar); | |||
3042 | ||||
3043 | ctk_container_foreach (CTK_CONTAINER (toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_container_get_type ())))))), | |||
3044 | (CtkCallback)set_non_homogeneus, | |||
3045 | NULL((void*)0)); | |||
3046 | ||||
3047 | /* Set the toolbar style */ | |||
3048 | ctk_toolbar_set_style (CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), | |||
3049 | CTK_TOOLBAR_BOTH_HORIZ); | |||
3050 | ||||
3051 | g_signal_connect (priv->fullscreen_controls, "enter-notify-event",g_signal_connect_data ((priv->fullscreen_controls), ("enter-notify-event" ), (((GCallback) (on_fullscreen_controls_enter_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
3052 | G_CALLBACK (on_fullscreen_controls_enter_notify_event),g_signal_connect_data ((priv->fullscreen_controls), ("enter-notify-event" ), (((GCallback) (on_fullscreen_controls_enter_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
3053 | window)g_signal_connect_data ((priv->fullscreen_controls), ("enter-notify-event" ), (((GCallback) (on_fullscreen_controls_enter_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0); | |||
3054 | g_signal_connect (priv->fullscreen_controls, "leave-notify-event",g_signal_connect_data ((priv->fullscreen_controls), ("leave-notify-event" ), (((GCallback) (on_fullscreen_controls_leave_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
3055 | G_CALLBACK (on_fullscreen_controls_leave_notify_event),g_signal_connect_data ((priv->fullscreen_controls), ("leave-notify-event" ), (((GCallback) (on_fullscreen_controls_leave_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0) | |||
3056 | window)g_signal_connect_data ((priv->fullscreen_controls), ("leave-notify-event" ), (((GCallback) (on_fullscreen_controls_leave_notify_event)) ), (window), ((void*)0), (GConnectFlags) 0); | |||
3057 | } | |||
3058 | ||||
3059 | static void | |||
3060 | can_search_again (LapizDocument *doc, | |||
3061 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3062 | LapizWindow *window) | |||
3063 | { | |||
3064 | gboolean sensitive; | |||
3065 | CtkAction *action; | |||
3066 | ||||
3067 | if (doc != lapiz_window_get_active_document (window)) | |||
3068 | return; | |||
3069 | ||||
3070 | sensitive = lapiz_document_get_can_search_again (doc); | |||
3071 | ||||
3072 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3073 | "SearchFindNext"); | |||
3074 | ctk_action_set_sensitive (action, sensitive); | |||
3075 | ||||
3076 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3077 | "SearchFindPrevious"); | |||
3078 | ctk_action_set_sensitive (action, sensitive); | |||
3079 | ||||
3080 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3081 | "SearchClearHighlight"); | |||
3082 | ctk_action_set_sensitive (action, sensitive); | |||
3083 | } | |||
3084 | ||||
3085 | static void | |||
3086 | can_undo (LapizDocument *doc, | |||
3087 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3088 | LapizWindow *window) | |||
3089 | { | |||
3090 | CtkAction *action; | |||
3091 | gboolean sensitive; | |||
3092 | ||||
3093 | sensitive = ctk_source_buffer_can_undo (CTK_SOURCE_BUFFER (doc)((((CtkSourceBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_source_buffer_get_type ()))))))); | |||
3094 | ||||
3095 | if (doc != lapiz_window_get_active_document (window)) | |||
3096 | return; | |||
3097 | ||||
3098 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3099 | "EditUndo"); | |||
3100 | ctk_action_set_sensitive (action, sensitive); | |||
3101 | } | |||
3102 | ||||
3103 | static void | |||
3104 | can_redo (LapizDocument *doc, | |||
3105 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3106 | LapizWindow *window) | |||
3107 | { | |||
3108 | CtkAction *action; | |||
3109 | gboolean sensitive; | |||
3110 | ||||
3111 | sensitive = ctk_source_buffer_can_redo (CTK_SOURCE_BUFFER (doc)((((CtkSourceBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_source_buffer_get_type ()))))))); | |||
3112 | ||||
3113 | if (doc != lapiz_window_get_active_document (window)) | |||
3114 | return; | |||
3115 | ||||
3116 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3117 | "EditRedo"); | |||
3118 | ctk_action_set_sensitive (action, sensitive); | |||
3119 | } | |||
3120 | ||||
3121 | static void | |||
3122 | selection_changed (LapizDocument *doc, | |||
3123 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3124 | LapizWindow *window) | |||
3125 | { | |||
3126 | LapizTab *tab; | |||
3127 | LapizView *view; | |||
3128 | CtkAction *action; | |||
3129 | LapizTabState state; | |||
3130 | gboolean state_normal; | |||
3131 | gboolean editable; | |||
3132 | ||||
3133 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3133, ((const char*) (__func__ ))); | |||
3134 | ||||
3135 | if (doc != lapiz_window_get_active_document (window)) | |||
3136 | return; | |||
3137 | ||||
3138 | tab = lapiz_tab_get_from_document (doc); | |||
3139 | state = lapiz_tab_get_state (tab); | |||
3140 | state_normal = (state == LAPIZ_TAB_STATE_NORMAL); | |||
3141 | ||||
3142 | view = lapiz_tab_get_view (tab); | |||
3143 | editable = ctk_text_view_get_editable (CTK_TEXT_VIEW (view)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_text_view_get_type ()))))))); | |||
3144 | ||||
3145 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3146 | "EditCut"); | |||
3147 | ctk_action_set_sensitive (action, | |||
3148 | state_normal && | |||
3149 | editable && | |||
3150 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
3151 | ||||
3152 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3153 | "EditCopy"); | |||
3154 | ctk_action_set_sensitive (action, | |||
3155 | (state_normal || | |||
3156 | state == LAPIZ_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && | |||
3157 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
3158 | ||||
3159 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3160 | "EditDelete"); | |||
3161 | ctk_action_set_sensitive (action, | |||
3162 | state_normal && | |||
3163 | editable && | |||
3164 | ctk_text_buffer_get_has_selection (CTK_TEXT_BUFFER (doc)((((CtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((doc)), ((ctk_text_buffer_get_type ())))))))); | |||
3165 | ||||
3166 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
3167 | } | |||
3168 | ||||
3169 | static void | |||
3170 | sync_languages_menu (LapizDocument *doc G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3171 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3172 | LapizWindow *window) | |||
3173 | { | |||
3174 | update_languages_menu (window); | |||
3175 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
3176 | } | |||
3177 | ||||
3178 | static void | |||
3179 | readonly_changed (LapizDocument *doc G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3180 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3181 | LapizWindow *window) | |||
3182 | { | |||
3183 | set_sensitivity_according_to_tab (window, window->priv->active_tab); | |||
3184 | ||||
3185 | sync_name (window->priv->active_tab, NULL((void*)0), window); | |||
3186 | ||||
3187 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
3188 | } | |||
3189 | ||||
3190 | static void | |||
3191 | editable_changed (LapizView *view G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3192 | GParamSpec *arg1 G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3193 | LapizWindow *window) | |||
3194 | { | |||
3195 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
3196 | } | |||
3197 | ||||
3198 | static void | |||
3199 | update_sensitivity_according_to_open_tabs (LapizWindow *window) | |||
3200 | { | |||
3201 | CtkAction *action; | |||
3202 | ||||
3203 | /* Set sensitivity */ | |||
3204 | ctk_action_group_set_sensitive (window->priv->action_group, | |||
3205 | window->priv->num_tabs != 0); | |||
3206 | ||||
3207 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3208 | "DocumentsMoveToNewWindow"); | |||
3209 | ctk_action_set_sensitive (action, | |||
3210 | window->priv->num_tabs > 1); | |||
3211 | ||||
3212 | ctk_action_group_set_sensitive (window->priv->close_action_group, | |||
3213 | window->priv->num_tabs != 0); | |||
3214 | } | |||
3215 | ||||
3216 | static void | |||
3217 | notebook_tab_added (LapizNotebook *notebook G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3218 | LapizTab *tab, | |||
3219 | LapizWindow *window) | |||
3220 | { | |||
3221 | LapizView *view; | |||
3222 | LapizDocument *doc; | |||
3223 | ||||
3224 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3224, ((const char*) (__func__ ))); | |||
3225 | ||||
3226 | g_return_if_fail ((window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) == 0)do { if (((window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ) == 0)) { } else { g_return_if_fail_warning (((gchar*) 0), ( (const char*) (__func__)), "(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) == 0" ); return; } } while (0); | |||
3227 | ||||
3228 | ++window->priv->num_tabs; | |||
3229 | ||||
3230 | update_sensitivity_according_to_open_tabs (window); | |||
3231 | ||||
3232 | view = lapiz_tab_get_view (tab); | |||
3233 | doc = lapiz_tab_get_document (tab); | |||
3234 | ||||
3235 | /* IMPORTANT: remember to disconnect the signal in notebook_tab_removed | |||
3236 | * if a new signal is connected here */ | |||
3237 | ||||
3238 | g_signal_connect (tab,g_signal_connect_data ((tab), ("notify::name"), (((GCallback) (sync_name))), (window), ((void*)0), (GConnectFlags) 0) | |||
3239 | "notify::name",g_signal_connect_data ((tab), ("notify::name"), (((GCallback) (sync_name))), (window), ((void*)0), (GConnectFlags) 0) | |||
3240 | G_CALLBACK (sync_name),g_signal_connect_data ((tab), ("notify::name"), (((GCallback) (sync_name))), (window), ((void*)0), (GConnectFlags) 0) | |||
3241 | window)g_signal_connect_data ((tab), ("notify::name"), (((GCallback) (sync_name))), (window), ((void*)0), (GConnectFlags) 0); | |||
3242 | g_signal_connect (tab,g_signal_connect_data ((tab), ("notify::state"), (((GCallback ) (sync_state))), (window), ((void*)0), (GConnectFlags) 0) | |||
3243 | "notify::state",g_signal_connect_data ((tab), ("notify::state"), (((GCallback ) (sync_state))), (window), ((void*)0), (GConnectFlags) 0) | |||
3244 | G_CALLBACK (sync_state),g_signal_connect_data ((tab), ("notify::state"), (((GCallback ) (sync_state))), (window), ((void*)0), (GConnectFlags) 0) | |||
3245 | window)g_signal_connect_data ((tab), ("notify::state"), (((GCallback ) (sync_state))), (window), ((void*)0), (GConnectFlags) 0); | |||
3246 | ||||
3247 | g_signal_connect (doc,g_signal_connect_data ((doc), ("cursor-moved"), (((GCallback) (update_cursor_position_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3248 | "cursor-moved",g_signal_connect_data ((doc), ("cursor-moved"), (((GCallback) (update_cursor_position_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3249 | G_CALLBACK (update_cursor_position_statusbar),g_signal_connect_data ((doc), ("cursor-moved"), (((GCallback) (update_cursor_position_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3250 | window)g_signal_connect_data ((doc), ("cursor-moved"), (((GCallback) (update_cursor_position_statusbar))), (window), ((void*)0), ( GConnectFlags) 0); | |||
3251 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::can-search-again"), ( ((GCallback) (can_search_again))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3252 | "notify::can-search-again",g_signal_connect_data ((doc), ("notify::can-search-again"), ( ((GCallback) (can_search_again))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3253 | G_CALLBACK (can_search_again),g_signal_connect_data ((doc), ("notify::can-search-again"), ( ((GCallback) (can_search_again))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3254 | window)g_signal_connect_data ((doc), ("notify::can-search-again"), ( ((GCallback) (can_search_again))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3255 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::can-undo"), (((GCallback ) (can_undo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3256 | "notify::can-undo",g_signal_connect_data ((doc), ("notify::can-undo"), (((GCallback ) (can_undo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3257 | G_CALLBACK (can_undo),g_signal_connect_data ((doc), ("notify::can-undo"), (((GCallback ) (can_undo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3258 | window)g_signal_connect_data ((doc), ("notify::can-undo"), (((GCallback ) (can_undo))), (window), ((void*)0), (GConnectFlags) 0); | |||
3259 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::can-redo"), (((GCallback ) (can_redo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3260 | "notify::can-redo",g_signal_connect_data ((doc), ("notify::can-redo"), (((GCallback ) (can_redo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3261 | G_CALLBACK (can_redo),g_signal_connect_data ((doc), ("notify::can-redo"), (((GCallback ) (can_redo))), (window), ((void*)0), (GConnectFlags) 0) | |||
3262 | window)g_signal_connect_data ((doc), ("notify::can-redo"), (((GCallback ) (can_redo))), (window), ((void*)0), (GConnectFlags) 0); | |||
3263 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::has-selection"), (((GCallback ) (selection_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3264 | "notify::has-selection",g_signal_connect_data ((doc), ("notify::has-selection"), (((GCallback ) (selection_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3265 | G_CALLBACK (selection_changed),g_signal_connect_data ((doc), ("notify::has-selection"), (((GCallback ) (selection_changed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3266 | window)g_signal_connect_data ((doc), ("notify::has-selection"), (((GCallback ) (selection_changed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3267 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::language"), (((GCallback ) (sync_languages_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3268 | "notify::language",g_signal_connect_data ((doc), ("notify::language"), (((GCallback ) (sync_languages_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3269 | G_CALLBACK (sync_languages_menu),g_signal_connect_data ((doc), ("notify::language"), (((GCallback ) (sync_languages_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3270 | window)g_signal_connect_data ((doc), ("notify::language"), (((GCallback ) (sync_languages_menu))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3271 | g_signal_connect (doc,g_signal_connect_data ((doc), ("notify::read-only"), (((GCallback ) (readonly_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3272 | "notify::read-only",g_signal_connect_data ((doc), ("notify::read-only"), (((GCallback ) (readonly_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3273 | G_CALLBACK (readonly_changed),g_signal_connect_data ((doc), ("notify::read-only"), (((GCallback ) (readonly_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3274 | window)g_signal_connect_data ((doc), ("notify::read-only"), (((GCallback ) (readonly_changed))), (window), ((void*)0), (GConnectFlags) 0); | |||
3275 | g_signal_connect (view,g_signal_connect_data ((view), ("toggle_overwrite"), (((GCallback ) (update_overwrite_mode_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3276 | "toggle_overwrite",g_signal_connect_data ((view), ("toggle_overwrite"), (((GCallback ) (update_overwrite_mode_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3277 | G_CALLBACK (update_overwrite_mode_statusbar),g_signal_connect_data ((view), ("toggle_overwrite"), (((GCallback ) (update_overwrite_mode_statusbar))), (window), ((void*)0), ( GConnectFlags) 0) | |||
3278 | window)g_signal_connect_data ((view), ("toggle_overwrite"), (((GCallback ) (update_overwrite_mode_statusbar))), (window), ((void*)0), ( GConnectFlags) 0); | |||
3279 | g_signal_connect (view,g_signal_connect_data ((view), ("notify::editable"), (((GCallback ) (editable_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3280 | "notify::editable",g_signal_connect_data ((view), ("notify::editable"), (((GCallback ) (editable_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3281 | G_CALLBACK (editable_changed),g_signal_connect_data ((view), ("notify::editable"), (((GCallback ) (editable_changed))), (window), ((void*)0), (GConnectFlags) 0) | |||
3282 | window)g_signal_connect_data ((view), ("notify::editable"), (((GCallback ) (editable_changed))), (window), ((void*)0), (GConnectFlags) 0); | |||
3283 | ||||
3284 | update_documents_list_menu (window); | |||
3285 | ||||
3286 | g_signal_connect (view,g_signal_connect_data ((view), ("drop_uris"), (((GCallback) ( drop_uris_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
3287 | "drop_uris",g_signal_connect_data ((view), ("drop_uris"), (((GCallback) ( drop_uris_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
3288 | G_CALLBACK (drop_uris_cb),g_signal_connect_data ((view), ("drop_uris"), (((GCallback) ( drop_uris_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
3289 | NULL)g_signal_connect_data ((view), ("drop_uris"), (((GCallback) ( drop_uris_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
3290 | ||||
3291 | update_window_state (window); | |||
3292 | ||||
3293 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), signals[TAB_ADDED], 0, tab); | |||
3294 | } | |||
3295 | ||||
3296 | static void | |||
3297 | notebook_tab_removed (LapizNotebook *notebook G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3298 | LapizTab *tab, | |||
3299 | LapizWindow *window) | |||
3300 | { | |||
3301 | LapizView *view; | |||
3302 | LapizDocument *doc; | |||
3303 | ||||
3304 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3304, ((const char*) (__func__ ))); | |||
3305 | ||||
3306 | g_return_if_fail ((window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) == 0)do { if (((window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ) == 0)) { } else { g_return_if_fail_warning (((gchar*) 0), ( (const char*) (__func__)), "(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION) == 0" ); return; } } while (0); | |||
3307 | ||||
3308 | --window->priv->num_tabs; | |||
3309 | ||||
3310 | view = lapiz_tab_get_view (tab); | |||
3311 | doc = lapiz_tab_get_document (tab); | |||
3312 | ||||
3313 | g_signal_handlers_disconnect_by_func (tab,g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_name))), (window)) | |||
3314 | G_CALLBACK (sync_name),g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_name))), (window)) | |||
3315 | window)g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_name))), (window)); | |||
3316 | g_signal_handlers_disconnect_by_func (tab,g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_state))), (window)) | |||
3317 | G_CALLBACK (sync_state),g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_state))), (window)) | |||
3318 | window)g_signal_handlers_disconnect_matched ((tab), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_state))), (window)); | |||
3319 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_cursor_position_statusbar))), (window )) | |||
3320 | G_CALLBACK (update_cursor_position_statusbar),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_cursor_position_statusbar))), (window )) | |||
3321 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_cursor_position_statusbar))), (window )); | |||
3322 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_search_again))), (window)) | |||
3323 | G_CALLBACK (can_search_again),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_search_again))), (window)) | |||
3324 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_search_again))), (window)); | |||
3325 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_undo))), (window)) | |||
3326 | G_CALLBACK (can_undo),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_undo))), (window)) | |||
3327 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_undo))), (window)); | |||
3328 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_redo))), (window)) | |||
3329 | G_CALLBACK (can_redo),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_redo))), (window)) | |||
3330 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (can_redo))), (window)); | |||
3331 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (selection_changed))), (window)) | |||
3332 | G_CALLBACK (selection_changed),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (selection_changed))), (window)) | |||
3333 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (selection_changed))), (window)); | |||
3334 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_languages_menu))), (window)) | |||
3335 | G_CALLBACK (sync_languages_menu),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_languages_menu))), (window)) | |||
3336 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (sync_languages_menu))), (window)); | |||
3337 | g_signal_handlers_disconnect_by_func (doc,g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (readonly_changed))), (window)) | |||
3338 | G_CALLBACK (readonly_changed),g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (readonly_changed))), (window)) | |||
3339 | window)g_signal_handlers_disconnect_matched ((doc), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (readonly_changed))), (window)); | |||
3340 | g_signal_handlers_disconnect_by_func (view,g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_overwrite_mode_statusbar))), (window )) | |||
3341 | G_CALLBACK (update_overwrite_mode_statusbar),g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_overwrite_mode_statusbar))), (window )) | |||
3342 | window)g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (update_overwrite_mode_statusbar))), (window )); | |||
3343 | g_signal_handlers_disconnect_by_func (view,g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (editable_changed))), (window)) | |||
3344 | G_CALLBACK (editable_changed),g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (editable_changed))), (window)) | |||
3345 | window)g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (editable_changed))), (window)); | |||
3346 | g_signal_handlers_disconnect_by_func (view,g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (drop_uris_cb))), (((void*)0))) | |||
3347 | G_CALLBACK (drop_uris_cb),g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (drop_uris_cb))), (((void*)0))) | |||
3348 | NULL)g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (drop_uris_cb))), (((void*)0))); | |||
3349 | ||||
3350 | if (window->priv->tab_width_id && tab == lapiz_window_get_active_tab (window)) | |||
3351 | { | |||
3352 | g_signal_handler_disconnect (view, window->priv->tab_width_id); | |||
3353 | window->priv->tab_width_id = 0; | |||
3354 | } | |||
3355 | ||||
3356 | if (window->priv->spaces_instead_of_tabs_id && tab == lapiz_window_get_active_tab (window)) | |||
3357 | { | |||
3358 | g_signal_handler_disconnect (view, window->priv->spaces_instead_of_tabs_id); | |||
3359 | window->priv->spaces_instead_of_tabs_id = 0; | |||
3360 | } | |||
3361 | ||||
3362 | if (window->priv->language_changed_id && tab == lapiz_window_get_active_tab (window)) | |||
3363 | { | |||
3364 | g_signal_handler_disconnect (doc, window->priv->language_changed_id); | |||
3365 | window->priv->language_changed_id = 0; | |||
3366 | } | |||
3367 | ||||
3368 | g_return_if_fail (window->priv->num_tabs >= 0)do { if ((window->priv->num_tabs >= 0)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window->priv->num_tabs >= 0" ); return; } } while (0); | |||
3369 | if (window->priv->num_tabs == 0) | |||
3370 | { | |||
3371 | window->priv->active_tab = NULL((void*)0); | |||
3372 | ||||
3373 | set_title (window); | |||
3374 | ||||
3375 | /* Remove line and col info */ | |||
3376 | lapiz_statusbar_set_cursor_position ( | |||
3377 | LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ())))))), | |||
3378 | -1, | |||
3379 | -1); | |||
3380 | ||||
3381 | lapiz_statusbar_clear_overwrite ( | |||
3382 | LAPIZ_STATUSBAR (window->priv->statusbar)((((LapizStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((lapiz_statusbar_get_type ()))))))); | |||
3383 | ||||
3384 | /* hide the combos */ | |||
3385 | ctk_widget_hide (window->priv->tab_width_combo); | |||
3386 | ctk_widget_hide (window->priv->language_combo); | |||
3387 | } | |||
3388 | ||||
3389 | if (!window->priv->removing_tabs) | |||
3390 | { | |||
3391 | update_documents_list_menu (window); | |||
3392 | update_next_prev_doc_sensitivity_per_window (window); | |||
3393 | } | |||
3394 | else | |||
3395 | { | |||
3396 | if (window->priv->num_tabs == 0) | |||
3397 | { | |||
3398 | update_documents_list_menu (window); | |||
3399 | update_next_prev_doc_sensitivity_per_window (window); | |||
3400 | } | |||
3401 | } | |||
3402 | ||||
3403 | update_sensitivity_according_to_open_tabs (window); | |||
3404 | ||||
3405 | if (window->priv->num_tabs == 0) | |||
3406 | { | |||
3407 | bean_extension_set_call (window->priv->extensions, "update_state", window); | |||
3408 | } | |||
3409 | ||||
3410 | update_window_state (window); | |||
3411 | ||||
3412 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), signals[TAB_REMOVED], 0, tab); | |||
3413 | } | |||
3414 | ||||
3415 | static void | |||
3416 | notebook_tabs_reordered (LapizNotebook *notebook G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3417 | LapizWindow *window) | |||
3418 | { | |||
3419 | update_documents_list_menu (window); | |||
3420 | update_next_prev_doc_sensitivity_per_window (window); | |||
3421 | ||||
3422 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), signals[TABS_REORDERED], 0); | |||
3423 | } | |||
3424 | ||||
3425 | static void | |||
3426 | notebook_tab_detached (LapizNotebook *notebook, | |||
3427 | LapizTab *tab, | |||
3428 | LapizWindow *window) | |||
3429 | { | |||
3430 | LapizWindow *new_window; | |||
3431 | ||||
3432 | new_window = clone_window (window); | |||
3433 | ||||
3434 | lapiz_notebook_move_tab (notebook, | |||
3435 | LAPIZ_NOTEBOOK (_lapiz_window_get_notebook (new_window))((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((_lapiz_window_get_notebook (new_window))), ((lapiz_notebook_get_type ())))))), | |||
3436 | tab, 0); | |||
3437 | ||||
3438 | ctk_window_set_position (CTK_WINDOW (new_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window)), ((ctk_window_get_type ())))))), | |||
3439 | CTK_WIN_POS_MOUSE); | |||
3440 | ||||
3441 | ctk_widget_show (CTK_WIDGET (new_window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window)), ((ctk_widget_get_type ()))))))); | |||
3442 | } | |||
3443 | ||||
3444 | static void | |||
3445 | notebook_tab_close_request (LapizNotebook *notebook G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3446 | LapizTab *tab, | |||
3447 | CtkWindow *window) | |||
3448 | { | |||
3449 | /* Note: we are destroying the tab before the default handler | |||
3450 | * seems to be ok, but we need to keep an eye on this. */ | |||
3451 | _lapiz_cmd_file_close_tab (tab, LAPIZ_WINDOW (window)((((LapizWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((lapiz_window_get_type()))))))); | |||
3452 | } | |||
3453 | ||||
3454 | static gboolean | |||
3455 | show_notebook_popup_menu (CtkNotebook *notebook, | |||
3456 | LapizWindow *window, | |||
3457 | CdkEventButton *event) | |||
3458 | { | |||
3459 | CtkWidget *menu; | |||
3460 | // CtkAction *action; | |||
3461 | ||||
3462 | menu = ctk_ui_manager_get_widget (window->priv->manager, "/NotebookPopup"); | |||
3463 | g_return_val_if_fail (menu != NULL, FALSE)do { if ((menu != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "menu != NULL"); return ((0)); } } while (0); | |||
3464 | ||||
3465 | // CHECK do we need this? | |||
3466 | #if 0 | |||
3467 | /* allow extensions to sync when showing the popup */ | |||
3468 | action = ctk_action_group_get_action (window->priv->action_group, | |||
3469 | "NotebookPopupAction"); | |||
3470 | g_return_val_if_fail (action != NULL, FALSE)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action != NULL") ; return ((0)); } } while (0); | |||
3471 | ctk_action_activate (action); | |||
3472 | #endif | |||
3473 | ||||
3474 | if (event != NULL((void*)0)) | |||
3475 | { | |||
3476 | ctk_menu_popup_at_pointer (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_get_type ())))))), NULL((void*)0)); | |||
3477 | } | |||
3478 | else | |||
3479 | { | |||
3480 | CtkWidget *tab; | |||
3481 | CtkWidget *tab_label; | |||
3482 | ||||
3483 | tab = CTK_WIDGET (lapiz_window_get_active_tab (window))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_window_get_active_tab (window))), ((ctk_widget_get_type ())))))); | |||
3484 | g_return_val_if_fail (tab != NULL, FALSE)do { if ((tab != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "tab != NULL"); return ((0)); } } while (0); | |||
3485 | ||||
3486 | tab_label = ctk_notebook_get_tab_label (notebook, tab); | |||
3487 | ||||
3488 | ctk_menu_popup_at_widget (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_get_type ())))))), | |||
3489 | tab_label, | |||
3490 | CDK_GRAVITY_SOUTH_WEST, | |||
3491 | CDK_GRAVITY_NORTH_WEST, | |||
3492 | (const CdkEvent*) event); | |||
3493 | ||||
3494 | 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)); | |||
3495 | } | |||
3496 | ||||
3497 | return TRUE(!(0)); | |||
3498 | } | |||
3499 | ||||
3500 | static gboolean | |||
3501 | notebook_button_press_event (CtkNotebook *notebook, | |||
3502 | CdkEventButton *event, | |||
3503 | LapizWindow *window) | |||
3504 | { | |||
3505 | if (event->type == CDK_BUTTON_PRESS) | |||
3506 | { | |||
3507 | if (event->button == 3) | |||
3508 | return show_notebook_popup_menu (notebook, window, event); | |||
3509 | ||||
3510 | else if (event->button == 2) | |||
3511 | { | |||
3512 | LapizTab *tab; | |||
3513 | tab = lapiz_window_get_active_tab (window); | |||
3514 | notebook_tab_close_request (LAPIZ_NOTEBOOK (notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((lapiz_notebook_get_type ())))))), tab, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
3515 | } | |||
3516 | } | |||
3517 | else if ((event->type == CDK_2BUTTON_PRESS) && (event->button == 1)) | |||
3518 | { | |||
3519 | lapiz_window_create_tab (window, TRUE(!(0))); | |||
3520 | } | |||
3521 | ||||
3522 | return FALSE(0); | |||
3523 | } | |||
3524 | ||||
3525 | static gboolean | |||
3526 | notebook_scroll_event (CtkNotebook *notebook, | |||
3527 | CdkEventScroll *event, | |||
3528 | LapizWindow *window G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
3529 | { | |||
3530 | if (event->direction == CDK_SCROLL_UP || event->direction == CDK_SCROLL_LEFT) | |||
3531 | { | |||
3532 | ctk_notebook_prev_page (notebook); | |||
3533 | } | |||
3534 | else if (event->direction == CDK_SCROLL_DOWN || event->direction == CDK_SCROLL_RIGHT) | |||
3535 | { | |||
3536 | ctk_notebook_next_page (notebook); | |||
3537 | } | |||
3538 | ||||
3539 | return FALSE(0); | |||
3540 | } | |||
3541 | ||||
3542 | static gboolean | |||
3543 | notebook_popup_menu (CtkNotebook *notebook, | |||
3544 | LapizWindow *window) | |||
3545 | { | |||
3546 | /* Only respond if the notebook is the actual focus */ | |||
3547 | if (LAPIZ_IS_NOTEBOOK (ctk_window_get_focus (CTK_WINDOW (window)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (ctk_window_get_focus (((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), ((ctk_window_get_type ())))))) ))); GType __t = ((lapiz_notebook_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; }))))) | |||
3548 | { | |||
3549 | return show_notebook_popup_menu (notebook, window, NULL((void*)0)); | |||
3550 | } | |||
3551 | ||||
3552 | return FALSE(0); | |||
3553 | } | |||
3554 | ||||
3555 | static void | |||
3556 | side_panel_size_allocate (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3557 | CtkAllocation *allocation, | |||
3558 | LapizWindow *window) | |||
3559 | { | |||
3560 | window->priv->side_panel_size = allocation->width; | |||
3561 | } | |||
3562 | ||||
3563 | static void | |||
3564 | bottom_panel_size_allocate (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3565 | CtkAllocation *allocation, | |||
3566 | LapizWindow *window) | |||
3567 | { | |||
3568 | window->priv->bottom_panel_size = allocation->height; | |||
3569 | } | |||
3570 | ||||
3571 | static void | |||
3572 | hpaned_restore_position (CtkWidget *widget, | |||
3573 | LapizWindow *window) | |||
3574 | { | |||
3575 | gint pos; | |||
3576 | ||||
3577 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3577, ((const char*) (__func__ )), | |||
3578 | "Restoring hpaned position: side panel size %d", | |||
3579 | window->priv->side_panel_size); | |||
3580 | ||||
3581 | pos = MAX (100, window->priv->side_panel_size)(((100) > (window->priv->side_panel_size)) ? (100) : (window->priv->side_panel_size)); | |||
3582 | ctk_paned_set_position (CTK_PANED (window->priv->hpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->hpaned)), ((ctk_paned_get_type ()))) ))), pos); | |||
3583 | ||||
3584 | /* start monitoring the size */ | |||
3585 | g_signal_connect (window->priv->side_panel,g_signal_connect_data ((window->priv->side_panel), ("size-allocate" ), (((GCallback) (side_panel_size_allocate))), (window), ((void *)0), (GConnectFlags) 0) | |||
3586 | "size-allocate",g_signal_connect_data ((window->priv->side_panel), ("size-allocate" ), (((GCallback) (side_panel_size_allocate))), (window), ((void *)0), (GConnectFlags) 0) | |||
3587 | G_CALLBACK (side_panel_size_allocate),g_signal_connect_data ((window->priv->side_panel), ("size-allocate" ), (((GCallback) (side_panel_size_allocate))), (window), ((void *)0), (GConnectFlags) 0) | |||
3588 | window)g_signal_connect_data ((window->priv->side_panel), ("size-allocate" ), (((GCallback) (side_panel_size_allocate))), (window), ((void *)0), (GConnectFlags) 0); | |||
3589 | ||||
3590 | /* run this only once */ | |||
3591 | g_signal_handlers_disconnect_by_func (widget, hpaned_restore_position, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (hpaned_restore_position), (window)); | |||
3592 | } | |||
3593 | ||||
3594 | static void | |||
3595 | vpaned_restore_position (CtkWidget *widget, | |||
3596 | LapizWindow *window) | |||
3597 | { | |||
3598 | CtkAllocation allocation; | |||
3599 | gint pos; | |||
3600 | ||||
3601 | ctk_widget_get_allocation (widget, &allocation); | |||
3602 | ||||
3603 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3603, ((const char*) (__func__ )), | |||
3604 | "Restoring vpaned position: bottom panel size %d", | |||
3605 | window->priv->bottom_panel_size); | |||
3606 | ||||
3607 | pos = allocation.height - | |||
3608 | MAX (50, window->priv->bottom_panel_size)(((50) > (window->priv->bottom_panel_size)) ? (50) : (window->priv->bottom_panel_size)); | |||
3609 | ctk_paned_set_position (CTK_PANED (window->priv->vpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->vpaned)), ((ctk_paned_get_type ()))) ))), pos); | |||
3610 | ||||
3611 | /* start monitoring the size */ | |||
3612 | g_signal_connect (window->priv->bottom_panel,g_signal_connect_data ((window->priv->bottom_panel), ("size-allocate" ), (((GCallback) (bottom_panel_size_allocate))), (window), (( void*)0), (GConnectFlags) 0) | |||
3613 | "size-allocate",g_signal_connect_data ((window->priv->bottom_panel), ("size-allocate" ), (((GCallback) (bottom_panel_size_allocate))), (window), (( void*)0), (GConnectFlags) 0) | |||
3614 | G_CALLBACK (bottom_panel_size_allocate),g_signal_connect_data ((window->priv->bottom_panel), ("size-allocate" ), (((GCallback) (bottom_panel_size_allocate))), (window), (( void*)0), (GConnectFlags) 0) | |||
3615 | window)g_signal_connect_data ((window->priv->bottom_panel), ("size-allocate" ), (((GCallback) (bottom_panel_size_allocate))), (window), (( void*)0), (GConnectFlags) 0); | |||
3616 | ||||
3617 | /* run this only once */ | |||
3618 | g_signal_handlers_disconnect_by_func (widget, vpaned_restore_position, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (vpaned_restore_position), (window)); | |||
3619 | } | |||
3620 | ||||
3621 | static void | |||
3622 | side_panel_visibility_changed (CtkWidget *side_panel, | |||
3623 | LapizWindow *window) | |||
3624 | { | |||
3625 | gboolean visible; | |||
3626 | CtkAction *action; | |||
3627 | ||||
3628 | visible = ctk_widget_get_visible (side_panel); | |||
3629 | ||||
3630 | if (!g_settings_get_boolean (lapiz_prefs_manager->settings, "show-tabs-with-side-pane")) | |||
3631 | { | |||
3632 | if (visible) | |||
3633 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), FALSE(0)); | |||
3634 | else | |||
3635 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), | |||
3636 | g_settings_get_boolean (lapiz_prefs_manager->settings, "show-single-tab") || | |||
3637 | (ctk_notebook_get_n_pages (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( )))))))) > 1)); | |||
3638 | } | |||
3639 | else | |||
3640 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), | |||
3641 | g_settings_get_boolean (lapiz_prefs_manager->settings, "show-single-tab") || | |||
3642 | (ctk_notebook_get_n_pages (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( )))))))) > 1)); | |||
3643 | ||||
3644 | if (lapiz_prefs_manager_side_pane_visible_can_set ()) | |||
3645 | lapiz_prefs_manager_set_side_pane_visible (visible); | |||
3646 | ||||
3647 | action = ctk_action_group_get_action (window->priv->panes_action_group, | |||
3648 | "ViewSidePane"); | |||
3649 | ||||
3650 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
3651 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
3652 | ||||
3653 | /* focus the document */ | |||
3654 | if (!visible && window->priv->active_tab != NULL((void*)0)) | |||
3655 | ctk_widget_grab_focus (CTK_WIDGET (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_view (((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->active_tab)), ((lapiz_tab_get_type ()))))))))), ((ctk_widget_get_type ())))))) | |||
3656 | lapiz_tab_get_view (LAPIZ_TAB (window->priv->active_tab)))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_view (((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->active_tab)), ((lapiz_tab_get_type ()))))))))), ((ctk_widget_get_type ()))))))); | |||
3657 | } | |||
3658 | ||||
3659 | static void | |||
3660 | create_side_panel (LapizWindow *window) | |||
3661 | { | |||
3662 | CtkWidget *documents_panel; | |||
3663 | ||||
3664 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3664, ((const char*) (__func__ ))); | |||
3665 | ||||
3666 | window->priv->side_panel = lapiz_panel_new (CTK_ORIENTATION_VERTICAL); | |||
3667 | ||||
3668 | ctk_paned_pack1 (CTK_PANED (window->priv->hpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->hpaned)), ((ctk_paned_get_type ()))) ))), | |||
3669 | window->priv->side_panel, | |||
3670 | FALSE(0), | |||
3671 | FALSE(0)); | |||
3672 | ||||
3673 | g_signal_connect_after (window->priv->side_panel,g_signal_connect_data ((window->priv->side_panel), ("show" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3674 | "show",g_signal_connect_data ((window->priv->side_panel), ("show" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3675 | G_CALLBACK (side_panel_visibility_changed),g_signal_connect_data ((window->priv->side_panel), ("show" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3676 | window)g_signal_connect_data ((window->priv->side_panel), ("show" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER); | |||
3677 | g_signal_connect_after (window->priv->side_panel,g_signal_connect_data ((window->priv->side_panel), ("hide" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3678 | "hide",g_signal_connect_data ((window->priv->side_panel), ("hide" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3679 | G_CALLBACK (side_panel_visibility_changed),g_signal_connect_data ((window->priv->side_panel), ("hide" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER) | |||
3680 | window)g_signal_connect_data ((window->priv->side_panel), ("hide" ), (((GCallback) (side_panel_visibility_changed))), (window), ((void*)0), G_CONNECT_AFTER); | |||
3681 | ||||
3682 | documents_panel = lapiz_documents_panel_new (window); | |||
3683 | lapiz_panel_add_item_with_icon (LAPIZ_PANEL (window->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->side_panel)), ((lapiz_panel_get_type ())))))), | |||
3684 | documents_panel, | |||
3685 | _("Documents")gettext ("Documents"), | |||
3686 | "text-x-generic"); | |||
3687 | } | |||
3688 | ||||
3689 | static void | |||
3690 | bottom_panel_visibility_changed (LapizPanel *bottom_panel, | |||
3691 | LapizWindow *window) | |||
3692 | { | |||
3693 | gboolean visible; | |||
3694 | CtkAction *action; | |||
3695 | ||||
3696 | visible = ctk_widget_get_visible (CTK_WIDGET (bottom_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((bottom_panel)), ((ctk_widget_get_type ()))))))); | |||
3697 | ||||
3698 | if (lapiz_prefs_manager_bottom_panel_visible_can_set ()) | |||
3699 | lapiz_prefs_manager_set_bottom_panel_visible (visible); | |||
3700 | ||||
3701 | action = ctk_action_group_get_action (window->priv->panes_action_group, | |||
3702 | "ViewBottomPane"); | |||
3703 | ||||
3704 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))) != visible) | |||
3705 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), visible); | |||
3706 | ||||
3707 | /* focus the document */ | |||
3708 | if (!visible && window->priv->active_tab != NULL((void*)0)) | |||
3709 | ctk_widget_grab_focus (CTK_WIDGET (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_view (((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->active_tab)), ((lapiz_tab_get_type ()))))))))), ((ctk_widget_get_type ())))))) | |||
3710 | lapiz_tab_get_view (LAPIZ_TAB (window->priv->active_tab)))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_tab_get_view (((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->active_tab)), ((lapiz_tab_get_type ()))))))))), ((ctk_widget_get_type ()))))))); | |||
3711 | } | |||
3712 | ||||
3713 | static void | |||
3714 | bottom_panel_item_removed (LapizPanel *panel, | |||
3715 | CtkWidget *item G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3716 | LapizWindow *window) | |||
3717 | { | |||
3718 | if (lapiz_panel_get_n_items (panel) == 0) | |||
3719 | { | |||
3720 | CtkAction *action; | |||
3721 | ||||
3722 | ctk_widget_hide (CTK_WIDGET (panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((panel)), ((ctk_widget_get_type ()))))))); | |||
3723 | ||||
3724 | action = ctk_action_group_get_action (window->priv->panes_action_group, | |||
3725 | "ViewBottomPane"); | |||
3726 | ctk_action_set_sensitive (action, FALSE(0)); | |||
3727 | } | |||
3728 | } | |||
3729 | ||||
3730 | static void | |||
3731 | bottom_panel_item_added (LapizPanel *panel, | |||
3732 | CtkWidget *item G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3733 | LapizWindow *window) | |||
3734 | { | |||
3735 | /* if it's the first item added, set the menu item | |||
3736 | * sensitive and if needed show the panel */ | |||
3737 | if (lapiz_panel_get_n_items (panel) == 1) | |||
3738 | { | |||
3739 | CtkAction *action; | |||
3740 | gboolean show; | |||
3741 | ||||
3742 | action = ctk_action_group_get_action (window->priv->panes_action_group, | |||
3743 | "ViewBottomPane"); | |||
3744 | ctk_action_set_sensitive (action, TRUE(!(0))); | |||
3745 | ||||
3746 | show = ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))); | |||
3747 | if (show) | |||
3748 | ctk_widget_show (CTK_WIDGET (panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((panel)), ((ctk_widget_get_type ()))))))); | |||
3749 | } | |||
3750 | } | |||
3751 | ||||
3752 | static void | |||
3753 | create_bottom_panel (LapizWindow *window) | |||
3754 | { | |||
3755 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3755, ((const char*) (__func__ ))); | |||
3756 | ||||
3757 | window->priv->bottom_panel = lapiz_panel_new (CTK_ORIENTATION_HORIZONTAL); | |||
3758 | ||||
3759 | ctk_paned_pack2 (CTK_PANED (window->priv->vpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->vpaned)), ((ctk_paned_get_type ()))) ))), | |||
3760 | window->priv->bottom_panel, | |||
3761 | FALSE(0), | |||
3762 | FALSE(0)); | |||
3763 | ||||
3764 | g_signal_connect_after (window->priv->bottom_panel,g_signal_connect_data ((window->priv->bottom_panel), ("show" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3765 | "show",g_signal_connect_data ((window->priv->bottom_panel), ("show" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3766 | G_CALLBACK (bottom_panel_visibility_changed),g_signal_connect_data ((window->priv->bottom_panel), ("show" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3767 | window)g_signal_connect_data ((window->priv->bottom_panel), ("show" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER); | |||
3768 | g_signal_connect_after (window->priv->bottom_panel,g_signal_connect_data ((window->priv->bottom_panel), ("hide" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3769 | "hide",g_signal_connect_data ((window->priv->bottom_panel), ("hide" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3770 | G_CALLBACK (bottom_panel_visibility_changed),g_signal_connect_data ((window->priv->bottom_panel), ("hide" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER) | |||
3771 | window)g_signal_connect_data ((window->priv->bottom_panel), ("hide" ), (((GCallback) (bottom_panel_visibility_changed))), (window ), ((void*)0), G_CONNECT_AFTER); | |||
3772 | } | |||
3773 | ||||
3774 | static void | |||
3775 | init_panels_visibility (LapizWindow *window) | |||
3776 | { | |||
3777 | gint active_page; | |||
3778 | ||||
3779 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3779, ((const char*) (__func__ ))); | |||
3780 | ||||
3781 | /* side pane */ | |||
3782 | active_page = lapiz_prefs_manager_get_side_panel_active_page (); | |||
3783 | _lapiz_panel_set_active_item_by_id (LAPIZ_PANEL (window->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->side_panel)), ((lapiz_panel_get_type ())))))), | |||
3784 | active_page); | |||
3785 | ||||
3786 | if (lapiz_prefs_manager_get_side_pane_visible ()) | |||
3787 | { | |||
3788 | ctk_widget_show (window->priv->side_panel); | |||
3789 | } | |||
3790 | ||||
3791 | /* bottom pane, it can be empty */ | |||
3792 | if (lapiz_panel_get_n_items (LAPIZ_PANEL (window->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->bottom_panel)), ((lapiz_panel_get_type ()))))))) > 0) | |||
3793 | { | |||
3794 | active_page = lapiz_prefs_manager_get_bottom_panel_active_page (); | |||
3795 | _lapiz_panel_set_active_item_by_id (LAPIZ_PANEL (window->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->bottom_panel)), ((lapiz_panel_get_type ())))))), | |||
3796 | active_page); | |||
3797 | ||||
3798 | if (lapiz_prefs_manager_get_bottom_panel_visible ()) | |||
3799 | { | |||
3800 | ctk_widget_show (window->priv->bottom_panel); | |||
3801 | } | |||
3802 | } | |||
3803 | else | |||
3804 | { | |||
3805 | CtkAction *action; | |||
3806 | action = ctk_action_group_get_action (window->priv->panes_action_group, | |||
3807 | "ViewBottomPane"); | |||
3808 | ctk_action_set_sensitive (action, FALSE(0)); | |||
3809 | } | |||
3810 | ||||
3811 | /* start track sensitivity after the initial state is set */ | |||
3812 | window->priv->bottom_panel_item_removed_handler_id = | |||
3813 | g_signal_connect (window->priv->bottom_panel,g_signal_connect_data ((window->priv->bottom_panel), ("item_removed" ), (((GCallback) (bottom_panel_item_removed))), (window), ((void *)0), (GConnectFlags) 0) | |||
3814 | "item_removed",g_signal_connect_data ((window->priv->bottom_panel), ("item_removed" ), (((GCallback) (bottom_panel_item_removed))), (window), ((void *)0), (GConnectFlags) 0) | |||
3815 | G_CALLBACK (bottom_panel_item_removed),g_signal_connect_data ((window->priv->bottom_panel), ("item_removed" ), (((GCallback) (bottom_panel_item_removed))), (window), ((void *)0), (GConnectFlags) 0) | |||
3816 | window)g_signal_connect_data ((window->priv->bottom_panel), ("item_removed" ), (((GCallback) (bottom_panel_item_removed))), (window), ((void *)0), (GConnectFlags) 0); | |||
3817 | ||||
3818 | g_signal_connect (window->priv->bottom_panel,g_signal_connect_data ((window->priv->bottom_panel), ("item_added" ), (((GCallback) (bottom_panel_item_added))), (window), ((void *)0), (GConnectFlags) 0) | |||
3819 | "item_added",g_signal_connect_data ((window->priv->bottom_panel), ("item_added" ), (((GCallback) (bottom_panel_item_added))), (window), ((void *)0), (GConnectFlags) 0) | |||
3820 | G_CALLBACK (bottom_panel_item_added),g_signal_connect_data ((window->priv->bottom_panel), ("item_added" ), (((GCallback) (bottom_panel_item_added))), (window), ((void *)0), (GConnectFlags) 0) | |||
3821 | window)g_signal_connect_data ((window->priv->bottom_panel), ("item_added" ), (((GCallback) (bottom_panel_item_added))), (window), ((void *)0), (GConnectFlags) 0); | |||
3822 | } | |||
3823 | ||||
3824 | static void | |||
3825 | clipboard_owner_change (CtkClipboard *clipboard, | |||
3826 | CdkEventOwnerChange *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3827 | LapizWindow *window) | |||
3828 | { | |||
3829 | set_paste_sensitivity_according_to_clipboard (window, | |||
3830 | clipboard); | |||
3831 | } | |||
3832 | ||||
3833 | static void | |||
3834 | window_realized (CtkWidget *window, | |||
3835 | gpointer *data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
3836 | { | |||
3837 | CtkClipboard *clipboard; | |||
3838 | ||||
3839 | clipboard = ctk_widget_get_clipboard (window, | |||
3840 | CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69)))); | |||
3841 | ||||
3842 | g_signal_connect (clipboard,g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3843 | "owner_change",g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3844 | G_CALLBACK (clipboard_owner_change),g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3845 | window)g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3846 | } | |||
3847 | ||||
3848 | static void | |||
3849 | window_unrealized (CtkWidget *window, | |||
3850 | gpointer *data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
3851 | { | |||
3852 | CtkClipboard *clipboard; | |||
3853 | ||||
3854 | clipboard = ctk_widget_get_clipboard (window, | |||
3855 | CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69)))); | |||
3856 | ||||
3857 | 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) (clipboard_owner_change))), (window)) | |||
3858 | G_CALLBACK (clipboard_owner_change),g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (clipboard_owner_change))), (window)) | |||
3859 | window)g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (clipboard_owner_change))), (window)); | |||
3860 | } | |||
3861 | ||||
3862 | static void | |||
3863 | check_window_is_active (LapizWindow *window, | |||
3864 | GParamSpec *property G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3865 | gpointer useless G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
3866 | { | |||
3867 | if (window->priv->window_state & CDK_WINDOW_STATE_FULLSCREEN) | |||
3868 | { | |||
3869 | if (ctk_window_is_active (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))))) | |||
3870 | { | |||
3871 | ctk_widget_show (window->priv->fullscreen_controls); | |||
3872 | } | |||
3873 | else | |||
3874 | { | |||
3875 | ctk_widget_hide (window->priv->fullscreen_controls); | |||
3876 | } | |||
3877 | } | |||
3878 | } | |||
3879 | ||||
3880 | static void | |||
3881 | connect_notebook_signals (LapizWindow *window, | |||
3882 | CtkWidget *notebook) | |||
3883 | { | |||
3884 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("switch-page"), (((GCallback ) (notebook_switch_page))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3885 | "switch-page",g_signal_connect_data ((notebook), ("switch-page"), (((GCallback ) (notebook_switch_page))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3886 | G_CALLBACK (notebook_switch_page),g_signal_connect_data ((notebook), ("switch-page"), (((GCallback ) (notebook_switch_page))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3887 | window)g_signal_connect_data ((notebook), ("switch-page"), (((GCallback ) (notebook_switch_page))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3888 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("tab-added"), (((GCallback ) (notebook_tab_added))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3889 | "tab-added",g_signal_connect_data ((notebook), ("tab-added"), (((GCallback ) (notebook_tab_added))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3890 | G_CALLBACK (notebook_tab_added),g_signal_connect_data ((notebook), ("tab-added"), (((GCallback ) (notebook_tab_added))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3891 | window)g_signal_connect_data ((notebook), ("tab-added"), (((GCallback ) (notebook_tab_added))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3892 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("tab-removed"), (((GCallback ) (notebook_tab_removed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3893 | "tab-removed",g_signal_connect_data ((notebook), ("tab-removed"), (((GCallback ) (notebook_tab_removed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3894 | G_CALLBACK (notebook_tab_removed),g_signal_connect_data ((notebook), ("tab-removed"), (((GCallback ) (notebook_tab_removed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3895 | window)g_signal_connect_data ((notebook), ("tab-removed"), (((GCallback ) (notebook_tab_removed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3896 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("tabs-reordered"), (((GCallback ) (notebook_tabs_reordered))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3897 | "tabs-reordered",g_signal_connect_data ((notebook), ("tabs-reordered"), (((GCallback ) (notebook_tabs_reordered))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3898 | G_CALLBACK (notebook_tabs_reordered),g_signal_connect_data ((notebook), ("tabs-reordered"), (((GCallback ) (notebook_tabs_reordered))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3899 | window)g_signal_connect_data ((notebook), ("tabs-reordered"), (((GCallback ) (notebook_tabs_reordered))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3900 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("tab-detached"), (((GCallback ) (notebook_tab_detached))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3901 | "tab-detached",g_signal_connect_data ((notebook), ("tab-detached"), (((GCallback ) (notebook_tab_detached))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3902 | G_CALLBACK (notebook_tab_detached),g_signal_connect_data ((notebook), ("tab-detached"), (((GCallback ) (notebook_tab_detached))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3903 | window)g_signal_connect_data ((notebook), ("tab-detached"), (((GCallback ) (notebook_tab_detached))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3904 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("tab-close-request"), ((( GCallback) (notebook_tab_close_request))), (window), ((void*) 0), (GConnectFlags) 0) | |||
3905 | "tab-close-request",g_signal_connect_data ((notebook), ("tab-close-request"), ((( GCallback) (notebook_tab_close_request))), (window), ((void*) 0), (GConnectFlags) 0) | |||
3906 | G_CALLBACK (notebook_tab_close_request),g_signal_connect_data ((notebook), ("tab-close-request"), ((( GCallback) (notebook_tab_close_request))), (window), ((void*) 0), (GConnectFlags) 0) | |||
3907 | window)g_signal_connect_data ((notebook), ("tab-close-request"), ((( GCallback) (notebook_tab_close_request))), (window), ((void*) 0), (GConnectFlags) 0); | |||
3908 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("button-press-event"), (( (GCallback) (notebook_button_press_event))), (window), ((void *)0), (GConnectFlags) 0) | |||
3909 | "button-press-event",g_signal_connect_data ((notebook), ("button-press-event"), (( (GCallback) (notebook_button_press_event))), (window), ((void *)0), (GConnectFlags) 0) | |||
3910 | G_CALLBACK (notebook_button_press_event),g_signal_connect_data ((notebook), ("button-press-event"), (( (GCallback) (notebook_button_press_event))), (window), ((void *)0), (GConnectFlags) 0) | |||
3911 | window)g_signal_connect_data ((notebook), ("button-press-event"), (( (GCallback) (notebook_button_press_event))), (window), ((void *)0), (GConnectFlags) 0); | |||
3912 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("popup-menu"), (((GCallback ) (notebook_popup_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3913 | "popup-menu",g_signal_connect_data ((notebook), ("popup-menu"), (((GCallback ) (notebook_popup_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3914 | G_CALLBACK (notebook_popup_menu),g_signal_connect_data ((notebook), ("popup-menu"), (((GCallback ) (notebook_popup_menu))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3915 | window)g_signal_connect_data ((notebook), ("popup-menu"), (((GCallback ) (notebook_popup_menu))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3916 | g_signal_connect (notebook,g_signal_connect_data ((notebook), ("scroll-event"), (((GCallback ) (notebook_scroll_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3917 | "scroll-event",g_signal_connect_data ((notebook), ("scroll-event"), (((GCallback ) (notebook_scroll_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3918 | G_CALLBACK (notebook_scroll_event),g_signal_connect_data ((notebook), ("scroll-event"), (((GCallback ) (notebook_scroll_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3919 | window)g_signal_connect_data ((notebook), ("scroll-event"), (((GCallback ) (notebook_scroll_event))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3920 | } | |||
3921 | ||||
3922 | static void | |||
3923 | add_notebook (LapizWindow *window, | |||
3924 | CtkWidget *notebook) | |||
3925 | { | |||
3926 | ctk_paned_pack1 (CTK_PANED (window->priv->vpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->vpaned)), ((ctk_paned_get_type ()))) ))), | |||
3927 | notebook, | |||
3928 | TRUE(!(0)), | |||
3929 | TRUE(!(0))); | |||
3930 | ||||
3931 | ctk_widget_show (notebook); | |||
3932 | ||||
3933 | ctk_widget_add_events (notebook, CDK_SCROLL_MASK); | |||
3934 | connect_notebook_signals (window, notebook); | |||
3935 | } | |||
3936 | ||||
3937 | static void | |||
3938 | on_extension_added (BeanExtensionSet *extensions G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3939 | BeanPluginInfo *info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3940 | BeanExtension *exten, | |||
3941 | LapizWindow *window) | |||
3942 | { | |||
3943 | bean_extension_call (exten, "activate", window); | |||
3944 | } | |||
3945 | ||||
3946 | static void | |||
3947 | on_extension_removed (BeanExtensionSet *extensions G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3948 | BeanPluginInfo *info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3949 | BeanExtension *exten, | |||
3950 | LapizWindow *window) | |||
3951 | { | |||
3952 | bean_extension_call (exten, "deactivate", window); | |||
3953 | ||||
3954 | /* Ensure update of ui manager, because we suspect it does something | |||
3955 | * with expected static strings in the type module (when unloaded the | |||
3956 | * strings don't exist anymore, and ui manager updates in an idle | |||
3957 | * func) */ | |||
3958 | ctk_ui_manager_ensure_update (window->priv->manager); | |||
3959 | } | |||
3960 | ||||
3961 | static void | |||
3962 | lapiz_window_init (LapizWindow *window) | |||
3963 | { | |||
3964 | CtkWidget *main_box; | |||
3965 | CtkTargetList *tl; | |||
3966 | ||||
3967 | lapiz_debug (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3967, ((const char*) (__func__ ))); | |||
3968 | ||||
3969 | window->priv = lapiz_window_get_instance_private (window); | |||
3970 | window->priv->active_tab = NULL((void*)0); | |||
3971 | window->priv->num_tabs = 0; | |||
3972 | window->priv->removing_tabs = FALSE(0); | |||
3973 | window->priv->state = LAPIZ_WINDOW_STATE_NORMAL; | |||
3974 | window->priv->dispose_has_run = FALSE(0); | |||
3975 | window->priv->fullscreen_controls = NULL((void*)0); | |||
3976 | window->priv->fullscreen_animation_timeout_id = 0; | |||
3977 | ||||
3978 | window->priv->message_bus = lapiz_message_bus_new (); | |||
3979 | ||||
3980 | window->priv->window_group = ctk_window_group_new (); | |||
3981 | ctk_window_group_add_window (window->priv->window_group, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
3982 | ||||
3983 | CtkStyleContext *context; | |||
3984 | ||||
3985 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
3986 | ctk_style_context_add_class (context, "lapiz-window"); | |||
3987 | ||||
3988 | main_box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
3989 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), main_box); | |||
3990 | ctk_widget_show (main_box); | |||
3991 | ||||
3992 | /* Add menu bar and toolbar bar */ | |||
3993 | create_menu_bar_and_toolbar (window, main_box); | |||
3994 | ||||
3995 | /* Add status bar */ | |||
3996 | create_statusbar (window, main_box); | |||
3997 | ||||
3998 | /* Add the main area */ | |||
3999 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 3999, ((const char*) (__func__ )), "Add main area"); | |||
4000 | window->priv->hpaned = ctk_paned_new (CTK_ORIENTATION_HORIZONTAL); | |||
4001 | ctk_box_pack_start (CTK_BOX (main_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_box)), ((ctk_box_get_type ())))))), | |||
4002 | window->priv->hpaned, | |||
4003 | TRUE(!(0)), | |||
4004 | TRUE(!(0)), | |||
4005 | 0); | |||
4006 | ||||
4007 | window->priv->vpaned = ctk_paned_new (CTK_ORIENTATION_VERTICAL); | |||
4008 | ctk_paned_pack2 (CTK_PANED (window->priv->hpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->hpaned)), ((ctk_paned_get_type ()))) ))), | |||
4009 | window->priv->vpaned, | |||
4010 | TRUE(!(0)), | |||
4011 | FALSE(0)); | |||
4012 | ||||
4013 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 4013, ((const char*) (__func__ )), "Create lapiz notebook"); | |||
4014 | window->priv->notebook = lapiz_notebook_new (); | |||
4015 | add_notebook (window, window->priv->notebook); | |||
4016 | ||||
4017 | /* side and bottom panels */ | |||
4018 | create_side_panel (window); | |||
4019 | create_bottom_panel (window); | |||
4020 | ||||
4021 | /* panes' state must be restored after panels have been mapped, | |||
4022 | * since the bottom pane position depends on the size of the vpaned. */ | |||
4023 | window->priv->side_panel_size = lapiz_prefs_manager_get_side_panel_size (); | |||
4024 | window->priv->bottom_panel_size = lapiz_prefs_manager_get_bottom_panel_size (); | |||
4025 | ||||
4026 | g_signal_connect_after (window->priv->hpaned,g_signal_connect_data ((window->priv->hpaned), ("map"), (((GCallback) (hpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4027 | "map",g_signal_connect_data ((window->priv->hpaned), ("map"), (((GCallback) (hpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4028 | G_CALLBACK (hpaned_restore_position),g_signal_connect_data ((window->priv->hpaned), ("map"), (((GCallback) (hpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4029 | window)g_signal_connect_data ((window->priv->hpaned), ("map"), (((GCallback) (hpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER); | |||
4030 | g_signal_connect_after (window->priv->vpaned,g_signal_connect_data ((window->priv->vpaned), ("map"), (((GCallback) (vpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4031 | "map",g_signal_connect_data ((window->priv->vpaned), ("map"), (((GCallback) (vpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4032 | G_CALLBACK (vpaned_restore_position),g_signal_connect_data ((window->priv->vpaned), ("map"), (((GCallback) (vpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER) | |||
4033 | window)g_signal_connect_data ((window->priv->vpaned), ("map"), (((GCallback) (vpaned_restore_position))), (window), ((void* )0), G_CONNECT_AFTER); | |||
4034 | ||||
4035 | ctk_widget_show (window->priv->hpaned); | |||
4036 | ctk_widget_show (window->priv->vpaned); | |||
4037 | ||||
4038 | /* Drag and drop support, set targets to NULL because we add the | |||
4039 | default uri_targets below */ | |||
4040 | ctk_drag_dest_set (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | |||
4041 | CTK_DEST_DEFAULT_MOTION | | |||
4042 | CTK_DEST_DEFAULT_HIGHLIGHT | | |||
4043 | CTK_DEST_DEFAULT_DROP, | |||
4044 | NULL((void*)0), | |||
4045 | 0, | |||
4046 | CDK_ACTION_COPY); | |||
4047 | ||||
4048 | /* Add uri targets */ | |||
4049 | tl = ctk_drag_dest_get_target_list (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
4050 | ||||
4051 | if (tl == NULL((void*)0)) | |||
4052 | { | |||
4053 | tl = ctk_target_list_new (NULL((void*)0), 0); | |||
4054 | ctk_drag_dest_set_target_list (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), tl); | |||
4055 | ctk_target_list_unref (tl); | |||
4056 | } | |||
4057 | ||||
4058 | ctk_target_list_add_uri_targets (tl, TARGET_URI_LIST); | |||
4059 | ||||
4060 | /* connect instead of override, so that we can | |||
4061 | * share the cb code with the view */ | |||
4062 | g_signal_connect (window,g_signal_connect_data ((window), ("drag_data_received"), (((GCallback ) (drag_data_received_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4063 | "drag_data_received",g_signal_connect_data ((window), ("drag_data_received"), (((GCallback ) (drag_data_received_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4064 | G_CALLBACK (drag_data_received_cb),g_signal_connect_data ((window), ("drag_data_received"), (((GCallback ) (drag_data_received_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4065 | NULL)g_signal_connect_data ((window), ("drag_data_received"), (((GCallback ) (drag_data_received_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
4066 | ||||
4067 | /* we can get the clipboard only after the widget | |||
4068 | * is realized */ | |||
4069 | g_signal_connect (window,g_signal_connect_data ((window), ("realize"), (((GCallback) ( window_realized))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
4070 | "realize",g_signal_connect_data ((window), ("realize"), (((GCallback) ( window_realized))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
4071 | G_CALLBACK (window_realized),g_signal_connect_data ((window), ("realize"), (((GCallback) ( window_realized))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
4072 | NULL)g_signal_connect_data ((window), ("realize"), (((GCallback) ( window_realized))), (((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
4073 | g_signal_connect (window,g_signal_connect_data ((window), ("unrealize"), (((GCallback) (window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4074 | "unrealize",g_signal_connect_data ((window), ("unrealize"), (((GCallback) (window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4075 | G_CALLBACK (window_unrealized),g_signal_connect_data ((window), ("unrealize"), (((GCallback) (window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4076 | NULL)g_signal_connect_data ((window), ("unrealize"), (((GCallback) (window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
4077 | ||||
4078 | /* Check if the window is active for fullscreen */ | |||
4079 | g_signal_connect (window,g_signal_connect_data ((window), ("notify::is-active"), (((GCallback ) (check_window_is_active))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4080 | "notify::is-active",g_signal_connect_data ((window), ("notify::is-active"), (((GCallback ) (check_window_is_active))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4081 | G_CALLBACK (check_window_is_active),g_signal_connect_data ((window), ("notify::is-active"), (((GCallback ) (check_window_is_active))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
4082 | NULL)g_signal_connect_data ((window), ("notify::is-active"), (((GCallback ) (check_window_is_active))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
4083 | ||||
4084 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 4084, ((const char*) (__func__ )), "Update plugins ui"); | |||
4085 | ||||
4086 | window->priv->extensions = bean_extension_set_new (BEAN_ENGINE (lapiz_plugins_engine_get_default ())((((BeanEngine*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lapiz_plugins_engine_get_default ())), ((bean_engine_get_type ())))))), | |||
4087 | BEAN_TYPE_ACTIVATABLE(bean_activatable_get_type ()), "object", window, NULL((void*)0)); | |||
4088 | ||||
4089 | bean_extension_set_call (window->priv->extensions, "activate"); | |||
4090 | ||||
4091 | g_signal_connect (window->priv->extensions,g_signal_connect_data ((window->priv->extensions), ("extension-added" ), (((GCallback) (on_extension_added))), (window), ((void*)0) , (GConnectFlags) 0) | |||
4092 | "extension-added",g_signal_connect_data ((window->priv->extensions), ("extension-added" ), (((GCallback) (on_extension_added))), (window), ((void*)0) , (GConnectFlags) 0) | |||
4093 | G_CALLBACK (on_extension_added),g_signal_connect_data ((window->priv->extensions), ("extension-added" ), (((GCallback) (on_extension_added))), (window), ((void*)0) , (GConnectFlags) 0) | |||
4094 | window)g_signal_connect_data ((window->priv->extensions), ("extension-added" ), (((GCallback) (on_extension_added))), (window), ((void*)0) , (GConnectFlags) 0); | |||
4095 | g_signal_connect (window->priv->extensions,g_signal_connect_data ((window->priv->extensions), ("extension-removed" ), (((GCallback) (on_extension_removed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
4096 | "extension-removed",g_signal_connect_data ((window->priv->extensions), ("extension-removed" ), (((GCallback) (on_extension_removed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
4097 | G_CALLBACK (on_extension_removed),g_signal_connect_data ((window->priv->extensions), ("extension-removed" ), (((GCallback) (on_extension_removed))), (window), ((void*) 0), (GConnectFlags) 0) | |||
4098 | window)g_signal_connect_data ((window->priv->extensions), ("extension-removed" ), (((GCallback) (on_extension_removed))), (window), ((void*) 0), (GConnectFlags) 0); | |||
4099 | ||||
4100 | /* set visibility of panes. | |||
4101 | * This needs to be done after plugins activatation */ | |||
4102 | init_panels_visibility (window); | |||
4103 | ||||
4104 | update_sensitivity_according_to_open_tabs (window); | |||
4105 | ||||
4106 | lapiz_debug_message (DEBUG_WINDOWLAPIZ_DEBUG_WINDOW, "lapiz-window.c", 4106, ((const char*) (__func__ )), "END"); | |||
4107 | } | |||
4108 | ||||
4109 | /** | |||
4110 | * lapiz_window_get_active_view: | |||
4111 | * @window: a #LapizWindow | |||
4112 | * | |||
4113 | * Gets the active #LapizView. | |||
4114 | * | |||
4115 | * Returns: (transfer none): the active #LapizView | |||
4116 | */ | |||
4117 | LapizView * | |||
4118 | lapiz_window_get_active_view (LapizWindow *window) | |||
4119 | { | |||
4120 | LapizView *view; | |||
4121 | ||||
4122 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4123 | ||||
4124 | if (window->priv->active_tab == NULL((void*)0)) | |||
4125 | return NULL((void*)0); | |||
4126 | ||||
4127 | view = lapiz_tab_get_view (LAPIZ_TAB (window->priv->active_tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->active_tab)), ((lapiz_tab_get_type() ))))))); | |||
4128 | ||||
4129 | return view; | |||
4130 | } | |||
4131 | ||||
4132 | /** | |||
4133 | * lapiz_window_get_active_document: | |||
4134 | * @window: a #LapizWindow | |||
4135 | * | |||
4136 | * Gets the active #LapizDocument. | |||
4137 | * | |||
4138 | * Returns: (transfer none): the active #LapizDocument | |||
4139 | */ | |||
4140 | LapizDocument * | |||
4141 | lapiz_window_get_active_document (LapizWindow *window) | |||
4142 | { | |||
4143 | LapizView *view; | |||
4144 | ||||
4145 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4146 | ||||
4147 | view = lapiz_window_get_active_view (window); | |||
4148 | if (view == NULL((void*)0)) | |||
4149 | return NULL((void*)0); | |||
4150 | ||||
4151 | return LAPIZ_DOCUMENT (ctk_text_view_get_buffer (CTK_TEXT_VIEW (view)))((((LapizDocument*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_text_view_get_buffer (((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), ((ctk_text_view_get_type ()))))) )))), ((lapiz_document_get_type())))))); | |||
4152 | } | |||
4153 | ||||
4154 | CtkWidget * | |||
4155 | _lapiz_window_get_notebook (LapizWindow *window) | |||
4156 | { | |||
4157 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4158 | ||||
4159 | return window->priv->notebook; | |||
4160 | } | |||
4161 | ||||
4162 | /** | |||
4163 | * lapiz_window_create_tab: | |||
4164 | * @window: a #LapizWindow | |||
4165 | * @jump_to: %TRUE to set the new #LapizTab as active | |||
4166 | * | |||
4167 | * Creates a new #LapizTab and adds the new tab to the #LapizNotebook. | |||
4168 | * In case @jump_to is %TRUE the #LapizNotebook switches to that new #LapizTab. | |||
4169 | * | |||
4170 | * Returns: (transfer none): a new #LapizTab | |||
4171 | */ | |||
4172 | LapizTab * | |||
4173 | lapiz_window_create_tab (LapizWindow *window, | |||
4174 | gboolean jump_to) | |||
4175 | { | |||
4176 | LapizTab *tab; | |||
4177 | ||||
4178 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4179 | ||||
4180 | tab = LAPIZ_TAB (_lapiz_tab_new ())((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((_lapiz_tab_new ())), ((lapiz_tab_get_type())))))); | |||
4181 | ctk_widget_show (CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((ctk_widget_get_type ()))))))); | |||
4182 | ||||
4183 | lapiz_notebook_add_tab (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4184 | tab, | |||
4185 | -1, | |||
4186 | jump_to); | |||
4187 | ||||
4188 | if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
4189 | { | |||
4190 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
4191 | } | |||
4192 | ||||
4193 | return tab; | |||
4194 | } | |||
4195 | ||||
4196 | /** | |||
4197 | * lapiz_window_create_tab_from_uri: | |||
4198 | * @window: a #LapizWindow | |||
4199 | * @uri: the uri of the document | |||
4200 | * @encoding: a #LapizEncoding | |||
4201 | * @line_pos: the line position to visualize | |||
4202 | * @create: %TRUE to create a new document in case @uri does exist | |||
4203 | * @jump_to: %TRUE to set the new #LapizTab as active | |||
4204 | * | |||
4205 | * Creates a new #LapizTab loading the document specified by @uri. | |||
4206 | * In case @jump_to is %TRUE the #LapizNotebook swithes to that new #LapizTab. | |||
4207 | * Whether @create is %TRUE, creates a new empty document if location does | |||
4208 | * not refer to an existing file | |||
4209 | * | |||
4210 | * Returns: (transfer none): a new #LapizTab | |||
4211 | */ | |||
4212 | LapizTab * | |||
4213 | lapiz_window_create_tab_from_uri (LapizWindow *window, | |||
4214 | const gchar *uri, | |||
4215 | const LapizEncoding *encoding, | |||
4216 | gint line_pos, | |||
4217 | gboolean create, | |||
4218 | gboolean jump_to) | |||
4219 | { | |||
4220 | CtkWidget *tab; | |||
4221 | ||||
4222 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4223 | g_return_val_if_fail (uri != NULL, NULL)do { if ((uri != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "uri != NULL"); return (((void*)0)); } } while (0); | |||
4224 | ||||
4225 | tab = _lapiz_tab_new_from_uri (uri, | |||
4226 | encoding, | |||
4227 | line_pos, | |||
4228 | create); | |||
4229 | if (tab == NULL((void*)0)) | |||
4230 | return NULL((void*)0); | |||
4231 | ||||
4232 | ctk_widget_show (tab); | |||
4233 | ||||
4234 | lapiz_notebook_add_tab (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4235 | LAPIZ_TAB (tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((lapiz_tab_get_type())))))), | |||
4236 | -1, | |||
4237 | jump_to); | |||
4238 | ||||
4239 | ||||
4240 | if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
4241 | { | |||
4242 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
4243 | } | |||
4244 | ||||
4245 | return LAPIZ_TAB (tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((lapiz_tab_get_type())))))); | |||
4246 | } | |||
4247 | ||||
4248 | /** | |||
4249 | * lapiz_window_get_active_tab: | |||
4250 | * @window: a LapizWindow | |||
4251 | * | |||
4252 | * Gets the active #LapizTab in the @window. | |||
4253 | * | |||
4254 | * Returns: (transfer none): the active #LapizTab in the @window. | |||
4255 | */ | |||
4256 | LapizTab * | |||
4257 | lapiz_window_get_active_tab (LapizWindow *window) | |||
4258 | { | |||
4259 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4260 | ||||
4261 | return (window->priv->active_tab == NULL((void*)0)) ? | |||
4262 | NULL((void*)0) : LAPIZ_TAB (window->priv->active_tab)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->active_tab)), ((lapiz_tab_get_type() )))))); | |||
4263 | } | |||
4264 | ||||
4265 | static void | |||
4266 | add_document (LapizTab *tab, GList **res) | |||
4267 | { | |||
4268 | LapizDocument *doc; | |||
4269 | ||||
4270 | doc = lapiz_tab_get_document (tab); | |||
4271 | ||||
4272 | *res = g_list_prepend (*res, doc); | |||
4273 | } | |||
4274 | ||||
4275 | /** | |||
4276 | * lapiz_window_get_documents: | |||
4277 | * @window: a #LapizWindow | |||
4278 | * | |||
4279 | * Gets a newly allocated list with all the documents in the window. | |||
4280 | * This list must be freed. | |||
4281 | * | |||
4282 | * Returns: (element-type Lapiz.Document) (transfer container): a newly | |||
4283 | * allocated list with all the documents in the window | |||
4284 | */ | |||
4285 | GList * | |||
4286 | lapiz_window_get_documents (LapizWindow *window) | |||
4287 | { | |||
4288 | GList *res = NULL((void*)0); | |||
4289 | ||||
4290 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4291 | ||||
4292 | ctk_container_foreach (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ())))))), | |||
4293 | (CtkCallback)add_document, | |||
4294 | &res); | |||
4295 | ||||
4296 | res = g_list_reverse (res); | |||
4297 | ||||
4298 | return res; | |||
4299 | } | |||
4300 | ||||
4301 | static void | |||
4302 | add_view (LapizTab *tab, GList **res) | |||
4303 | { | |||
4304 | LapizView *view; | |||
4305 | ||||
4306 | view = lapiz_tab_get_view (tab); | |||
4307 | ||||
4308 | *res = g_list_prepend (*res, view); | |||
4309 | } | |||
4310 | ||||
4311 | /** | |||
4312 | * lapiz_window_get_views: | |||
4313 | * @window: a #LapizWindow | |||
4314 | * | |||
4315 | * Gets a list with all the views in the window. This list must be freed. | |||
4316 | * | |||
4317 | * Returns: (element-type Lapiz.View) (transfer container): a newly allocated | |||
4318 | * list with all the views in the window | |||
4319 | */ | |||
4320 | GList * | |||
4321 | lapiz_window_get_views (LapizWindow *window) | |||
4322 | { | |||
4323 | GList *res = NULL((void*)0); | |||
4324 | ||||
4325 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4326 | ||||
4327 | ctk_container_foreach (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ())))))), | |||
4328 | (CtkCallback)add_view, | |||
4329 | &res); | |||
4330 | ||||
4331 | res = g_list_reverse (res); | |||
4332 | ||||
4333 | return res; | |||
4334 | } | |||
4335 | ||||
4336 | /** | |||
4337 | * lapiz_window_close_tab: | |||
4338 | * @window: a #LapizWindow | |||
4339 | * @tab: the #LapizTab to close | |||
4340 | * | |||
4341 | * Closes the @tab. | |||
4342 | */ | |||
4343 | void | |||
4344 | lapiz_window_close_tab (LapizWindow *window, | |||
4345 | LapizTab *tab) | |||
4346 | { | |||
4347 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4348 | g_return_if_fail (LAPIZ_IS_TAB (tab))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tab)); GType __t = ((lapiz_tab_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__)), "LAPIZ_IS_TAB (tab)"); return; } } while (0); | |||
4349 | g_return_if_fail ((lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SAVING) &&do { if (((lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SAVING ) && (lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "(lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SAVING) && (lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW)" ); return; } } while (0) | |||
4350 | (lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW))do { if (((lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SAVING ) && (lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "(lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SAVING) && (lapiz_tab_get_state (tab) != LAPIZ_TAB_STATE_SHOWING_PRINT_PREVIEW)" ); return; } } while (0); | |||
4351 | ||||
4352 | lapiz_notebook_remove_tab (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4353 | tab); | |||
4354 | } | |||
4355 | ||||
4356 | /** | |||
4357 | * lapiz_window_close_all_tabs: | |||
4358 | * @window: a #LapizWindow | |||
4359 | * | |||
4360 | * Closes all opened tabs. | |||
4361 | */ | |||
4362 | void | |||
4363 | lapiz_window_close_all_tabs (LapizWindow *window) | |||
4364 | { | |||
4365 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4366 | g_return_if_fail (!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) &&do { if ((!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING ) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)" ); return; } } while (0) | |||
4367 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION))do { if ((!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING ) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)" ); return; } } while (0); | |||
4368 | ||||
4369 | window->priv->removing_tabs = TRUE(!(0)); | |||
4370 | ||||
4371 | lapiz_notebook_remove_all_tabs (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ()))))))); | |||
4372 | ||||
4373 | window->priv->removing_tabs = FALSE(0); | |||
4374 | } | |||
4375 | ||||
4376 | /** | |||
4377 | * lapiz_window_close_tabs: | |||
4378 | * @window: a #LapizWindow | |||
4379 | * @tabs: (element-type Lapiz.Tab): a list of #LapizTab | |||
4380 | * | |||
4381 | * Closes all tabs specified by @tabs. | |||
4382 | */ | |||
4383 | void | |||
4384 | lapiz_window_close_tabs (LapizWindow *window, | |||
4385 | const GList *tabs) | |||
4386 | { | |||
4387 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4388 | g_return_if_fail (!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) &&do { if ((!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING ) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)" ); return; } } while (0) | |||
4389 | !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION))do { if ((!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING ) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION ))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "!(window->priv->state & LAPIZ_WINDOW_STATE_SAVING) && !(window->priv->state & LAPIZ_WINDOW_STATE_SAVING_SESSION)" ); return; } } while (0); | |||
4390 | ||||
4391 | if (tabs == NULL((void*)0)) | |||
4392 | return; | |||
4393 | ||||
4394 | window->priv->removing_tabs = TRUE(!(0)); | |||
4395 | ||||
4396 | while (tabs != NULL((void*)0)) | |||
4397 | { | |||
4398 | if (tabs->next == NULL((void*)0)) | |||
4399 | window->priv->removing_tabs = FALSE(0); | |||
4400 | ||||
4401 | lapiz_notebook_remove_tab (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4402 | LAPIZ_TAB (tabs->data)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tabs->data)), ((lapiz_tab_get_type()))))))); | |||
4403 | ||||
4404 | tabs = g_list_next (tabs)((tabs) ? (((GList *)(tabs))->next) : ((void*)0)); | |||
4405 | } | |||
4406 | ||||
4407 | g_return_if_fail (window->priv->removing_tabs == FALSE)do { if ((window->priv->removing_tabs == (0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__ )), "window->priv->removing_tabs == FALSE"); return; } } while (0); | |||
4408 | } | |||
4409 | ||||
4410 | LapizWindow * | |||
4411 | _lapiz_window_move_tab_to_new_window (LapizWindow *window, | |||
4412 | LapizTab *tab) | |||
4413 | { | |||
4414 | LapizWindow *new_window; | |||
4415 | ||||
4416 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4417 | g_return_val_if_fail (LAPIZ_IS_TAB (tab), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tab)); GType __t = ((lapiz_tab_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__)), "LAPIZ_IS_TAB (tab)"); return (((void*)0)); } } while (0); | |||
4418 | g_return_val_if_fail (ctk_notebook_get_n_pages (do { if ((ctk_notebook_get_n_pages ( ((((CtkNotebook*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((window->priv ->notebook)), ((ctk_notebook_get_type ()))))))) > 1)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char *) (__func__)), "ctk_notebook_get_n_pages ( CTK_NOTEBOOK (window->priv->notebook)) > 1" ); return (((void*)0)); } } while (0) | |||
4419 | CTK_NOTEBOOK (window->priv->notebook)) > 1,do { if ((ctk_notebook_get_n_pages ( ((((CtkNotebook*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((window->priv ->notebook)), ((ctk_notebook_get_type ()))))))) > 1)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char *) (__func__)), "ctk_notebook_get_n_pages ( CTK_NOTEBOOK (window->priv->notebook)) > 1" ); return (((void*)0)); } } while (0) | |||
4420 | NULL)do { if ((ctk_notebook_get_n_pages ( ((((CtkNotebook*) (void * ) g_type_check_instance_cast ((GTypeInstance*) ((window->priv ->notebook)), ((ctk_notebook_get_type ()))))))) > 1)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char *) (__func__)), "ctk_notebook_get_n_pages ( CTK_NOTEBOOK (window->priv->notebook)) > 1" ); return (((void*)0)); } } while (0); | |||
4421 | ||||
4422 | new_window = clone_window (window); | |||
4423 | ||||
4424 | lapiz_notebook_move_tab (LAPIZ_NOTEBOOK (window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4425 | LAPIZ_NOTEBOOK (new_window->priv->notebook)((((LapizNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window->priv->notebook)), ((lapiz_notebook_get_type ())))))), | |||
4426 | tab, | |||
4427 | -1); | |||
4428 | ||||
4429 | ctk_widget_show (CTK_WIDGET (new_window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window)), ((ctk_widget_get_type ()))))))); | |||
4430 | ||||
4431 | return new_window; | |||
4432 | } | |||
4433 | ||||
4434 | /** | |||
4435 | * lapiz_window_set_active_tab: | |||
4436 | * @window: a #LapizWindow | |||
4437 | * @tab: a #LapizTab | |||
4438 | * | |||
4439 | * Switches to the tab that matches with @tab. | |||
4440 | */ | |||
4441 | void | |||
4442 | lapiz_window_set_active_tab (LapizWindow *window, | |||
4443 | LapizTab *tab) | |||
4444 | { | |||
4445 | gint page_num; | |||
4446 | ||||
4447 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4448 | g_return_if_fail (LAPIZ_IS_TAB (tab))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tab)); GType __t = ((lapiz_tab_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__)), "LAPIZ_IS_TAB (tab)"); return; } } while (0); | |||
4449 | ||||
4450 | page_num = ctk_notebook_page_num (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), | |||
4451 | CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((ctk_widget_get_type ()))))))); | |||
4452 | g_return_if_fail (page_num != -1)do { if ((page_num != -1)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "page_num != -1") ; return; } } while (0); | |||
4453 | ||||
4454 | ctk_notebook_set_current_page (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), | |||
4455 | page_num); | |||
4456 | } | |||
4457 | ||||
4458 | /** | |||
4459 | * lapiz_window_get_group: | |||
4460 | * @window: a #LapizWindow | |||
4461 | * | |||
4462 | * Gets the #CtkWindowGroup in which @window resides. | |||
4463 | * | |||
4464 | * Returns: (transfer none): the #CtkWindowGroup | |||
4465 | */ | |||
4466 | CtkWindowGroup * | |||
4467 | lapiz_window_get_group (LapizWindow *window) | |||
4468 | { | |||
4469 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4470 | ||||
4471 | return window->priv->window_group; | |||
4472 | } | |||
4473 | ||||
4474 | gboolean | |||
4475 | _lapiz_window_is_removing_tabs (LapizWindow *window) | |||
4476 | { | |||
4477 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return ((0)); } } while (0); | |||
4478 | ||||
4479 | return window->priv->removing_tabs; | |||
4480 | } | |||
4481 | ||||
4482 | /** | |||
4483 | * lapiz_window_get_ui_manager: | |||
4484 | * @window: a #LapizWindow | |||
4485 | * | |||
4486 | * Gets the #CtkUIManager associated with the @window. | |||
4487 | * | |||
4488 | * Returns: (transfer none): the #CtkUIManager of the @window. | |||
4489 | */ | |||
4490 | CtkUIManager * | |||
4491 | lapiz_window_get_ui_manager (LapizWindow *window) | |||
4492 | { | |||
4493 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4494 | ||||
4495 | return window->priv->manager; | |||
4496 | } | |||
4497 | ||||
4498 | /** | |||
4499 | * lapiz_window_get_side_panel: | |||
4500 | * @window: a #LapizWindow | |||
4501 | * | |||
4502 | * Gets the side #LapizPanel of the @window. | |||
4503 | * | |||
4504 | * Returns: (transfer none): the side #LapizPanel. | |||
4505 | */ | |||
4506 | LapizPanel * | |||
4507 | lapiz_window_get_side_panel (LapizWindow *window) | |||
4508 | { | |||
4509 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4510 | ||||
4511 | return LAPIZ_PANEL (window->priv->side_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->side_panel)), ((lapiz_panel_get_type ())))))); | |||
4512 | } | |||
4513 | ||||
4514 | /** | |||
4515 | * lapiz_window_get_bottom_panel: | |||
4516 | * @window: a #LapizWindow | |||
4517 | * | |||
4518 | * Gets the bottom #LapizPanel of the @window. | |||
4519 | * | |||
4520 | * Returns: (transfer none): the bottom #LapizPanel. | |||
4521 | */ | |||
4522 | LapizPanel * | |||
4523 | lapiz_window_get_bottom_panel (LapizWindow *window) | |||
4524 | { | |||
4525 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4526 | ||||
4527 | return LAPIZ_PANEL (window->priv->bottom_panel)((((LapizPanel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->bottom_panel)), ((lapiz_panel_get_type ())))))); | |||
4528 | } | |||
4529 | ||||
4530 | /** | |||
4531 | * lapiz_window_get_statusbar: | |||
4532 | * @window: a #LapizWindow | |||
4533 | * | |||
4534 | * Gets the #LapizStatusbar of the @window. | |||
4535 | * | |||
4536 | * Returns: (transfer none): the #LapizStatusbar of the @window. | |||
4537 | */ | |||
4538 | CtkWidget * | |||
4539 | lapiz_window_get_statusbar (LapizWindow *window) | |||
4540 | { | |||
4541 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (0); } } while (0); | |||
4542 | ||||
4543 | return window->priv->statusbar; | |||
4544 | } | |||
4545 | ||||
4546 | /** | |||
4547 | * lapiz_window_get_state: | |||
4548 | * @window: a #LapizWindow | |||
4549 | * | |||
4550 | * Retrieves the state of the @window. | |||
4551 | * | |||
4552 | * Returns: the current #LapizWindowState of the @window. | |||
4553 | */ | |||
4554 | LapizWindowState | |||
4555 | lapiz_window_get_state (LapizWindow *window) | |||
4556 | { | |||
4557 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), LAPIZ_WINDOW_STATE_NORMAL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (LAPIZ_WINDOW_STATE_NORMAL ); } } while (0); | |||
4558 | ||||
4559 | return window->priv->state; | |||
4560 | } | |||
4561 | ||||
4562 | GFile * | |||
4563 | _lapiz_window_get_default_location (LapizWindow *window) | |||
4564 | { | |||
4565 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4566 | ||||
4567 | return window->priv->default_location != NULL((void*)0) ? | |||
4568 | g_object_ref (window->priv->default_location)((__typeof__ (window->priv->default_location)) (g_object_ref ) (window->priv->default_location)) : NULL((void*)0); | |||
4569 | } | |||
4570 | ||||
4571 | void | |||
4572 | _lapiz_window_set_default_location (LapizWindow *window, | |||
4573 | GFile *location) | |||
4574 | { | |||
4575 | GFile *dir; | |||
4576 | ||||
4577 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4578 | g_return_if_fail (G_IS_FILE (location))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((location)); GType __t = ((g_file_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__)), "G_IS_FILE (location)"); return; } } while (0); | |||
4579 | ||||
4580 | dir = g_file_get_parent (location); | |||
4581 | g_return_if_fail (dir != NULL)do { if ((dir != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "dir != NULL"); return ; } } while (0); | |||
4582 | ||||
4583 | if (window->priv->default_location != NULL((void*)0)) | |||
4584 | g_object_unref (window->priv->default_location); | |||
4585 | ||||
4586 | window->priv->default_location = dir; | |||
4587 | } | |||
4588 | ||||
4589 | /** | |||
4590 | * lapiz_window_get_unsaved_documents: | |||
4591 | * @window: a #LapizWindow | |||
4592 | * | |||
4593 | * Gets the list of documents that need to be saved before closing the window. | |||
4594 | * | |||
4595 | * Returns: (element-type Lapiz.Document) (transfer container): a list of | |||
4596 | * #LapizDocument that need to be saved before closing the window | |||
4597 | */ | |||
4598 | GList * | |||
4599 | lapiz_window_get_unsaved_documents (LapizWindow *window) | |||
4600 | { | |||
4601 | GList *unsaved_docs = NULL((void*)0); | |||
4602 | GList *tabs; | |||
4603 | GList *l; | |||
4604 | ||||
4605 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4606 | ||||
4607 | tabs = ctk_container_get_children (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ()))))))); | |||
4608 | ||||
4609 | l = tabs; | |||
4610 | while (l != NULL((void*)0)) | |||
4611 | { | |||
4612 | LapizTab *tab; | |||
4613 | ||||
4614 | tab = LAPIZ_TAB (l->data)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((lapiz_tab_get_type())))))); | |||
4615 | ||||
4616 | if (!_lapiz_tab_can_close (tab)) | |||
4617 | { | |||
4618 | LapizDocument *doc; | |||
4619 | ||||
4620 | doc = lapiz_tab_get_document (tab); | |||
4621 | unsaved_docs = g_list_prepend (unsaved_docs, doc); | |||
4622 | } | |||
4623 | ||||
4624 | l = g_list_next (l)((l) ? (((GList *)(l))->next) : ((void*)0)); | |||
4625 | } | |||
4626 | ||||
4627 | g_list_free (tabs); | |||
4628 | ||||
4629 | return g_list_reverse (unsaved_docs); | |||
4630 | } | |||
4631 | ||||
4632 | void | |||
4633 | _lapiz_window_set_saving_session_state (LapizWindow *window, | |||
4634 | gboolean saving_session) | |||
4635 | { | |||
4636 | LapizWindowState old_state; | |||
4637 | ||||
4638 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4639 | ||||
4640 | old_state = window->priv->state; | |||
4641 | ||||
4642 | if (saving_session) | |||
4643 | window->priv->state |= LAPIZ_WINDOW_STATE_SAVING_SESSION; | |||
4644 | else | |||
4645 | window->priv->state &= ~LAPIZ_WINDOW_STATE_SAVING_SESSION; | |||
4646 | ||||
4647 | if (old_state != window->priv->state) | |||
4648 | { | |||
4649 | set_sensitivity_according_to_window_state (window); | |||
4650 | ||||
4651 | g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), "state"); | |||
4652 | } | |||
4653 | } | |||
4654 | ||||
4655 | static void | |||
4656 | hide_notebook_tabs_on_fullscreen (CtkNotebook *notebook, | |||
4657 | GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4658 | LapizWindow *window G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
4659 | { | |||
4660 | ctk_notebook_set_show_tabs (notebook, FALSE(0)); | |||
4661 | } | |||
4662 | ||||
4663 | void | |||
4664 | _lapiz_window_fullscreen (LapizWindow *window) | |||
4665 | { | |||
4666 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4667 | ||||
4668 | if (_lapiz_window_is_fullscreen (window)) | |||
4669 | return; | |||
4670 | ||||
4671 | /* Go to fullscreen mode and hide bars */ | |||
4672 | ctk_window_fullscreen (&window->window); | |||
4673 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), FALSE(0)); | |||
4674 | g_signal_connect (window->priv->notebook, "notify::show-tabs",g_signal_connect_data ((window->priv->notebook), ("notify::show-tabs" ), (((GCallback) (hide_notebook_tabs_on_fullscreen))), (window ), ((void*)0), (GConnectFlags) 0) | |||
4675 | G_CALLBACK (hide_notebook_tabs_on_fullscreen), window)g_signal_connect_data ((window->priv->notebook), ("notify::show-tabs" ), (((GCallback) (hide_notebook_tabs_on_fullscreen))), (window ), ((void*)0), (GConnectFlags) 0); | |||
4676 | ||||
4677 | ctk_widget_hide (window->priv->menubar); | |||
4678 | ||||
4679 | g_signal_handlers_block_by_func (window->priv->toolbar,g_signal_handlers_block_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)) | |||
4680 | toolbar_visibility_changed,g_signal_handlers_block_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)) | |||
4681 | window)g_signal_handlers_block_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)); | |||
4682 | ctk_widget_hide (window->priv->toolbar); | |||
4683 | ||||
4684 | g_signal_handlers_block_by_func (window->priv->statusbar,g_signal_handlers_block_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ) | |||
4685 | statusbar_visibility_changed,g_signal_handlers_block_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ) | |||
4686 | window)g_signal_handlers_block_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ); | |||
4687 | ctk_widget_hide (window->priv->statusbar); | |||
4688 | ||||
4689 | fullscreen_controls_build (window); | |||
4690 | fullscreen_controls_show (window); | |||
4691 | } | |||
4692 | ||||
4693 | void | |||
4694 | _lapiz_window_unfullscreen (LapizWindow *window) | |||
4695 | { | |||
4696 | gboolean visible; | |||
4697 | CtkAction *action; | |||
4698 | ||||
4699 | g_return_if_fail (LAPIZ_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return; } } while (0); | |||
4700 | ||||
4701 | if (!_lapiz_window_is_fullscreen (window)) | |||
4702 | return; | |||
4703 | ||||
4704 | /* Unfullscreen and show bars */ | |||
4705 | ctk_window_unfullscreen (&window->window); | |||
4706 | g_signal_handlers_disconnect_by_func (window->priv->notebook,g_signal_handlers_disconnect_matched ((window->priv->notebook ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (hide_notebook_tabs_on_fullscreen), (window )) | |||
4707 | hide_notebook_tabs_on_fullscreen,g_signal_handlers_disconnect_matched ((window->priv->notebook ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (hide_notebook_tabs_on_fullscreen), (window )) | |||
4708 | window)g_signal_handlers_disconnect_matched ((window->priv->notebook ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (hide_notebook_tabs_on_fullscreen), (window )); | |||
4709 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (window->priv->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_notebook_get_type ( ))))))), TRUE(!(0))); | |||
4710 | ctk_widget_show (window->priv->menubar); | |||
4711 | ||||
4712 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
4713 | "ViewToolbar"); | |||
4714 | visible = ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))); | |||
4715 | if (visible) | |||
4716 | ctk_widget_show (window->priv->toolbar); | |||
4717 | g_signal_handlers_unblock_by_func (window->priv->toolbar,g_signal_handlers_unblock_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)) | |||
4718 | toolbar_visibility_changed,g_signal_handlers_unblock_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)) | |||
4719 | window)g_signal_handlers_unblock_matched ((window->priv->toolbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (toolbar_visibility_changed), (window)); | |||
4720 | ||||
4721 | action = ctk_action_group_get_action (window->priv->always_sensitive_action_group, | |||
4722 | "ViewStatusbar"); | |||
4723 | visible = ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ()))))))); | |||
4724 | if (visible) | |||
4725 | ctk_widget_show (window->priv->statusbar); | |||
4726 | g_signal_handlers_unblock_by_func (window->priv->statusbar,g_signal_handlers_unblock_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ) | |||
4727 | statusbar_visibility_changed,g_signal_handlers_unblock_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ) | |||
4728 | window)g_signal_handlers_unblock_matched ((window->priv->statusbar ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (statusbar_visibility_changed), (window) ); | |||
4729 | ||||
4730 | ctk_widget_hide (window->priv->fullscreen_controls); | |||
4731 | } | |||
4732 | ||||
4733 | gboolean | |||
4734 | _lapiz_window_is_fullscreen (LapizWindow *window) | |||
4735 | { | |||
4736 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return ((0)); } } while (0); | |||
4737 | ||||
4738 | return window->priv->window_state & CDK_WINDOW_STATE_FULLSCREEN; | |||
4739 | } | |||
4740 | ||||
4741 | /** | |||
4742 | * lapiz_window_get_tab_from_location: | |||
4743 | * @window: a #LapizWindow | |||
4744 | * @location: a #GFile | |||
4745 | * | |||
4746 | * Gets the #LapizTab that matches with the given @location. | |||
4747 | * | |||
4748 | * Returns: (transfer none): the #LapizTab that matches with the given @location. | |||
4749 | */ | |||
4750 | LapizTab * | |||
4751 | lapiz_window_get_tab_from_location (LapizWindow *window, | |||
4752 | GFile *location) | |||
4753 | { | |||
4754 | GList *tabs; | |||
4755 | GList *l; | |||
4756 | LapizTab *ret = NULL((void*)0); | |||
4757 | ||||
4758 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4759 | g_return_val_if_fail (G_IS_FILE (location), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((location)); GType __t = ((g_file_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__)), "G_IS_FILE (location)"); return (((void*)0)); } } while (0); | |||
4760 | ||||
4761 | tabs = ctk_container_get_children (CTK_CONTAINER (window->priv->notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->notebook)), ((ctk_container_get_type ()))))))); | |||
4762 | ||||
4763 | for (l = tabs; l != NULL((void*)0); l = g_list_next (l)((l) ? (((GList *)(l))->next) : ((void*)0))) | |||
4764 | { | |||
4765 | LapizDocument *d; | |||
4766 | LapizTab *t; | |||
4767 | GFile *f; | |||
4768 | ||||
4769 | t = LAPIZ_TAB (l->data)((((LapizTab*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((lapiz_tab_get_type())))))); | |||
4770 | d = lapiz_tab_get_document (t); | |||
4771 | ||||
4772 | f = lapiz_document_get_location (d); | |||
4773 | ||||
4774 | if ((f != NULL((void*)0))) | |||
4775 | { | |||
4776 | gboolean found = g_file_equal (location, f); | |||
4777 | ||||
4778 | g_object_unref (f); | |||
4779 | ||||
4780 | if (found) | |||
4781 | { | |||
4782 | ret = t; | |||
4783 | break; | |||
4784 | } | |||
4785 | } | |||
4786 | } | |||
4787 | ||||
4788 | g_list_free (tabs); | |||
4789 | ||||
4790 | return ret; | |||
4791 | } | |||
4792 | ||||
4793 | /** | |||
4794 | * lapiz_window_get_message_bus: | |||
4795 | * @window: a #LapizWindow | |||
4796 | * | |||
4797 | * Gets the #LapizMessageBus associated with @window. The returned reference | |||
4798 | * is owned by the window and should not be unreffed. | |||
4799 | * | |||
4800 | * Return value: (transfer none): the #LapizMessageBus associated with @window | |||
4801 | */ | |||
4802 | LapizMessageBus * | |||
4803 | lapiz_window_get_message_bus (LapizWindow *window) | |||
4804 | { | |||
4805 | g_return_val_if_fail (LAPIZ_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((lapiz_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__)), "LAPIZ_IS_WINDOW (window)"); return (((void*)0 )); } } while (0); | |||
4806 | ||||
4807 | return window->priv->message_bus; | |||
4808 | } |