~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to compiz-icon/src/applet-init.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
Import upstream version 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (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
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
/******************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Rémy Robertson (for any bug report, please mail me to changfu@cairo-dock.org)
 
26
Fabrice Rey <fabounet@users.berlios.de>
 
27
 
 
28
******************************************************************************/
 
29
 
 
30
#include "stdlib.h"
 
31
 
 
32
#include "applet-config.h"
 
33
#include "applet-notifications.h"
 
34
#include "applet-struct.h"
 
35
#include "applet-init.h"
 
36
#include "applet-load-icon.h"
 
37
#include "applet-compiz.h"
 
38
 
 
39
#define CD_COMPIZ_CHECK_TIME 4
 
40
 
 
41
CD_APPLET_DEFINITION ("compiz-icon",
 
42
        1, 6, 2,
 
43
        CAIRO_DOCK_CATEGORY_DESKTOP,
 
44
        N_("This applet allows you to manage compiz and other windows manager\n"
 
45
        "The sub-dock gives you to acces to CCSM, Emerald and some basic Compiz actions.\n"
 
46
        "You can bind one of these actions with the middle-click.\n"
 
47
        "The configuration panel gives you some options to launch Compiz."),
 
48
        "ChAnGFu (Rémy Robertson) (thanks to Coz for his icons)")
 
49
 
 
50
 
 
51
CD_APPLET_INIT_BEGIN
 
52
        cd_compiz_build_icons ();
 
53
        
 
54
        if (myConfig.bAutoReloadDecorator || myConfig.bAutoReloadCompiz) {
 
55
                myData.bDecoratorRestarted = FALSE;
 
56
                myData.iCompizIcon = -1;  // force le dessin.
 
57
                if (! myConfig.forceConfig) // on fait comme si c'est nous qui l'avons mis dans l'etat actuel.
 
58
                        myData.bCompizRestarted = TRUE;
 
59
                
 
60
                myData.pTask = cairo_dock_new_task (CD_COMPIZ_CHECK_TIME,
 
61
                        (CairoDockGetDataAsyncFunc) cd_compiz_read_data,
 
62
                        (CairoDockUpdateSyncFunc) cd_compiz_update_from_data,
 
63
                        myApplet);
 
64
                cairo_dock_launch_task (myData.pTask);
 
65
        }
 
66
        else {
 
67
                CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_DEFAULT], "default.svg");
 
68
        }
 
69
        
 
70
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
 
71
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
 
72
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
 
73
CD_APPLET_INIT_END
 
74
 
 
75
 
 
76
CD_APPLET_STOP_BEGIN
 
77
        
 
78
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
 
79
        CD_APPLET_UNREGISTER_FOR_MIDDLE_CLICK_EVENT;
 
80
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
 
81
CD_APPLET_STOP_END
 
82
 
 
83
 
 
84
CD_APPLET_RELOAD_BEGIN
 
85
        //\_______________ On recharge les donnees qui ont pu changer.
 
86
        if (CD_APPLET_MY_CONFIG_CHANGED) {
 
87
                
 
88
                //\________________ les icones ont pu changer, ainsi que l'inhibition.
 
89
                if (myIcon->pSubDock != NULL) {
 
90
                        cairo_dock_destroy_dock (myIcon->pSubDock, myIcon->acName, NULL, NULL);
 
91
                        myIcon->pSubDock = NULL;
 
92
                }
 
93
                if (myDesklet && myDesklet->icons != NULL) {
 
94
                        g_list_foreach (myDesklet->icons, (GFunc) cairo_dock_free_icon, NULL);
 
95
                        g_list_free (myDesklet->icons);
 
96
                        myDesklet->icons = NULL;
 
97
                }
 
98
                
 
99
                if (cairo_dock_task_is_active (myData.pTask) && ! myConfig.bAutoReloadDecorator && ! myConfig.bAutoReloadCompiz) {
 
100
                        cairo_dock_stop_task (myData.pTask);
 
101
                        CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_DEFAULT], "default.svg");
 
102
                }
 
103
                else if (! cairo_dock_task_is_active (myData.pTask) && (myConfig.bAutoReloadDecorator || myConfig.bAutoReloadCompiz)) {
 
104
                        myData.iCompizIcon = -1;
 
105
                        myData.bDecoratorRestarted = FALSE;
 
106
                        if (! myConfig.forceConfig) // on fait comme si c'est nous qui l'avons mis dans l'etat actuel.
 
107
                                myData.bCompizRestarted = TRUE;
 
108
                        
 
109
                        cairo_dock_launch_task (myData.pTask);
 
110
                }
 
111
                else {
 
112
                        if (cairo_dock_task_is_active (myData.pTask))
 
113
                                myData.iCompizIcon = -1;
 
114
                        else {
 
115
                                CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_DEFAULT], "default.svg");
 
116
                        }
 
117
                }
 
118
                cd_compiz_build_icons ();
 
119
                
 
120
        }
 
121
        else if (myDesklet != NULL) {
 
122
                gpointer pConfig[2] = {GINT_TO_POINTER (FALSE), GINT_TO_POINTER (FALSE)};
 
123
                CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA ("Caroussel", pConfig);
 
124
        }
 
125
        else {
 
126
                //Rien a faire
 
127
        }
 
128
CD_APPLET_RELOAD_END