~cairo-dock-team/ubuntu/quantal/cairo-dock-plug-ins/3.0.2

« back to all changes in this revision

Viewing changes to Clipper/src/applet-init.c

Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "applet-init.h"
27
27
 
28
28
 
29
 
CD_APPLET_DEFINITION ("Clipper",
 
29
CD_APPLET_DEFINITION (N_("Clipper"),
30
30
        1, 6, 3,
31
 
        CAIRO_DOCK_CATEGORY_ACCESSORY,
 
31
        CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY,
32
32
        N_("This applet keeps a trace of the clipboard and mouse selection,\n"
33
33
        "so that you can recall them quickly. It's a clone of the well-know Klipper.\n"
34
34
        "It supports clipboard and mouse selection, predefined actions, and persistent items.\n"
44
44
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
45
45
        }
46
46
        
47
 
        if (myIcon->cFileName == NULL)
48
 
        {
49
 
                CD_APPLET_SET_LOCAL_IMAGE_ON_MY_ICON (MY_APPLET_ICON_FILE);
50
 
        }
 
47
        CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;
51
48
        
52
49
        GtkClipboard *pClipBoard;
53
50
        if (myConfig.iItemType & CD_CLIPPER_CLIPBOARD)
62
59
                myData.iSidPrimaryOwnerChange = g_signal_connect (G_OBJECT (pClipBoard), "owner-change", G_CALLBACK(cd_clipper_selection_owner_changed), NULL);
63
60
        }
64
61
        
65
 
        //_on_text_received (NULL, "http://test.fr", NULL);
66
 
        //_on_text_received (NULL, "http://truc.fr", NULL);
 
62
        if (myConfig.cRememberedItems != NULL)
 
63
        {
 
64
                cd_clipper_load_items (myConfig.cRememberedItems);
 
65
        }
 
66
        
67
67
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
68
68
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
69
69
        CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT;
89
89
                pClipBoard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
90
90
                g_signal_handler_disconnect (pClipBoard, myData.iSidPrimaryOwnerChange);
91
91
        }
 
92
        
 
93
        if (myConfig.bRememberItems)  // on se souvient des items courants.
 
94
        {
 
95
                gchar *cRememberedItems = cd_clipper_concat_items_of_type (CD_CLIPPER_CLIPBOARD, CD_ITEMS_DELIMITER);  // on prend que les CTRL+c.
 
96
                cairo_dock_update_conf_file (CD_APPLET_MY_CONF_FILE,
 
97
                        G_TYPE_STRING, "Configuration", "last items", cRememberedItems,
 
98
                        G_TYPE_INVALID);
 
99
                g_free (cRememberedItems);
 
100
        }
92
101
CD_APPLET_STOP_END
93
102
 
94
103
 
95
104
//\___________ The reload occurs in 2 occasions : when the user changes the applet's config, and when the user reload the cairo-dock's config or modify the desklet's size. The macro CD_APPLET_MY_CONFIG_CHANGED can tell you this. myConfig has already been reloaded at this point if you're in the first case, myData is untouched. You also have the macro CD_APPLET_MY_CONTAINER_TYPE_CHANGED that can tell you if you switched from dock/desklet to desklet/dock mode.
96
105
CD_APPLET_RELOAD_BEGIN
97
 
        if (myDesklet)
98
 
        {
99
 
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
100
 
                gtk_widget_queue_draw (myDesklet->container.pWidget);
101
 
        }
102
 
        
103
106
        //\_______________ On recharge les donnees qui ont pu changer.
104
107
        if (CD_APPLET_MY_CONFIG_CHANGED)
105
108
        {
106
 
                if (myIcon->cFileName == NULL)
 
109
                if (myDesklet && CD_APPLET_MY_CONTAINER_TYPE_CHANGED)  // we are now in a desklet, set a renderer.
107
110
                {
108
 
                        CD_APPLET_SET_LOCAL_IMAGE_ON_MY_ICON (MY_APPLET_ICON_FILE);
 
111
                        CD_APPLET_SET_DESKLET_RENDERER ("Simple");
109
112
                }
110
113
                
 
114
                CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE;
 
115
                
111
116
                g_list_foreach (myData.pActions, (GFunc) cd_clipper_free_action, NULL);
112
117
                g_list_free (myData.pActions);
113
118
                myData.pActions = NULL;
149
154
                                myData.iSidPrimaryOwnerChange = 0;
150
155
                        }
151
156
                }
 
157
                
 
158
                if (myConfig.cRememberedItems != NULL && ! myConfig.bRememberItems)  // on ne veut plus s'en souvenir.
 
159
                {
 
160
                        cairo_dock_update_conf_file (CD_APPLET_MY_CONF_FILE,
 
161
                                G_TYPE_STRING, "Configuration", "last items", "",
 
162
                                G_TYPE_INVALID);
 
163
                        g_free (myConfig.cRememberedItems);
 
164
                        myConfig.cRememberedItems = NULL;
 
165
                }
152
166
        }
153
167
CD_APPLET_RELOAD_END