Debian Codegraph @

systray/src/systray-interface.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 #include <string.h>
25 #include <signal.h>
26
27 #include "systray-interface.h"
28 #include "systray-init.h"
29 #include "systray-struct.h"
30 #include "na-tray.h"
31 #include "na-tray-manager.h"
32
33
34 void cd_systray_build_dialog (void)
35 {
36 CairoDialogAttr attr;
37 memset (&attr, 0, sizeof (CairoDialogAttr));
38 attr.pInteractiveWidget = GTK_WIDGET (myData.tray);
39 attr.bHideOnClick = TRUE; // keep the dialog alive on click (hide it).
40 attr.pIcon = myIcon;
41 attr.pContainer = myContainer;
42 myData.dialog = gldi_dialog_new (&attr);
43 gtk_window_set_resizable (GTK_WINDOW(myData.dialog->container.pWidget), FALSE); /// utile ?...
44 gldi_dialog_hide (myData.dialog);
45 }
46
47 void cd_systray_build_systray (void)
48 {
49 if (myData.tray != NULL)
50 return;
51
52 myData.tray = na_tray_new_for_screen (gtk_widget_get_screen (GTK_WIDGET (myContainer->pWidget)),
53 myConfig.iIconPacking == 0 ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
54 na_tray_set_icon_size (myData.tray, 24);
55 na_tray_set_padding (myData.tray, 3);
56
57 if (myDock)
58 {
59 cd_systray_build_dialog ();
60 }
61 else
62 {
63 gldi_desklet_add_interactive_widget (myDesklet, GTK_WIDGET (myData.tray));
64 CD_APPLET_SET_DESKLET_RENDERER (NULL);
65 }
66 gtk_widget_show (GTK_WIDGET (myData.tray));
67 }
68
69
70 void cd_systray_check_running (void)
71 {
72 if (na_tray_manager_check_running (gtk_widget_get_screen (GTK_WIDGET (myContainer->pWidget))) && ! cairo_dock_is_loading ())
73 {
74 gldi_dialog_show_temporary_with_icon (D_("Another systray is already running (probably on your panel)\nSince there can only be one systray at once, you should remove it to avoid any conflict."), myIcon, myContainer, 8000, NULL);
75 }
76 }
77
78
79 void systray_on_keybinding_pull (const char *keystring, gpointer user_data)
80 {
81 if (myData.tray)
82 {
83 if (myDesklet)
84 gldi_desklet_show(myDesklet);
85 else if (myData.dialog)
86 gldi_dialog_unhide (myData.dialog);
87 }
88 }
89
90
91 void cd_systray_set_orientation (GtkOrientation o)
92 {
93 GtkOrientation o_ = na_tray_get_orientation (myData.tray);
94 if (o != o_)
95 {
96 na_tray_set_orientation (myData.tray, o);
97 }
98 }