~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

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

  • Committer: Kees Cook
  • Date: 2011-08-11 23:17:39 UTC
  • mfrom: (20.1.1 cairo-dock-plug-ins)
  • Revision ID: kees@outflux.net-20110811231739-cteedan51tmdg77v
Tags: 2.4.0~0beta2-0ubuntu1
releasing version 2.4.0~0beta2-0ubuntu1

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
 
#include <string.h>
21
 
#include <cairo-dock.h>
22
 
 
23
 
#include "applet-struct.h"
24
 
#include "applet-load-icon.h"
25
 
#include "applet-compiz.h"
26
 
 
27
 
 
28
 
#define MY_NB_ICON_STATE 3
29
 
#define MY_NB_SUB_ICONS 5
30
 
 
31
 
static const gchar *s_iconName[MY_NB_SUB_ICONS] = {N_("Configure Compiz"), N_("Emerald Manager"), N_("Reload WM"), N_("Exposition"), N_("Widget Layer")};
32
 
 
33
 
static const gchar *s_iconClass[MY_NB_SUB_ICONS] = {"ccsm", "emerald-theme-manager", NULL, NULL, NULL};
34
 
 
35
 
static const gchar *s_iconFile[MY_NB_ICON_STATE] = {"default.svg", "broken.svg", "other.svg"};
36
 
 
37
 
 
38
 
static GList * _list_icons (void) {
39
 
        GList *pIconList = NULL;
40
 
        
41
 
        Icon *pIcon;
42
 
        int i, j=3;
43
 
        if (myConfig.bScriptSubDock)
44
 
                j = 5;
45
 
  
46
 
        for (i = 0; i < j; i ++)
47
 
        {
48
 
                if (i == 1 && ! myConfig.bEmeraldIcon)
49
 
                        continue;
50
 
                pIcon = cairo_dock_create_dummy_launcher (g_strdup (D_(s_iconName[i])),
51
 
                        (myConfig.cUserImage[i+MY_NB_ICON_STATE] != NULL ?
52
 
                                cairo_dock_generate_file_path (myConfig.cUserImage[i+MY_NB_ICON_STATE]) :
53
 
                                g_strdup_printf ("%s/%d.svg", MY_APPLET_SHARE_DATA_DIR, i)),
54
 
                        (s_iconClass[i] != NULL ? g_strdup (s_iconClass[i]) : g_strdup ("none")),
55
 
                        NULL,
56
 
                        2*i);
57
 
                pIcon->cParentDockName = g_strdup (myIcon->cName);
58
 
                pIconList = g_list_append (pIconList, pIcon);
59
 
                if (myConfig.bStealTaskBarIcon && s_iconClass[i] != NULL)
60
 
                {
61
 
                        cairo_dock_inhibite_class (s_iconClass[i], pIcon);
62
 
                }
63
 
        }
64
 
        
65
 
        return pIconList;
66
 
}
67
 
 
68
 
void cd_compiz_update_main_icon (void) {
69
 
        gboolean bNeedsRedraw = FALSE;
70
 
        if (myData.bAcquisitionOK) {
71
 
                if (myData.bCompizIsRunning && myData.iCompizIcon != COMPIZ_DEFAULT) {
72
 
//                      //cd_debug ("COMPIZ_DEFAULT");
73
 
                        myData.iCompizIcon = COMPIZ_DEFAULT;
74
 
                        CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_DEFAULT], "default.svg");
75
 
                        bNeedsRedraw = TRUE;
76
 
                }
77
 
                else if (! myData.bCompizIsRunning && myData.iCompizIcon != COMPIZ_OTHER) {
78
 
                        //cd_debug ("COMPIZ_OTHER");
79
 
                        myData.iCompizIcon = COMPIZ_OTHER;
80
 
                        CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_OTHER], "other.svg");
81
 
                        bNeedsRedraw = TRUE;
82
 
                }
83
 
        }
84
 
        else {
85
 
                if (myData.iCompizIcon != COMPIZ_BROKEN) {
86
 
                        //cd_debug ("COMPIZ_BROKEN");
87
 
                        myData.iCompizIcon = COMPIZ_BROKEN;
88
 
                        CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cUserImage[COMPIZ_BROKEN], "broken.svg");
89
 
                        bNeedsRedraw = TRUE;
90
 
                }
91
 
        }
92
 
        if (bNeedsRedraw)
93
 
                CD_APPLET_REDRAW_MY_ICON;
94
 
}
95
 
 
96
 
 
97
 
void cd_compiz_build_icons (void) {
98
 
        if (myIcon->cName == NULL && myDock)
99
 
        {
100
 
                CD_APPLET_SET_NAME_FOR_MY_ICON (COMPIZ_DEFAULT_NAME);
101
 
        }
102
 
        GList *pIconList = _list_icons ();  // ne nous appartiendra plus, donc ne pas desallouer.
103
 
        
104
 
        gpointer pConfig[2] = {GINT_TO_POINTER (FALSE), GINT_TO_POINTER (FALSE)};
105
 
        CD_APPLET_LOAD_MY_ICONS_LIST (pIconList, myConfig.cRenderer, "Caroussel", pConfig);
106
 
}