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

« back to all changes in this revision

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

  • Committer: Matthieu Baerts
  • Date: 2012-08-27 13:52:53 UTC
  • mfrom: (1.1.24)
  • Revision ID: matttbe@gmail.com-20120827135253-hddj9plv24wc90sa
Tags: 3.0.99.beta1.1~20120827~bzr2515-0ubuntu1
* New upstream snapshot.
* Upstream ChangeLog (detailed changes):
 - Recent-Events: Dialog: no longer added removed files
    + Dialog: Applications: Used the translated name
    + Recent files: added deleted files to the hashtable to prevent
       useless g_file_test
 - ShowDesktop: fixed a typo (about the coloration in the code)
    + checked if Xrandr extension is available before using it
       (LP: #1040271)
 - CMakeLists.txt: linked each plugin to all libs used by gldi except
    gldi (and not only to a few modules)
 - Dbus: cairo-dock-unity-bridge crashed with TypeError in
    on_name_owner_changed(): cannot concatenate 'str' and 'NoneType'
    objects (LP: #1041558)
 - CMakeLists.txt: Checked gio-2.0 for 'gvfs-integration' even if GMenu
    is not compiled
    + Linked gvfs-integration static library to gio-2.0
 - GMenu: fixed a bug that could provoke a crash if the applet is
    deactivating
    + Used gio to launch the menu entries, so that the event is stored
     in Zeitgeist
 - Dbus: the binary was not linked to libdbusmenu
    + checked if we have dbusmenu and dbusmenu-gtk before adding DBusMenu
     support
 - DBus: cairo-dock-unity-bridge: excluded the current process when
    looking if the script has not already been launched
    + converted grep commands to python commands to not launch 4 processes
     just for that
    + Added 'Unity-Bridge' before all 'print'
    + ps command: print only pid + cmd
* debian/control:
 - Bump Cairo-Dock versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <stdlib.h>
21
21
#include <string.h>
22
22
#include <glib/gi18n.h>
23
 
#include<X11/Xlib.h>
 
23
#include <X11/Xlib.h>
24
24
#ifdef HAVE_XRANDR
25
 
#include<X11/extensions/Xrandr.h>
 
25
#include <X11/extensions/Xrandr.h>
26
26
#endif
27
27
#include <gdk/gdkx.h>
28
28
 
198
198
        
199
199
        // Main Menu
200
200
        #ifdef HAVE_XRANDR
201
 
        GtkWidget *pResSubMenu = CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_("Change screen resolution"), CD_APPLET_MY_MENU, GTK_STOCK_FULLSCREEN);
202
 
        
203
 
        Display                 *dpy;
204
 
        Window                  root;
205
 
        int                     num_sizes;
206
 
        XRRScreenSize           *xrrs;
207
 
        XRRScreenConfiguration  *conf;
208
 
        short                   original_rate;
209
 
        Rotation                original_rotation;
210
 
        SizeID                  original_size_id;
211
 
        
212
 
        dpy = gdk_x11_get_default_xdisplay ();
213
 
        root = RootWindow(dpy, 0);
214
 
        
215
 
        conf = XRRGetScreenInfo(dpy, root);  // config  courante.
216
 
        if (conf != NULL)
 
201
        if (cairo_dock_xrandr_is_available ())
217
202
        {
218
 
                original_rate = XRRConfigCurrentRate(conf);
219
 
                original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation);
220
 
                
221
 
                // resolutions possibles.
222
 
                int num_sizes = 0;
223
 
                XRRScreenSize *xrrs = XRRSizes(dpy, 0, &num_sizes);
224
 
                // add to the menu
225
 
                GString *pResString = g_string_new ("");
226
 
                int i;
227
 
                for (i = 0; i < num_sizes; i ++)
 
203
                GtkWidget *pResSubMenu = CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_("Change screen resolution"), CD_APPLET_MY_MENU, GTK_STOCK_FULLSCREEN);
 
204
                
 
205
                Display                 *dpy;
 
206
                Window                  root;
 
207
                int                     num_sizes;
 
208
                XRRScreenSize           *xrrs;
 
209
                XRRScreenConfiguration  *conf;
 
210
                short                   original_rate;
 
211
                Rotation                original_rotation;
 
212
                SizeID                  original_size_id;
 
213
                
 
214
                dpy = gdk_x11_get_default_xdisplay ();
 
215
                root = RootWindow(dpy, 0);
 
216
                
 
217
                conf = XRRGetScreenInfo(dpy, root);  // config  courante.
 
218
                if (conf != NULL)
228
219
                {
229
 
                        g_string_printf (pResString, "%dx%d", xrrs[i].width, xrrs[i].height);
230
 
                        if (i == original_size_id)
231
 
                                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (pResString->str, GTK_STOCK_APPLY, _on_select_resolution, pResSubMenu, GINT_TO_POINTER (i));
232
 
                        else
233
 
                                CD_APPLET_ADD_IN_MENU_WITH_DATA (pResString->str, _on_select_resolution, pResSubMenu, GINT_TO_POINTER (i));
234
 
                        /*short   *rates;
235
 
                        int     num_rates;
236
 
                        rates = XRRRates(dpy, 0, i, &num_rates);
237
 
                        for(int j = 0; j < num_rates; j ++) {
238
 
                                possible_frequencies[i][j] = rates[j];
239
 
                                printf("%4i ", rates[j]); }*/
 
220
                        original_rate = XRRConfigCurrentRate(conf);
 
221
                        original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation);
 
222
                        
 
223
                        // resolutions possibles.
 
224
                        int num_sizes = 0;
 
225
                        XRRScreenSize *xrrs = XRRSizes(dpy, 0, &num_sizes);
 
226
                        // add to the menu
 
227
                        GString *pResString = g_string_new ("");
 
228
                        int i;
 
229
                        for (i = 0; i < num_sizes; i ++)
 
230
                        {
 
231
                                g_string_printf (pResString, "%dx%d", xrrs[i].width, xrrs[i].height);
 
232
                                if (i == original_size_id)
 
233
                                        CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (pResString->str, GTK_STOCK_APPLY, _on_select_resolution, pResSubMenu, GINT_TO_POINTER (i));
 
234
                                else
 
235
                                        CD_APPLET_ADD_IN_MENU_WITH_DATA (pResString->str, _on_select_resolution, pResSubMenu, GINT_TO_POINTER (i));
 
236
                                /*short   *rates;
 
237
                                int     num_rates;
 
238
                                rates = XRRRates(dpy, 0, i, &num_rates);
 
239
                                for(int j = 0; j < num_rates; j ++) {
 
240
                                        possible_frequencies[i][j] = rates[j];
 
241
                                        printf("%4i ", rates[j]); }*/
 
242
                        }
 
243
                        g_string_free (pResString, TRUE);
 
244
                        XRRFreeScreenConfigInfo (conf);
240
245
                }
241
 
                g_string_free (pResString, TRUE);
242
 
                XRRFreeScreenConfigInfo (conf);
243
246
        }
 
247
        else
 
248
                cd_warning ("Xrandr extension not available.");
244
249
        #endif
245
250
CD_APPLET_ON_BUILD_MENU_END
246
251