2
* * Copyright (C) 2008-2009 Ali <aliov@xfce.org>
4
* Licensed under the GNU General Public License Version 2
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* 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, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include <libxfce4util/libxfce4util.h>
25
#include "xfpm-common.h"
27
const gchar *xfpm_bool_to_string (gboolean value)
29
if ( value == TRUE ) return "TRUE";
33
gboolean xfpm_string_to_bool (const gchar *string)
35
if ( !g_strcmp0 (string, "TRUE") ) return TRUE;
36
else if ( !g_strcmp0 (string, "FALSE") ) return FALSE;
41
GtkBuilder *xfpm_builder_new_from_string (const gchar *ui, GError **error)
45
builder = gtk_builder_new ();
47
gtk_builder_add_from_string (GTK_BUILDER (builder),
56
xfpm_link_browser (GtkAboutDialog *about, const gchar *link, gpointer data)
60
cmd = g_strdup_printf ("%s %s","xdg-open", link);
62
if ( !g_spawn_command_line_async (cmd, NULL) )
65
cmd = g_strdup_printf ("%s %s","xfbrowser4", link);
66
g_spawn_command_line_async (cmd, NULL);
73
xfpm_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data)
75
gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link);
77
g_spawn_command_line_async (cmd, NULL);
83
xfpm_lock_screen (void)
85
gboolean ret = g_spawn_command_line_async ("xflock4", NULL);
89
g_spawn_command_line_async ("gnome-screensaver-command -l", NULL);
94
/* this should be the default*/
95
ret = g_spawn_command_line_async ("xdg-screensaver lock", NULL);
100
ret = g_spawn_command_line_async ("xscreensaver-command -lock", NULL);
105
g_critical ("Connot lock screen\n");
110
xfpm_preferences (void)
112
g_spawn_command_line_async ("xfce4-power-manager-settings", NULL);
118
g_spawn_command_line_async ("xfhelp4 xfce4-power-manager.html", NULL);
124
g_spawn_command_line_async ("xfce4-power-manager -q", NULL);
128
xfpm_about (GtkWidget *widget, gpointer data)
130
gchar *package = (gchar *)data;
132
const gchar* authors[3] =
134
"Ali Abdallah <aliov@xfce.org>",
138
static const gchar *documenters[] =
140
"Ali Abdallah <aliov@xfce.org>",
145
gtk_about_dialog_set_url_hook (xfpm_link_browser, NULL, NULL);
146
gtk_about_dialog_set_email_hook (xfpm_link_mailto, NULL, NULL);
148
gtk_show_about_dialog (NULL,
150
"copyright", "Copyright \302\251 2008-2009 Ali Abdallah",
151
"destroy-with-parent", TRUE,
152
"documenters", documenters,
153
"license", XFCE_LICENSE_GPL,
155
"translator-credits", _("translator-credits"),
156
"version", PACKAGE_VERSION,
157
"website", "http://goodies.xfce.org",
162
gboolean xfpm_is_multihead_connected (void)
169
dpy = gdk_display_get_default ();
171
nscreen = gdk_display_get_n_screens (dpy);
175
screen = gdk_display_get_screen (dpy, 0);
178
nmonitor = gdk_screen_get_n_monitors (screen);
181
g_debug ("Multiple monitor connected");
188
else if ( nscreen > 1 )
190
g_debug ("Multiple screen connected");
197
GdkPixbuf *xfpm_icon_load (const gchar *icon_name, gint size)
199
GdkPixbuf *pix = NULL;
200
GError *error = NULL;
202
pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
205
GTK_ICON_LOOKUP_USE_BUILTIN,
210
g_warning ("Unable to load icon : %s : %s", icon_name, error->message);
211
g_error_free (error);