~cairo-dock-team/ubuntu/oneiric/cairo-dock-plug-ins/2.3.0-2.1

« back to all changes in this revision

Viewing changes to stack/src/applet-notifications.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        }
54
54
        else if (CD_APPLET_CLICKED_ICON != NULL)
55
55
        {
 
56
                cd_debug ("_launch_item");
56
57
                _launch_item (CD_APPLET_CLICKED_ICON, myApplet);  // on intercepte la notification.
57
58
        }
58
59
        else
175
176
        {
176
177
                // Main Menu
177
178
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open (click)"), GTK_STOCK_EXECUTE, _cd_stack_open_item, CD_APPLET_MY_MENU, data);
178
 
                if (CD_APPLET_CLICKED_ICON->iVolumeID == 1)
 
179
                gchar *cContent = CD_APPLET_CLICKED_ICON->cCommand;
 
180
                if (strncmp (cContent, "file://", 7) == 0)
179
181
                        CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open parent folder"), GTK_STOCK_OPEN, _cd_stack_open_item_folder, CD_APPLET_MY_MENU, data);
180
182
                CD_APPLET_ADD_SEPARATOR_IN_MENU (CD_APPLET_MY_MENU);
181
 
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Copy (middle click)"), GTK_STOCK_COPY, _cd_stack_copy_content, CD_APPLET_MY_MENU, data);
 
183
                gchar *cLabel = g_strdup_printf ("%s (%s)", D_("Copy"), D_("middle-click"));
 
184
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (cLabel, GTK_STOCK_COPY, _cd_stack_copy_content, CD_APPLET_MY_MENU, data);
 
185
                g_free (cLabel);
182
186
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Cut"), GTK_STOCK_CUT, _cd_stack_cut_item, CD_APPLET_MY_MENU, data);
183
187
                
184
188
                CD_APPLET_ADD_SEPARATOR_IN_MENU (CD_APPLET_MY_MENU);
204
208
                _cd_stack_copy_content (NULL, data);
205
209
        }
206
210
CD_APPLET_ON_MIDDLE_CLICK_END
 
211
 
 
212
 
 
213
gboolean cd_stack_on_drop_data (gpointer data, const gchar *cReceivedData, Icon *icon, double fOrder, CairoContainer *pContainer)
 
214
{
 
215
        //g_print ("Stack received '%s'\n", cReceivedData);
 
216
        
 
217
        // if we dropped on an icon, let pass the notif to it.
 
218
        if (fOrder == CAIRO_DOCK_LAST_ORDER)  // drop on an icon.
 
219
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
220
        
 
221
        // if it's a .desktop, let pass to the core (it will create the associated launcher).
 
222
        if (g_str_has_suffix (cReceivedData, ".desktop"))
 
223
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
224
        
 
225
        // if it's not a file or an URL, let pass it.
 
226
        gchar *cPath = NULL;
 
227
        if (strncmp (cReceivedData, "file://", 7) == 0)  // it's a file.
 
228
        {
 
229
                cPath = g_filename_from_uri (cReceivedData, NULL, NULL);
 
230
                if (!g_file_test (cPath, G_FILE_TEST_EXISTS)
 
231
                || g_file_test (cPath, G_FILE_TEST_IS_DIR))  // if the path doesn't exist, or is a folder, skip it (folders are handled by the 'Folders' applet).
 
232
                {
 
233
                        g_free (cPath);
 
234
                        return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
235
                }
 
236
        }
 
237
        else if (strncmp (cReceivedData, "http://", 7) != 0
 
238
        && strncmp (cReceivedData, "https://", 8) != 0)  // it's neither a file nor an URL.
 
239
        {
 
240
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
241
        }
 
242
        
 
243
        // grab the first instance of the Stack applet (launch it if necessary)
 
244
        CairoDockModule *pModule = cairo_dock_find_module_from_name ("stack");
 
245
        g_return_val_if_fail (pModule != NULL, CAIRO_DOCK_LET_PASS_NOTIFICATION);
 
246
        
 
247
        if (pModule->pInstancesList == NULL)  // no stack yet
 
248
        {
 
249
                cairo_dock_activate_module_and_load ("stack");
 
250
                g_return_val_if_fail (pModule->pInstancesList != NULL, CAIRO_DOCK_LET_PASS_NOTIFICATION);
 
251
        }
 
252
        
 
253
        // add the item to the instance.
 
254
        CairoDockModuleInstance *myApplet = pModule->pInstancesList->data;
 
255
        cd_stack_create_and_load_item (myApplet, cReceivedData);
 
256
        
 
257
        cairo_dock_show_temporary_dialog_with_icon (
 
258
                cPath != NULL ?
 
259
                D_("The file has been added to the stack."):
 
260
                D_("The URL has been added to the stack."),
 
261
                myIcon, myContainer,
 
262
                5000,
 
263
                "same icon");
 
264
        
 
265
        g_free (cPath);
 
266
        return CAIRO_DOCK_INTERCEPT_NOTIFICATION;
 
267
}