Debian Codegraph @

systray/src/systray-init.c

raw symbols SCIP
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2 /*
3 ** Login : <[email protected]>
4 ** Started on Fri Nov 30 05:31:31 2007 GESTES Cedric
5 ** $Id$
6 **
7 ** Copyright (C) 2007 GESTES Cedric
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 3 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include <stdlib.h>
24
25 #include "systray-config.h"
26 #include "systray-interface.h"
27 #include "systray-notifications.h"
28 #include "systray-struct.h"
29 #include "systray-init.h"
30
31
32 CD_APPLET_DEFINE_BEGIN ("systray",
33 2, 2, 0,
34 CAIRO_DOCK_CATEGORY_APPLET_DESKTOP,
35 N_("Add a systray to your dock.\n"
36 "Left-click to show/hide the systray in a dialog (you can bind a keyboard shortcut for it.)\n"
37 "But the best way to use it is to detach it from the dock, and place it somewhere, above other windows."),
38 "Ctaf (Cedric Gestes)")
39 CD_APPLET_DEFINE_COMMON_APPLET_INTERFACE
40 CD_APPLET_SET_UNRESIZABLE_DESKLET
41 CD_APPLET_REDEFINE_TITLE (N_("Notification Area Old"))
42 CD_APPLET_DEFINE_END
43
44
45 CD_APPLET_INIT_BEGIN
46
47 CD_APPLET_REGISTER_FOR_CLICK_EVENT;
48 CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
49 // CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
50
51 cd_systray_check_running (); // petit message si l'utilisateur active le systray alors qu'un autre systray existe.
52
53 cd_systray_build_systray (); // on construit le systray immediatement pour les applis qui ne peuvent exister sans.
54
55 if (myDesklet) // le desklet ne tourne pas.
56 {
57 CD_APPLET_SET_STATIC_DESKLET;
58 }
59 else // en mode desklet on n'a pas besoin de l'icone.
60 {
61 CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;
62 }
63
64 myData.cKeyBinding = CD_APPLET_BIND_KEY (myConfig.shortcut,
65 D_("Show/hide the systray"),
66 "Configuration", "shortkey",
67 (CDBindkeyHandler) systray_on_keybinding_pull);
68 CD_APPLET_INIT_END
69
70
71 CD_APPLET_STOP_BEGIN
72
73 CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
74 CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
75 // CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
76
77 gldi_object_unref (GLDI_OBJECT(myData.cKeyBinding));
78
79 CD_APPLET_STOP_END
80
81
82 CD_APPLET_RELOAD_BEGIN
83
84 if (CD_APPLET_MY_CONFIG_CHANGED)
85 {
86 if (! myData.tray) // ne devrait pas arriver.
87 {
88 cd_systray_build_systray ();
89 }
90 else
91 {
92 // changement de l'orientation.
93 cd_systray_set_orientation (myConfig.iIconPacking == 0 ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
94
95 // changement de container.
96 if (CD_APPLET_MY_CONTAINER_TYPE_CHANGED)
97 {
98 if (myDesklet != NULL) // il faut passer du dialogue au desklet.
99 {
100 gldi_dialog_steal_interactive_widget (myData.dialog);
101 gldi_object_unref (GLDI_OBJECT(myData.dialog));
102 myData.dialog = NULL;
103 gldi_desklet_add_interactive_widget (myDesklet, GTK_WIDGET (myData.tray));
104 CD_APPLET_SET_DESKLET_RENDERER (NULL); // pour empecher le clignotement du au double-buffer.
105 CD_APPLET_SET_STATIC_DESKLET;
106 }
107 else // il faut passer du desklet au dialogue
108 {
109 CairoDesklet *pDesklet = CAIRO_DESKLET (CD_APPLET_MY_OLD_CONTAINER);
110 gldi_desklet_steal_interactive_widget (pDesklet);
111 cd_systray_build_dialog ();
112 }
113 g_object_unref (G_OBJECT (myData.tray)); // le 'steal' a ajoute une reference, et l'insertion dans le container aussi.
114 }
115
116 if (myDock)
117 CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE; // set the default icon if none is specified in conf.
118 }
119
120 gldi_shortkey_rebind (myData.cKeyBinding, myConfig.shortcut, NULL);
121 }
122
123 if (myDesklet) // on cloue le desklet.
124 {
125 GdkGravity iGravity;
126 if (myContainer->iWindowPositionX < g_desktopGeometry.Xscreen.width/2) // we don't know if the container is set on a given screen or not, so take the X screen.
127 iGravity = GDK_GRAVITY_NORTH_WEST;
128 else
129 iGravity = GDK_GRAVITY_NORTH_EAST;
130 gtk_window_set_gravity (GTK_WINDOW (myContainer->pWidget), iGravity);
131 }
132
133 CD_APPLET_RELOAD_END