Debian Codegraph @

terminal/src/terminal-init.c

raw
1 /*
2 ** Login : <[email protected]>
3 ** Started on Fri Nov 30 05:31:31 2007 GESTES Cedric
4 ** $Id$
5 **
6 ** Copyright (C) 2007 GESTES Cedric
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 3 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 #include "stdlib.h"
23
24 #include "terminal-config.h"
25 #include "terminal-menu-functions.h"
26 #include "terminal-struct.h"
27 #include "terminal-widget.h"
28 #include "terminal-init.h"
29
30
31 CD_APPLET_DEFINITION (N_("terminal"),
32 2, 0, 7,
33 CAIRO_DOCK_CATEGORY_APPLET_SYSTEM,
34 N_("Add a terminal to your dock!\n"
35 "Left-click to show/hide terminal (you can bind a keyboard shortcut for it).\n"
36 "You can drag'n'drop files or text and select an action.\n"
37 "You can open many tabs, rename them, change their color (right-click on a tab to interact on it).\n"
38 "To open a new tab: type 'Ctrl+T' or double-click next to the last tab.\n"
39 "To close a tab: type 'Ctrl+W' or middle-click on it.\n"
40 "To copy/paste: type 'Ctrl+Shift+C/V' or right-click on it."),
41 "Ctaf (Cedric Gestes) &amp; Fabounet (Fabrice Rey)")
42
43
44 CD_APPLET_INIT_BEGIN
45 CD_APPLET_REGISTER_FOR_CLICK_EVENT;
46 CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
47 CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
48
49 if (myDesklet) // on cree le terminal pour avoir qqch a afficher dans le desklet.
50 {
51 terminal_build_and_show_tab ();
52 CD_APPLET_SET_STATIC_DESKLET;
53 }
54 else // en mode desklet, on n'a pas besoin de l'icone.
55 {
56 CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE; // set the default icon if none is specified in conf.
57 }
58
59 myData.cKeyBinding = CD_APPLET_BIND_KEY (myConfig.shortcut,
60 D_("Show/hide the terminal"),
61 "Configuration", "shortkey",
62 (CDBindkeyHandler) term_on_keybinding_pull);
63 if (! gldi_shortkey_could_grab (myData.cKeyBinding)) // si le bind n'a pas eu lieu, on s'en souvient. En effet, on a besoin de savoir si on pourra rappeler le desklet lors d'un 'exit' dans le dernier onglet pour cacher ou non le desklet.
64 {
65 g_free (myConfig.shortcut);
66 myConfig.shortcut = NULL;
67 }
68 CD_APPLET_INIT_END
69
70
71 CD_APPLET_STOP_BEGIN
72 CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
73 CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
74 CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
75
76 gldi_object_unref (GLDI_OBJECT(myData.cKeyBinding));
77 CD_APPLET_STOP_END
78
79
80 CD_APPLET_RELOAD_BEGIN
81 if (CD_APPLET_MY_CONFIG_CHANGED)
82 {
83 if (! myData.tab)
84 {
85 if (myDesklet) // on cree le terminal pour avoir qqch a afficher dans le desklet.
86 terminal_build_and_show_tab ();
87 }
88 else if (CD_APPLET_MY_CONTAINER_TYPE_CHANGED)
89 {
90 if (myDesklet) // il faut passer du dialogue au desklet.
91 {
92 // on retire le terminal du dialogue.
93 myData.tab = gldi_dialog_steal_interactive_widget (myData.dialog);
94 gldi_object_unref (GLDI_OBJECT(myData.dialog));
95 myData.dialog = NULL;
96
97 // on l'insere dans le desklet.
98 gldi_desklet_add_interactive_widget (myDesklet, myData.tab);
99 g_object_unref (myData.tab); // le 'steal' a rajoute une reference.
100 CD_APPLET_SET_DESKLET_RENDERER (NULL); // pour empecher le clignotement du au double-buffer.
101 CD_APPLET_SET_STATIC_DESKLET;
102 }
103 else // il faut passer du desklet au dialogue
104 {
105 // on retire le terminal du desklet.
106 myData.tab = gldi_desklet_steal_interactive_widget (CAIRO_DESKLET (CD_APPLET_MY_OLD_CONTAINER));
107 myData.dialog = cd_terminal_build_dialog ();
108 g_object_unref (myData.tab); // le 'steal' a rajoute une reference.
109 gldi_dialog_hide (myData.dialog);
110 }
111 }
112
113 if (myData.tab)
114 {
115 term_apply_settings();
116 }
117
118 if (myDock) // en mode desklet, on n'a pas besoin de l'icone.
119 {
120 CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE; // set the default icon if none is specified in conf.
121 }
122
123 gldi_shortkey_rebind (myData.cKeyBinding, myConfig.shortcut, NULL);
124 }
125 CD_APPLET_RELOAD_END