summaryrefslogtreecommitdiff
path: root/capplets
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-12-08 04:01:38 -0300
committerPerberos <[email protected]>2011-12-08 04:01:38 -0300
commit8e68aa4f36fd333cb4f3c65efd7b0525a793299e (patch)
tree98c5d74fabbd6035f29be806b5230f9d11e0d9ed /capplets
parentc9b0659767febba8b1852c3c5726d55983c22e28 (diff)
downloadmate-control-center-8e68aa4f36fd333cb4f3c65efd7b0525a793299e.tar.bz2
mate-control-center-8e68aa4f36fd333cb4f3c65efd7b0525a793299e.tar.xz
removing deprecated GDK_DISPLAY()
Diffstat (limited to 'capplets')
-rw-r--r--capplets/Makefile.am38
-rw-r--r--capplets/appearance/mate-wp-info.c124
-rw-r--r--capplets/appearance/mate-wp-info.h23
-rw-r--r--capplets/appearance/mate-wp-xml.c891
-rw-r--r--capplets/appearance/mate-wp-xml.h4
-rw-r--r--capplets/appearance/theme-util.c15
-rw-r--r--capplets/common/mate-theme-info.c2
-rw-r--r--capplets/common/wm-common.c26
-rw-r--r--capplets/keybindings/eggcellrendererkeys.c503
-rw-r--r--capplets/keybindings/mate-keybinding-properties.c559
-rw-r--r--capplets/keyboard/mate-keyboard-properties-xkb.c2
-rw-r--r--capplets/mouse/mate-mouse-properties.c30
12 files changed, 1159 insertions, 1058 deletions
diff --git a/capplets/Makefile.am b/capplets/Makefile.am
index 004d00fd..9b3c70ea 100644
--- a/capplets/Makefile.am
+++ b/capplets/Makefile.am
@@ -1,26 +1,26 @@
SUBDIRS = \
- common \
- accessibility \
- appearance \
- default-applications \
- display \
- keybindings \
- keyboard \
- mouse \
- network \
+ common \
+ accessibility \
+ appearance \
+ default-applications \
+ display \
+ keybindings \
+ keyboard \
+ mouse \
+ network \
windows
DIST_SUBDIRS = \
- common \
- accessibility \
- appearance \
- default-applications \
- keybindings \
- keyboard \
- mouse \
- network \
- windows \
- display \
+ common \
+ accessibility \
+ appearance \
+ default-applications \
+ keybindings \
+ keyboard \
+ mouse \
+ network \
+ windows \
+ display \
about-me
diff --git a/capplets/appearance/mate-wp-info.c b/capplets/appearance/mate-wp-info.c
index 5c799eab..58145fd0 100644
--- a/capplets/appearance/mate-wp-info.c
+++ b/capplets/appearance/mate-wp-info.c
@@ -24,64 +24,74 @@
#include <gio/gio.h>
#include "mate-wp-info.h"
-MateWPInfo * mate_wp_info_new (const gchar * uri,
- MateDesktopThumbnailFactory * thumbs) {
- MateWPInfo *wp;
- GFile *file;
- GFileInfo *info;
-
- file = g_file_new_for_commandline_arg (uri);
-
- info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_NAME ","
- G_FILE_ATTRIBUTE_STANDARD_SIZE ","
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
- G_FILE_QUERY_INFO_NONE,
- NULL, NULL);
- g_object_unref (file);
-
- if (info == NULL || g_file_info_get_content_type (info) == NULL) {
- if (!strcmp (uri, "(none)")) {
- wp = g_new0 (MateWPInfo, 1);
-
- wp->mime_type = g_strdup ("image/x-no-data");
- wp->uri = g_strdup (uri);
- wp->name = g_strdup (_("No Desktop Background"));
- wp->size = 0;
- } else {
- wp = NULL;
- }
- } else {
- wp = g_new0 (MateWPInfo, 1);
-
- wp->uri = g_strdup (uri);
-
- wp->name = g_strdup (g_file_info_get_name (info));
- if (g_file_info_get_content_type (info) != NULL)
- wp->mime_type = g_strdup (g_file_info_get_content_type (info));
- wp->size = g_file_info_get_size (info);
- wp->mtime = g_file_info_get_attribute_uint64 (info,
- G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
- wp->thumburi = mate_desktop_thumbnail_factory_lookup (thumbs,
- uri,
- wp->mtime);
- }
-
- if (info != NULL)
- g_object_unref (info);
-
- return wp;
+MateWPInfo* mate_wp_info_new(const char* uri, MateDesktopThumbnailFactory* thumbs)
+{
+ MateWPInfo* wp;
+
+ GFile* file = g_file_new_for_commandline_arg(uri);
+
+ GFileInfo* info = g_file_query_info(file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+
+ g_object_unref(file);
+
+ if (info == NULL || g_file_info_get_content_type (info) == NULL)
+ {
+ if (!strcmp (uri, "(none)"))
+ {
+ wp = g_new0(MateWPInfo, 1);
+
+ wp->mime_type = g_strdup("image/x-no-data");
+ wp->uri = g_strdup(uri);
+ wp->name = g_strdup(_("No Desktop Background"));
+ wp->size = 0;
+ }
+ else
+ {
+ wp = NULL;
+ }
+ }
+ else
+ {
+ wp = g_new0 (MateWPInfo, 1);
+
+ wp->uri = g_strdup(uri);
+
+ wp->name = g_strdup(g_file_info_get_name(info));
+
+ if (g_file_info_get_content_type(info) != NULL)
+ {
+ wp->mime_type = g_strdup(g_file_info_get_content_type(info));
+ }
+
+ wp->size = g_file_info_get_size(info);
+ wp->mtime = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+ wp->thumburi = mate_desktop_thumbnail_factory_lookup(thumbs, uri, wp->mtime);
+ }
+
+ if (info != NULL)
+ {
+ g_object_unref(info);
+ }
+
+ return wp;
}
-void mate_wp_info_free (MateWPInfo * info) {
- if (info == NULL) {
- return;
- }
+void mate_wp_info_free(MateWPInfo* info)
+{
+ if (info == NULL)
+ {
+ return;
+ }
- g_free (info->uri);
- g_free (info->thumburi);
- g_free (info->name);
- g_free (info->mime_type);
+ g_free(info->uri);
+ g_free(info->thumburi);
+ g_free(info->name);
+ g_free(info->mime_type);
}
diff --git a/capplets/appearance/mate-wp-info.h b/capplets/appearance/mate-wp-info.h
index 95c94f89..21462e5c 100644
--- a/capplets/appearance/mate-wp-info.h
+++ b/capplets/appearance/mate-wp-info.h
@@ -24,22 +24,19 @@
#include <glib.h>
#include <libmateui/mate-desktop-thumbnail.h>
-typedef struct _MateWPInfo MateWPInfo;
+typedef struct _MateWPInfo {
+ char* uri;
+ char* thumburi;
+ char* name;
+ char* mime_type;
-struct _MateWPInfo {
- gchar * uri;
- gchar * thumburi;
- gchar * name;
- gchar * mime_type;
+ goffset size;
- goffset size;
+ time_t mtime;
+} MateWPInfo;
- time_t mtime;
-};
-
-MateWPInfo * mate_wp_info_new (const gchar * uri,
- MateDesktopThumbnailFactory * thumbs);
-void mate_wp_info_free (MateWPInfo * info);
+MateWPInfo* mate_wp_info_new(const char* uri, MateDesktopThumbnailFactory* thumbs);
+void mate_wp_info_free(MateWPInfo* info);
#endif
diff --git a/capplets/appearance/mate-wp-xml.c b/capplets/appearance/mate-wp-xml.c
index 2157acf7..c7d7867d 100644
--- a/capplets/appearance/mate-wp-xml.c
+++ b/capplets/appearance/mate-wp-xml.c
@@ -24,428 +24,531 @@
#include <string.h>
#include <libxml/parser.h>
-static gboolean mate_wp_xml_get_bool (const xmlNode * parent,
- const gchar * prop_name) {
- xmlChar * prop;
- gboolean ret_val = FALSE;
-
- g_return_val_if_fail (parent != NULL, FALSE);
- g_return_val_if_fail (prop_name != NULL, FALSE);
-
- prop = xmlGetProp ((xmlNode *) parent, (xmlChar*)prop_name);
- if (prop != NULL) {
- if (!g_ascii_strcasecmp ((gchar *)prop, "true") || !g_ascii_strcasecmp ((gchar *)prop, "1")) {
- ret_val = TRUE;
- } else {
- ret_val = FALSE;
- }
- g_free (prop);
- }
-
- return ret_val;
-}
+static gboolean mate_wp_xml_get_bool(const xmlNode* parent, const char* prop_name)
+{
+ gboolean ret_val = FALSE;
+
+ if (parent != NULL && prop_name != NULL)
+ {
+ xmlChar* prop = xmlGetProp((xmlNode*) parent, (xmlChar*) prop_name);
+
+ if (prop != NULL)
+ {
+ if (!g_ascii_strcasecmp((char*) prop, "true") || !g_ascii_strcasecmp((char*) prop, "1"))
+ {
+ ret_val = TRUE;
+ }
+ else
+ {
+ ret_val = FALSE;
+ }
+
+ g_free(prop);
+ }
+ }
-static void mate_wp_xml_set_bool (const xmlNode * parent,
- const xmlChar * prop_name, gboolean value) {
- g_return_if_fail (parent != NULL);
- g_return_if_fail (prop_name != NULL);
+ return ret_val;
+}
- if (value) {
- xmlSetProp ((xmlNode *) parent, prop_name, (xmlChar *)"true");
- } else {
- xmlSetProp ((xmlNode *) parent, prop_name, (xmlChar *)"false");
- }
+static void mate_wp_xml_set_bool(const xmlNode* parent, const xmlChar* prop_name, gboolean value)
+{
+ if (parent != NULL && prop_name != NULL)
+ {
+ if (value)
+ {
+ xmlSetProp((xmlNode*) parent, prop_name, (xmlChar*) "true");
+ }
+ else
+ {
+ xmlSetProp((xmlNode*) parent, prop_name, (xmlChar*) "false");
+ }
+ }
}
-static void mate_wp_load_legacy (AppearanceData *data) {
- FILE * fp;
- gchar * foo, * filename;
+static void mate_wp_load_legacy(AppearanceData* data)
+{
+ /* Legacy of GNOME2
+ * ~/.gnome2/wallpapers.list */
+ char* filename = g_build_filename(g_get_home_dir(), ".gnome2", "wallpapers.list", NULL);
- filename = g_build_filename (g_get_home_dir (), ".mate2",
- "wallpapers.list", NULL);
+ if (g_file_test(filename, G_FILE_TEST_EXISTS))
+ {
+ FILE* fp;
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- if ((fp = fopen (filename, "r")) != NULL) {
- foo = (gchar *) g_malloc (sizeof (gchar) * 4096);
- while (fgets (foo, 4096, fp)) {
- MateWPItem * item;
+ if ((fp = fopen(filename, "r")) != NULL)
+ {
+ char* foo = (char*) g_malloc(sizeof(char) * 4096);
- if (foo[strlen (foo) - 1] == '\n') {
- foo[strlen (foo) - 1] = '\0';
- }
+ while (fgets(foo, 4096, fp))
+ {
+ MateWPItem * item;
+
+ if (foo[strlen(foo) - 1] == '\n')
+ {
+ foo[strlen(foo) - 1] = '\0';
+ }
+
+ item = g_hash_table_lookup(data->wp_hash, foo);
- item = g_hash_table_lookup (data->wp_hash, foo);
- if (item != NULL) {
- continue;
+ if (item != NULL)
+ {
+ continue;
+ }
+
+ if (!g_file_test(foo, G_FILE_TEST_EXISTS))
+ {
+ continue;
+ }
+
+ item = mate_wp_item_new(foo, data->wp_hash, data->thumb_factory);
+
+ if (item != NULL && item->fileinfo == NULL)
+ {
+ mate_wp_item_free(item);
+ }
+ }
+
+ fclose(fp);
+ g_free(foo);
+ }
}
- if (!g_file_test (foo, G_FILE_TEST_EXISTS)) {
- continue;
+ g_free(filename);
+}
+
+static void mate_wp_xml_load_xml(AppearanceData* data, const char* filename)
+{
+ xmlDoc* wplist;
+ xmlNode* root;
+ xmlNode* list;
+ xmlNode* wpa;
+ xmlChar* nodelang;
+ const char* const* syslangs;
+ GdkColor color1;
+ GdkColor color2;
+ gint i;
+
+ wplist = xmlParseFile(filename);
+
+ if (!wplist)
+ {
+ return;
}
- item = mate_wp_item_new (foo, data->wp_hash, data->thumb_factory);
- if (item != NULL && item->fileinfo == NULL) {
- mate_wp_item_free (item);
+ syslangs = g_get_language_names();
+
+ root = xmlDocGetRootElement(wplist);
+
+ for (list = root->children; list != NULL; list = list->next)
+ {
+ if (!strcmp((char*) list->name, "wallpaper"))
+ {
+ MateWPItem * wp;
+ char *pcolor = NULL, *scolor = NULL;
+ char *s;
+ gboolean have_scale = FALSE, have_shade = FALSE;
+
+ wp = g_new0(MateWPItem, 1);
+
+ wp->deleted = mate_wp_xml_get_bool(list, "deleted");
+
+ for (wpa = list->children; wpa != NULL; wpa = wpa->next)
+ {
+ if (wpa->type == XML_COMMENT_NODE)
+ {
+ continue;
+ }
+ else if (!strcmp ((char*) wpa->name, "filename"))
+ {
+ if (wpa->last != NULL && wpa->last->content != NULL)
+ {
+ const char* none = "(none)";
+ char* content = g_strstrip((char*) wpa->last->content);
+
+ if (!strcmp (content, none))
+ {
+ wp->filename = g_strdup (content);
+ }
+ else if (g_utf8_validate (content, -1, NULL) && g_file_test (content, G_FILE_TEST_EXISTS))
+ {
+ wp->filename = g_strdup (content);
+ }
+ else
+ {
+ wp->filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL);
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "name"))
+ {
+ if (wpa->last != NULL && wpa->last->content != NULL)
+ {
+ nodelang = xmlNodeGetLang (wpa->last);
+
+ if (wp->name == NULL && nodelang == NULL)
+ {
+ wp->name = g_strdup (g_strstrip ((char *)wpa->last->content));
+ }
+ else
+ {
+ for (i = 0; syslangs[i] != NULL; i++)
+ {
+ if (!strcmp (syslangs[i], (char *)nodelang))
+ {
+ g_free (wp->name);
+ wp->name = g_strdup (g_strstrip ((char*) wpa->last->content));
+ break;
+ }
+ }
+ }
+
+ xmlFree (nodelang);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "options"))
+ {
+ if (wpa->last != NULL)
+ {
+ wp->options = wp_item_string_to_option(g_strstrip ((char *)wpa->last->content));
+ have_scale = TRUE;
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "shade_type"))
+ {
+ if (wpa->last != NULL)
+ {
+ wp->shade_type = wp_item_string_to_shading(g_strstrip ((char *)wpa->last->content));
+ have_shade = TRUE;
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "pcolor"))
+ {
+ if (wpa->last != NULL)
+ {
+ pcolor = g_strdup(g_strstrip ((char *)wpa->last->content));
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "scolor"))
+ {
+ if (wpa->last != NULL)
+ {
+ scolor = g_strdup(g_strstrip ((char *)wpa->last->content));
+ }
+ }
+ else if (!strcmp ((char*) wpa->name, "text"))
+ {
+ /* Do nothing here, libxml2 is being weird */
+ }
+ else
+ {
+ g_warning ("Unknown Tag: %s", wpa->name);
+ }
+ }
+
+ /* Make sure we don't already have this one and that filename exists */
+ if (wp->filename == NULL || g_hash_table_lookup (data->wp_hash, wp->filename) != NULL)
+ {
+
+ mate_wp_item_free (wp);
+ g_free (pcolor);
+ g_free (scolor);
+ continue;
+ }
+
+ /* Verify the colors and alloc some GdkColors here */
+ if (!have_scale)
+ {
+ s = mateconf_client_get_string(data->client, WP_OPTIONS_KEY, NULL);
+ wp->options = wp_item_string_to_option (s);
+ g_free (s);
+ }
+
+ if (!have_shade)
+ {
+ s = mateconf_client_get_string(data->client, WP_SHADING_KEY, NULL);
+ wp->shade_type = wp_item_string_to_shading (s);
+ g_free (s);
+ }
+
+ if (pcolor == NULL)
+ {
+ pcolor = mateconf_client_get_string(data->client, WP_PCOLOR_KEY, NULL);
+ }
+
+ if (scolor == NULL)
+ {
+ scolor = mateconf_client_get_string (data->client, WP_SCOLOR_KEY, NULL);
+ }
+
+ gdk_color_parse(pcolor, &color1);
+ gdk_color_parse(scolor, &color2);
+ g_free(pcolor);
+ g_free(scolor);
+
+ wp->pcolor = gdk_color_copy(&color1);
+ wp->scolor = gdk_color_copy(&color2);
+
+ if ((wp->filename != NULL && g_file_test (wp->filename, G_FILE_TEST_EXISTS)) || !strcmp (wp->filename, "(none)"))
+ {
+ wp->fileinfo = mate_wp_info_new(wp->filename, data->thumb_factory);
+
+ if (wp->name == NULL || !strcmp(wp->filename, "(none)"))
+ {
+ g_free (wp->name);
+ wp->name = g_strdup (wp->fileinfo->name);
+ }
+
+ mate_wp_item_ensure_mate_bg (wp);
+ mate_wp_item_update_description (wp);
+ g_hash_table_insert (data->wp_hash, wp->filename, wp);
+ }
+ else
+ {
+ mate_wp_item_free(wp);
+ wp = NULL;
+ }
+ }
}
- }
- fclose (fp);
- g_free (foo);
- }
- }
- g_free (filename);
+ xmlFreeDoc(wplist);
}
-static void mate_wp_xml_load_xml (AppearanceData *data,
- const gchar * filename) {
- xmlDoc * wplist;
- xmlNode * root, * list, * wpa;
- xmlChar * nodelang;
- const gchar * const * syslangs;
- GdkColor color1, color2;
- gint i;
-
- wplist = xmlParseFile (filename);
-
- if (!wplist)
- return;
-
- syslangs = g_get_language_names ();
-
- root = xmlDocGetRootElement (wplist);
-
- for (list = root->children; list != NULL; list = list->next) {
- if (!strcmp ((gchar *)list->name, "wallpaper")) {
- MateWPItem * wp;
- gchar *pcolor = NULL, *scolor = NULL;
- gchar *s;
- gboolean have_scale = FALSE, have_shade = FALSE;
-
- wp = g_new0 (MateWPItem, 1);
-
- wp->deleted = mate_wp_xml_get_bool (list, "deleted");
-
- for (wpa = list->children; wpa != NULL; wpa = wpa->next) {
- if (wpa->type == XML_COMMENT_NODE) {
- continue;
- } else if (!strcmp ((gchar *)wpa->name, "filename")) {
- if (wpa->last != NULL && wpa->last->content != NULL) {
- const char * none = "(none)";
- gchar *content = g_strstrip ((gchar *)wpa->last->content);
-
- if (!strcmp (content, none))
- wp->filename = g_strdup (content);
- else if (g_utf8_validate (content, -1, NULL) &&
- g_file_test (content, G_FILE_TEST_EXISTS))
- wp->filename = g_strdup (content);
- else
- wp->filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL);
- } else {
- break;
- }
- } else if (!strcmp ((gchar *)wpa->name, "name")) {
- if (wpa->last != NULL && wpa->last->content != NULL) {
- nodelang = xmlNodeGetLang (wpa->last);
-
- if (wp->name == NULL && nodelang == NULL) {
- wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content));
- } else {
- for (i = 0; syslangs[i] != NULL; i++) {
- if (!strcmp (syslangs[i], (gchar *)nodelang)) {
- g_free (wp->name);
- wp->name = g_strdup (g_strstrip ((gchar *)wpa->last->content));
- break;
- }
- }
- }
-
- xmlFree (nodelang);
- } else {
- break;
- }
- } else if (!strcmp ((gchar *)wpa->name, "options")) {
- if (wpa->last != NULL) {
- wp->options = wp_item_string_to_option (g_strstrip ((gchar *)wpa->last->content));
- have_scale = TRUE;
- }
- } else if (!strcmp ((gchar *)wpa->name, "shade_type")) {
- if (wpa->last != NULL) {
- wp->shade_type = wp_item_string_to_shading (g_strstrip ((gchar *)wpa->last->content));
- have_shade = TRUE;
- }
- } else if (!strcmp ((gchar *)wpa->name, "pcolor")) {
- if (wpa->last != NULL) {
- pcolor = g_strdup (g_strstrip ((gchar *)wpa->last->content));
- }
- } else if (!strcmp ((gchar *)wpa->name, "scolor")) {
- if (wpa->last != NULL) {
- scolor = g_strdup (g_strstrip ((gchar *)wpa->last->content));
- }
- } else if (!strcmp ((gchar *)wpa->name, "text")) {
- /* Do nothing here, libxml2 is being weird */
- } else {
- g_warning ("Unknown Tag: %s", wpa->name);
+static void mate_wp_file_changed(GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonitorEvent event_type, AppearanceData* data)
+{
+ char* filename;
+
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ filename = g_file_get_path(file);
+ mate_wp_xml_load_xml(data, filename);
+ g_free(filename);
+ break;
+ default:
+ break;
}
- }
-
- /* Make sure we don't already have this one and that filename exists */
- if (wp->filename == NULL ||
- g_hash_table_lookup (data->wp_hash, wp->filename) != NULL) {
-
- mate_wp_item_free (wp);
- g_free (pcolor);
- g_free (scolor);
- continue;
- }
-
- /* Verify the colors and alloc some GdkColors here */
- if (!have_scale) {
- s = mateconf_client_get_string (data->client, WP_OPTIONS_KEY, NULL);
- wp->options = wp_item_string_to_option (s);
- g_free (s);
- }
-
- if (!have_shade) {
- s = mateconf_client_get_string (data->client, WP_SHADING_KEY, NULL);
- wp->shade_type = wp_item_string_to_shading (s);
- g_free (s);
- }
-
- if (pcolor == NULL) {
- pcolor = mateconf_client_get_string (data->client,
- WP_PCOLOR_KEY, NULL);
- }
- if (scolor == NULL) {
- scolor = mateconf_client_get_string (data->client,
- WP_SCOLOR_KEY, NULL);
- }
- gdk_color_parse (pcolor, &color1);
- gdk_color_parse (scolor, &color2);
- g_free (pcolor);
- g_free (scolor);
-
- wp->pcolor = gdk_color_copy (&color1);
- wp->scolor = gdk_color_copy (&color2);
-
- if ((wp->filename != NULL &&
- g_file_test (wp->filename, G_FILE_TEST_EXISTS)) ||
- !strcmp (wp->filename, "(none)")) {
- wp->fileinfo = mate_wp_info_new (wp->filename, data->thumb_factory);
-
- if (wp->name == NULL || !strcmp (wp->filename, "(none)")) {
- g_free (wp->name);
- wp->name = g_strdup (wp->fileinfo->name);
+}
+
+static void mate_wp_xml_add_monitor(GFile* directory, AppearanceData* data)
+{
+ GError* error = NULL;
+
+ GFileMonitor* monitor = g_file_monitor_directory(directory, G_FILE_MONITOR_NONE, NULL, &error);
+
+ if (error != NULL)
+ {
+ char* path = g_file_get_parse_name (directory);
+ g_warning("Unable to monitor directory %s: %s", path, error->message);
+ g_error_free(error);
+ g_free(path);
+ return;
}
- mate_wp_item_ensure_mate_bg (wp);
- mate_wp_item_update_description (wp);
- g_hash_table_insert (data->wp_hash, wp->filename, wp);
- } else {
- mate_wp_item_free (wp);
- wp = NULL;
- }
- }
- }
- xmlFreeDoc (wplist);
+ g_signal_connect(monitor, "changed", G_CALLBACK(mate_wp_file_changed), data);
}
-static void mate_wp_file_changed (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- AppearanceData *data) {
- gchar * filename;
-
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_CREATED:
- filename = g_file_get_path (file);
- mate_wp_xml_load_xml (data, filename);
- g_free (filename);
- break;
- default:
- break;
- }
-}
+static void mate_wp_xml_load_from_dir(const char* path, AppearanceData* data)
+{
+ GFile* directory;
+ GFileEnumerator* enumerator;
+ GError* error = NULL;
+ GFileInfo* info;
+
+ if (!g_file_test(path, G_FILE_TEST_IS_DIR))
+ {
+ return;
+ }
+
+ directory = g_file_new_for_path(path);
+ enumerator = g_file_enumerate_children(
+ directory,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &error);
+
+ if (error != NULL)
+ {
+ g_warning("Unable to check directory %s: %s", path, error->message);
+ g_error_free(error);
+ g_object_unref(directory);
+ return;
+ }
+
+ while ((info = g_file_enumerator_next_file(enumerator, NULL, NULL)))
+ {
+ const char* filename = g_file_info_get_name(info);
+ char* fullpath = g_build_filename(path, filename, NULL);
+
+ g_object_unref(info);
+
+ mate_wp_xml_load_xml(data, fullpath);
+ g_free(fullpath);
+ }
-static void mate_wp_xml_add_monitor (GFile *directory,
- AppearanceData *data) {
- GFileMonitor *monitor;
- GError *error = NULL;
-
- monitor = g_file_monitor_directory (directory,
- G_FILE_MONITOR_NONE,
- NULL,
- &error);
- if (error != NULL) {
- gchar *path;
-
- path = g_file_get_parse_name (directory);
- g_warning ("Unable to monitor directory %s: %s",
- path, error->message);
- g_error_free (error);
- g_free (path);
- return;
- }
-
- g_signal_connect (monitor, "changed",
- G_CALLBACK (mate_wp_file_changed),
- data);
+ g_file_enumerator_close(enumerator, NULL, NULL);
+
+ mate_wp_xml_add_monitor(directory, data);
+
+ g_object_unref(directory);
}
-static void mate_wp_xml_load_from_dir (const gchar *path,
- AppearanceData *data) {
- GFile *directory;
- GFileEnumerator *enumerator;
- GError *error = NULL;
- GFileInfo *info;
-
- if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
- return;
- }
-
- directory = g_file_new_for_path (path);
- enumerator = g_file_enumerate_children (directory,
- G_FILE_ATTRIBUTE_STANDARD_NAME,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- &error);
- if (error != NULL) {
- g_warning ("Unable to check directory %s: %s", path, error->message);
- g_error_free (error);
- g_object_unref (directory);
- return;
- }
-
- while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL))) {
- const gchar *filename;
- gchar *fullpath;
-
- filename = g_file_info_get_name (info);
- fullpath = g_build_filename (path, filename, NULL);
- g_object_unref (info);
-
- mate_wp_xml_load_xml (data, fullpath);
- g_free (fullpath);
- }
- g_file_enumerator_close (enumerator, NULL, NULL);
-
- mate_wp_xml_add_monitor (directory, data);
-
- g_object_unref (directory);
+void mate_wp_xml_load_list(AppearanceData* data)
+{
+ const char* const* system_data_dirs;
+ char* datadir;
+ char* wpdbfile;
+ gint i;
+
+ wpdbfile = g_build_filename(g_get_home_dir(), ".config", "mate", "backgrounds.xml", NULL);
+
+ if (g_file_test(wpdbfile, G_FILE_TEST_EXISTS))
+ {
+ mate_wp_xml_load_xml(data, wpdbfile);
+ }
+ else
+ {
+ g_free (wpdbfile);
+
+ wpdbfile = g_build_filename(g_get_home_dir(), ".config", "mate", "wp-list.xml", NULL);
+
+ if (g_file_test(wpdbfile, G_FILE_TEST_EXISTS))
+ {
+ mate_wp_xml_load_xml(data, wpdbfile);
+ }
+ }
+
+ g_free (wpdbfile);
+
+ /* This is obsoleto.
+ * Do not store stuff in ~/.mate2/ */
+ #ifndef MATE_DISABLE_DEPRECATED
+ /*wpdbfile = g_build_filename(g_get_home_dir(), ".mate2", "backgrounds.xml", NULL);
+
+ if (g_file_test(wpdbfile, G_FILE_TEST_EXISTS))
+ {
+ mate_wp_xml_load_xml(data, wpdbfile);
+ }
+ else
+ {
+ g_free (wpdbfile);
+
+ wpdbfile = g_build_filename(g_get_home_dir(), ".mate2", "wp-list.xml", NULL);
+
+ if (g_file_test(wpdbfile, G_FILE_TEST_EXISTS))
+ {
+ mate_wp_xml_load_xml(data, wpdbfile);
+ }
+ }
+
+ g_free(wpdbfile);*/
+ #endif /* MATE_DISABLE_DEPRECATED */
+
+ datadir = g_build_filename(g_get_user_data_dir(), "mate-background-properties", NULL);
+ mate_wp_xml_load_from_dir(datadir, data);
+ g_free(datadir);
+
+ system_data_dirs = g_get_system_data_dirs();
+
+ for (i = 0; system_data_dirs[i]; i++)
+ {
+ datadir = g_build_filename(system_data_dirs[i], "mate-background-properties", NULL);
+ mate_wp_xml_load_from_dir(datadir, data);
+ g_free (datadir);
+ }
+
+ mate_wp_xml_load_from_dir(WALLPAPER_DATADIR, data);
+
+ mate_wp_load_legacy(data);
}
-void mate_wp_xml_load_list (AppearanceData *data) {
- const char * const *system_data_dirs;
- gchar * datadir;
- gchar * wpdbfile;
- gint i;
-
- wpdbfile = g_build_filename (g_get_home_dir (),
- ".mate2",
- "backgrounds.xml",
- NULL);
-
- if (g_file_test (wpdbfile, G_FILE_TEST_EXISTS)) {
- mate_wp_xml_load_xml (data, wpdbfile);
- } else {
- g_free (wpdbfile);
- wpdbfile = g_build_filename (g_get_home_dir (),
- ".mate2",
- "wp-list.xml",
- NULL);
- if (g_file_test (wpdbfile, G_FILE_TEST_EXISTS)) {
- mate_wp_xml_load_xml (data, wpdbfile);
- }
- }
- g_free (wpdbfile);
-
- datadir = g_build_filename (g_get_user_data_dir (),
- "mate-background-properties",
- NULL);
- mate_wp_xml_load_from_dir (datadir, data);
- g_free (datadir);
-
- system_data_dirs = g_get_system_data_dirs ();
- for (i = 0; system_data_dirs[i]; i++) {
- datadir = g_build_filename (system_data_dirs[i],
- "mate-background-properties",
- NULL);
- mate_wp_xml_load_from_dir (datadir, data);
- g_free (datadir);
- }
-
- mate_wp_xml_load_from_dir (WALLPAPER_DATADIR, data);
-
- mate_wp_load_legacy (data);
+static void mate_wp_list_flatten(const char* key, MateWPItem* item, GSList** list)
+{
+ if (key != NULL && item != NULL)
+ {
+ *list = g_slist_prepend(*list, item);
+ }
}
-static void mate_wp_list_flatten (const gchar * key, MateWPItem * item,
- GSList ** list) {
- g_return_if_fail (key != NULL);
- g_return_if_fail (item != NULL);
+void mate_wp_xml_save_list(AppearanceData* data)
+{
+ xmlDoc* wplist;
+ xmlNode* root;
+ xmlNode* wallpaper;
+ //xmlNode* item;
+ GSList* list = NULL;
+ char* wpfile;
+
+ g_hash_table_foreach(data->wp_hash, (GHFunc) mate_wp_list_flatten, &list);
+ g_hash_table_destroy(data->wp_hash);
+ list = g_slist_reverse(list);
+
+ wpfile = g_build_filename(g_get_home_dir (), ".config", "mate", "backgrounds.xml", NULL);
+
+ xmlKeepBlanksDefault(0);
+
+ wplist = xmlNewDoc((xmlChar*) "1.0");
+ xmlCreateIntSubset(wplist, (xmlChar*) "wallpapers", NULL, (xmlChar*) "mate-wp-list.dtd");
+ root = xmlNewNode(NULL, (xmlChar*) "wallpapers");
+ xmlDocSetRootElement(wplist, root);
+
+ while (list != NULL)
+ {
+ MateWPItem* wpitem = list->data;
+ const char* none = "(none)";
+ char* filename;
+ const char* scale;
+ const char* shade;
+ char* pcolor;
+ char* scolor;
+
+ if (!strcmp(wpitem->filename, none) || (g_utf8_validate(wpitem->filename, -1, NULL) && g_file_test(wpitem->filename, G_FILE_TEST_EXISTS)))
+ {
+ filename = g_strdup(wpitem->filename);
+ }
+ else
+ {
+ filename = g_filename_to_utf8(wpitem->filename, -1, NULL, NULL, NULL);
+ }
+
+ pcolor = gdk_color_to_string(wpitem->pcolor);
+ scolor = gdk_color_to_string(wpitem->scolor);
+ scale = wp_item_option_to_string(wpitem->options);
+ shade = wp_item_shading_to_string(wpitem->shade_type);
+
+ wallpaper = xmlNewChild(root, NULL, (xmlChar*) "wallpaper", NULL);
+ mate_wp_xml_set_bool(wallpaper, (xmlChar*) "deleted", wpitem->deleted);
+
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "name", (xmlChar*) wpitem->name);
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "filename", (xmlChar*) filename);
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "options", (xmlChar*) scale);
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "shade_type", (xmlChar*) shade);
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "pcolor", (xmlChar*) pcolor);
+ xmlNewTextChild(wallpaper, NULL, (xmlChar*) "scolor", (xmlChar*) scolor);
+
+ g_free(pcolor);
+ g_free(scolor);
+ g_free(filename);
+
+ list = g_slist_delete_link(list, list);
+ mate_wp_item_free(wpitem);
+ }
- *list = g_slist_prepend (*list, item);
-}
+ /* Guardamos el archivo, solo si hay nodos en <wallpapers> */
+ if (xmlChildElementCount(root) > 0)
+ {
+ xmlSaveFormatFile(wpfile, wplist, 1);
+ }
-void mate_wp_xml_save_list (AppearanceData *data) {
- xmlDoc * wplist;
- xmlNode * root, * wallpaper, * item;
- GSList * list = NULL;
- gchar * wpfile;
-
- g_hash_table_foreach (data->wp_hash,
- (GHFunc) mate_wp_list_flatten, &list);
- g_hash_table_destroy (data->wp_hash);
- list = g_slist_reverse (list);
-
- wpfile = g_build_filename (g_get_home_dir (),
- "/.mate2",
- "backgrounds.xml",
- NULL);
-
- xmlKeepBlanksDefault (0);
-
- wplist = xmlNewDoc ((xmlChar *)"1.0");
- xmlCreateIntSubset (wplist, (xmlChar *)"wallpapers", NULL, (xmlChar *)"mate-wp-list.dtd");
- root = xmlNewNode (NULL, (xmlChar *)"wallpapers");
- xmlDocSetRootElement (wplist, root);
-
- while (list != NULL) {
- MateWPItem * wpitem = list->data;
- const char * none = "(none)";
- gchar * filename;
- const gchar * scale, * shade;
- gchar * pcolor, * scolor;
-
- if (!strcmp (wpitem->filename, none) ||
- (g_utf8_validate (wpitem->filename, -1, NULL) &&
- g_file_test (wpitem->filename, G_FILE_TEST_EXISTS)))
- filename = g_strdup (wpitem->filename);
- else
- filename = g_filename_to_utf8 (wpitem->filename, -1, NULL, NULL, NULL);
-
- pcolor = gdk_color_to_string (wpitem->pcolor);
- scolor = gdk_color_to_string (wpitem->scolor);
- scale = wp_item_option_to_string (wpitem->options);
- shade = wp_item_shading_to_string (wpitem->shade_type);
-
- wallpaper = xmlNewChild (root, NULL, (xmlChar *)"wallpaper", NULL);
- mate_wp_xml_set_bool (wallpaper, (xmlChar *)"deleted", wpitem->deleted);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"name", (xmlChar *)wpitem->name);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"filename", (xmlChar *)filename);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"options", (xmlChar *)scale);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"shade_type", (xmlChar *)shade);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"pcolor", (xmlChar *)pcolor);
- item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"scolor", (xmlChar *)scolor);
- g_free (pcolor);
- g_free (scolor);
- g_free (filename);
-
- list = g_slist_delete_link (list, list);
- mate_wp_item_free (wpitem);
- }
- xmlSaveFormatFile (wpfile, wplist, 1);
- xmlFreeDoc (wplist);
- g_free (wpfile);
+ xmlFreeDoc(wplist);
+ g_free(wpfile);
}
diff --git a/capplets/appearance/mate-wp-xml.h b/capplets/appearance/mate-wp-xml.h
index 795487ff..18d3807b 100644
--- a/capplets/appearance/mate-wp-xml.h
+++ b/capplets/appearance/mate-wp-xml.h
@@ -21,8 +21,8 @@
#ifndef _MATE_WP_XML_H_
#define _MATE_WP_XML_H_
-void mate_wp_xml_load_list (AppearanceData *data);
-void mate_wp_xml_save_list (AppearanceData *data);
+void mate_wp_xml_load_list(AppearanceData* data);
+void mate_wp_xml_save_list(AppearanceData* data);
#endif
diff --git a/capplets/appearance/theme-util.c b/capplets/appearance/theme-util.c
index 2305b0f9..69a0423a 100644
--- a/capplets/appearance/theme-util.c
+++ b/capplets/appearance/theme-util.c
@@ -29,8 +29,7 @@
#include "capplet-util.h"
#include "theme-util.h"
-gboolean
-theme_is_writable (const gpointer theme)
+gboolean theme_is_writable (const gpointer theme)
{
MateThemeCommonInfo *info = theme;
GFile *file;
@@ -57,8 +56,7 @@ theme_is_writable (const gpointer theme)
return writable;
}
-gboolean
-theme_delete (const gchar *name, ThemeType type)
+gboolean theme_delete (const gchar *name, ThemeType type)
{
gboolean rc;
GtkDialog *dialog;
@@ -140,8 +138,7 @@ theme_delete (const gchar *name, ThemeType type)
return rc;
}
-gboolean
-theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter)
+gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter)
{
GtkTreeIter walk, prev;
gboolean valid;
@@ -160,8 +157,7 @@ theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter)
return FALSE;
}
-gboolean
-theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
+gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
{
GtkTreeIter walk;
gboolean valid;
@@ -190,8 +186,7 @@ theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
return FALSE;
}
-gboolean
-packagekit_available (void)
+gboolean packagekit_available (void)
{
DBusGConnection *connection;
DBusGProxy *proxy;
diff --git a/capplets/common/mate-theme-info.c b/capplets/common/mate-theme-info.c
index aead0b34..b15abafe 100644
--- a/capplets/common/mate-theme-info.c
+++ b/capplets/common/mate-theme-info.c
@@ -637,7 +637,7 @@ read_current_cursor_font (void)
gchar *dir_name;
struct dirent *file_dirent;
- dir_name = g_build_filename (g_get_home_dir (), ".mate2/share/cursor-fonts", NULL);
+ dir_name = g_build_filename (g_get_home_dir (), ".config/mate/share/cursor-fonts", NULL);
if (! g_file_test (dir_name, G_FILE_TEST_EXISTS)) {
g_free (dir_name);
return NULL;
diff --git a/capplets/common/wm-common.c b/capplets/common/wm-common.c
index 31cd503d..acf9e431 100644
--- a/capplets/common/wm-common.c
+++ b/capplets/common/wm-common.c
@@ -29,12 +29,12 @@ wm_common_get_window_manager_property (Atom atom)
if (wm_window == None)
return NULL;
- utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False);
+ utf8_string = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "UTF8_STRING", False);
gdk_error_trap_push ();
val = NULL;
- result = XGetWindowProperty (GDK_DISPLAY (),
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
wm_window,
atom,
0, G_MAXLONG,
@@ -62,7 +62,7 @@ wm_common_get_window_manager_property (Atom atom)
char*
wm_common_get_current_window_manager (void)
{
- Atom atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);
+ Atom atom = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WM_NAME", False);
char *result;
result = wm_common_get_window_manager_property (atom);
@@ -75,7 +75,7 @@ wm_common_get_current_window_manager (void)
char**
wm_common_get_current_keybindings (void)
{
- Atom keybindings_atom = XInternAtom (GDK_DISPLAY (), "_MATE_WM_KEYBINDINGS", False);
+ Atom keybindings_atom = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_MATE_WM_KEYBINDINGS", False);
char *keybindings = wm_common_get_window_manager_property (keybindings_atom);
char **results;
@@ -89,7 +89,7 @@ wm_common_get_current_keybindings (void)
}
else
{
- Atom wm_atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);
+ Atom wm_atom = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WM_NAME", False);
char *wm_name = wm_common_get_window_manager_property (wm_atom);
char *to_copy[] = { NULL, NULL };
@@ -111,8 +111,8 @@ update_wm_window (void)
gulong nitems;
gulong bytes_after;
- XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
- XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False),
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW (),
+ XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_SUPPORTING_WM_CHECK", False),
0, G_MAXLONG, False, XA_WINDOW, &type, &format,
&nitems, &bytes_after, (guchar **) &xwindow);
@@ -123,8 +123,8 @@ update_wm_window (void)
}
gdk_error_trap_push ();
- XSelectInput (GDK_DISPLAY (), *xwindow, StructureNotifyMask | PropertyChangeMask);
- XSync (GDK_DISPLAY (), False);
+ XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), *xwindow, StructureNotifyMask | PropertyChangeMask);
+ XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
if (gdk_error_trap_pop ())
{
@@ -149,10 +149,10 @@ wm_window_event_filter (GdkXEvent *xev,
wm_window != None && xevent->xany.window == wm_window) ||
(xevent->type == PropertyNotify &&
xevent->xany.window == GDK_ROOT_WINDOW () &&
- xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False))) ||
+ xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_SUPPORTING_WM_CHECK", False))) ||
(xevent->type == PropertyNotify &&
wm_window != None && xevent->xany.window == wm_window &&
- xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False))))
+ xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WM_NAME", False))))
{
update_wm_window ();
(* ncb_data->func) ((gpointer)wm_common_get_current_window_manager(),
@@ -177,8 +177,8 @@ wm_common_register_window_manager_change (GFunc func,
update_wm_window ();
- XSelectInput (GDK_DISPLAY (), GDK_ROOT_WINDOW (), PropertyChangeMask);
- XSync (GDK_DISPLAY (), False);
+ XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW (), PropertyChangeMask);
+ XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
}
diff --git a/capplets/keybindings/eggcellrendererkeys.c b/capplets/keybindings/eggcellrendererkeys.c
index 776a5391..8f4260ec 100644
--- a/capplets/keybindings/eggcellrendererkeys.c
+++ b/capplets/keybindings/eggcellrendererkeys.c
@@ -7,13 +7,13 @@
#include "eggaccelerators.h"
#ifndef EGG_COMPILATION
-#ifndef _
-#define _(x) dgettext (GETTEXT_PACKAGE, x)
-#define N_(x) x
-#endif
+ #ifndef _
+ #define _(x) dgettext (GETTEXT_PACKAGE, x)
+ #define N_(x) x
+ #endif
#else
-#define _(x) x
-#define N_(x) x
+ #define _(x) x
+ #define N_(x) x
#endif
#define EGG_CELL_RENDERER_TEXT_PATH "egg-cell-renderer-text"
@@ -58,81 +58,76 @@ enum {
PROP_ACCEL_MODE
};
-static GtkCellRendererTextClass *parent_class = NULL;
+static GtkCellRendererTextClass* parent_class = NULL;
-GType
-egg_cell_renderer_keys_get_type (void)
+GType egg_cell_renderer_keys_get_type(void)
{
- static GType cell_keys_type = 0;
-
- if (!cell_keys_type)
- {
- static const GTypeInfo cell_keys_info =
- {
- sizeof (EggCellRendererKeysClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)egg_cell_renderer_keys_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EggCellRendererKeys),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_cell_renderer_keys_init
- };
+ static GType cell_keys_type = 0;
- cell_keys_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "EggCellRendererKeys", &cell_keys_info, 0);
- }
+ if (!cell_keys_type)
+ {
+ static const GTypeInfo cell_keys_info = {
+ sizeof (EggCellRendererKeysClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc)egg_cell_renderer_keys_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EggCellRendererKeys),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) egg_cell_renderer_keys_init
+ };
+
+ cell_keys_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "EggCellRendererKeys", &cell_keys_info, 0);
+ }
- return cell_keys_type;
+ return cell_keys_type;
}
-static void
-egg_cell_renderer_keys_init (EggCellRendererKeys *cell_keys)
+static void egg_cell_renderer_keys_init(EggCellRendererKeys* cell_keys)
{
- cell_keys->accel_mode = EGG_CELL_RENDERER_KEYS_MODE_GTK;
+ MATEDEBUG();
+ cell_keys->accel_mode = EGG_CELL_RENDERER_KEYS_MODE_GTK;
}
/* FIXME setup stuff to generate this */
/* VOID:STRING,UINT,FLAGS,UINT */
-static void
-marshal_VOID__STRING_UINT_FLAGS_UINT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
+static void marshal_VOID__STRING_UINT_FLAGS_UINT(GClosure* closure, GValue* return_value, guint n_param_values, const GValue* param_values, gpointer invocation_hint, gpointer marshal_data)
{
- typedef void (*GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (gpointer data1,
- const char *arg_1,
- guint arg_2,
- int arg_3,
- guint arg_4,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 5);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
+ /* typedef inside a function? wow */
+ typedef void (*GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (
+ gpointer data1,
+ const char* arg_1,
+ guint arg_2,
+ int arg_3,
+ guint arg_4,
+ gpointer data2);
+
+ register GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT callback;
+ register GCClosure* cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA(closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer(param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer(param_values + 0);
+ data2 = closure->data;
+ }
- callback = (GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (marshal_data ? marshal_data : cc->callback);
+ callback = (GMarshalFunc_VOID__STRING_UINT_FLAGS_UINT) (marshal_data ? marshal_data : cc->callback);
- callback (data1,
- g_value_get_string (param_values + 1),
- g_value_get_uint (param_values + 2),
- g_value_get_flags (param_values + 3),
- g_value_get_uint (param_values + 4),
- data2);
+ callback(data1,
+ g_value_get_string(param_values + 1),
+ g_value_get_uint(param_values + 2),
+ g_value_get_flags(param_values + 3),
+ g_value_get_uint(param_values + 4),
+ data2);
}
static void
@@ -229,19 +224,19 @@ egg_cell_renderer_keys_new (void)
static void
egg_cell_renderer_keys_finalize (GObject *object)
{
-
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
-static gchar *
-convert_keysym_state_to_string (guint keysym,
- guint keycode,
- EggVirtualModifierType mask)
+static gchar* convert_keysym_state_to_string(guint keysym, guint keycode, EggVirtualModifierType mask)
{
- if (keysym == 0 && keycode == 0)
- return g_strdup (_("Disabled"));
- else
- return egg_virtual_accelerator_label (keysym, keycode, mask);
+ if (keysym == 0 && keycode == 0)
+ {
+ return g_strdup (_("Disabled"));
+ }
+ else
+ {
+ return egg_virtual_accelerator_label(keysym, keycode, mask);
+ }
}
static void
@@ -318,31 +313,32 @@ egg_cell_renderer_keys_set_property (GObject *object,
}
}
-static gboolean
-is_modifier (guint keycode)
+static gboolean is_modifier(guint keycode)
{
- gint i;
- gint map_size;
- XModifierKeymap *mod_keymap;
- gboolean retval = FALSE;
+ gint i;
+ gint map_size;
+ XModifierKeymap* mod_keymap;
+ gboolean retval = FALSE;
- mod_keymap = XGetModifierMapping (gdk_display);
+ mod_keymap = XGetModifierMapping(gdk_display);
- map_size = 8 * mod_keymap->max_keypermod;
- i = 0;
- while (i < map_size)
- {
- if (keycode == mod_keymap->modifiermap[i])
- {
- retval = TRUE;
- break;
- }
- ++i;
- }
+ map_size = 8 * mod_keymap->max_keypermod;
+ i = 0;
- XFreeModifiermap (mod_keymap);
+ while (i < map_size)
+ {
+ if (keycode == mod_keymap->modifiermap[i])
+ {
+ retval = TRUE;
+ break;
+ }
+
+ ++i;
+ }
- return retval;
+ XFreeModifiermap(mod_keymap);
+
+ return retval;
}
static void
@@ -374,142 +370,143 @@ egg_cell_renderer_keys_get_size (GtkCellRenderer *cell,
* GTK mode) and a removed key.
*/
-static gboolean
-grab_key_callback (GtkWidget *widget,
- GdkEventKey *event,
- void *data)
+static gboolean grab_key_callback(GtkWidget* widget, GdkEventKey* event, void* data)
{
- GdkModifierType accel_mods = 0;
- guint accel_keyval;
- EggCellRendererKeys *keys;
- char *path;
- gboolean edited;
- gboolean cleared;
- GdkModifierType consumed_modifiers;
- guint upper;
- GdkModifierType ignored_modifiers;
-
- keys = EGG_CELL_RENDERER_KEYS (data);
+ GdkModifierType accel_mods = 0;
+ guint accel_keyval;
+ EggCellRendererKeys *keys;
+ char *path;
+ gboolean edited;
+ gboolean cleared;
+ GdkModifierType consumed_modifiers;
+ guint upper;
+ GdkModifierType ignored_modifiers;
+
+ keys = EGG_CELL_RENDERER_KEYS(data);
+
+ if (is_modifier(event->hardware_keycode))
+ {
+ return TRUE;
+ }
- if (is_modifier (event->hardware_keycode))
- return TRUE;
+ edited = FALSE;
+ cleared = FALSE;
- edited = FALSE;
- cleared = FALSE;
+ consumed_modifiers = 0;
+ gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
+ event->hardware_keycode,
+ event->state,
+ event->group,
+ NULL, NULL, NULL, &consumed_modifiers);
- consumed_modifiers = 0;
- gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
- event->hardware_keycode,
- event->state,
- event->group,
- NULL, NULL, NULL, &consumed_modifiers);
+ upper = event->keyval;
+ accel_keyval = gdk_keyval_to_lower(upper);
- upper = event->keyval;
- accel_keyval = gdk_keyval_to_lower (upper);
- if (accel_keyval == GDK_ISO_Left_Tab)
- accel_keyval = GDK_Tab;
+ if (accel_keyval == GDK_ISO_Left_Tab)
+ {
+ accel_keyval = GDK_Tab;
+ }
+ /* Put shift back if it changed the case of the key, not otherwise. */
+ if (upper != accel_keyval && (consumed_modifiers & GDK_SHIFT_MASK))
+ {
+ consumed_modifiers &= ~(GDK_SHIFT_MASK);
+ }
+ egg_keymap_resolve_virtual_modifiers(gdk_keymap_get_default(),
+ EGG_VIRTUAL_NUM_LOCK_MASK |
+ EGG_VIRTUAL_SCROLL_LOCK_MASK |
+ EGG_VIRTUAL_LOCK_MASK,
+ &ignored_modifiers);
+
+ /* http://bugzilla.gnome.org/show_bug.cgi?id=139605
+ * mouse keys should effect keybindings */
+ ignored_modifiers |= GDK_BUTTON1_MASK |
+ GDK_BUTTON2_MASK |
+ GDK_BUTTON3_MASK |
+ GDK_BUTTON4_MASK |
+ GDK_BUTTON5_MASK;
+
+ /* filter consumed/ignored modifiers */
+ if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
+ {
+ accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
+ }
+ else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
+ {
+ accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
+ }
+ else
+ {
+ g_assert_not_reached();
+ }
- /* Put shift back if it changed the case of the key, not otherwise.
- */
- if (upper != accel_keyval &&
- (consumed_modifiers & GDK_SHIFT_MASK))
- {
- consumed_modifiers &= ~(GDK_SHIFT_MASK);
- }
+ if (accel_mods == 0 && accel_keyval == GDK_Escape)
+ {
+ goto out; /* cancel */
+ }
- egg_keymap_resolve_virtual_modifiers (gdk_keymap_get_default (),
- EGG_VIRTUAL_NUM_LOCK_MASK |
- EGG_VIRTUAL_SCROLL_LOCK_MASK |
- EGG_VIRTUAL_LOCK_MASK,
- &ignored_modifiers);
-
- /* http://bugzilla.gnome.org/show_bug.cgi?id=139605
- * mouse keys should effect keybindings */
- ignored_modifiers |= GDK_BUTTON1_MASK |
- GDK_BUTTON2_MASK |
- GDK_BUTTON3_MASK |
- GDK_BUTTON4_MASK |
- GDK_BUTTON5_MASK;
-
- /* filter consumed/ignored modifiers */
-
- if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
- accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
- else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
- accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
- else
- g_assert_not_reached ();
-
- if (accel_mods == 0 && accel_keyval == GDK_Escape)
- goto out; /* cancel */
-
- /* clear the accelerator on Backspace */
- if (accel_mods == 0 && accel_keyval == GDK_BackSpace)
- {
- cleared = TRUE;
- goto out;
- }
+ /* clear the accelerator on Backspace */
+ if (accel_mods == 0 && accel_keyval == GDK_BackSpace)
+ {
+ cleared = TRUE;
+ goto out;
+ }
- if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
- {
- if (!gtk_accelerator_valid (accel_keyval, accel_mods))
+ if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
{
- accel_keyval = 0;
- accel_mods = 0;
+ if (!gtk_accelerator_valid (accel_keyval, accel_mods))
+ {
+ accel_keyval = 0;
+ accel_mods = 0;
+ }
}
- }
- edited = TRUE;
- out:
- gdk_keyboard_ungrab (event->time);
- gdk_pointer_ungrab (event->time);
+ edited = TRUE;
- path = g_strdup (g_object_get_data (G_OBJECT (keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));
+ out:
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (keys->edit_widget));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (keys->edit_widget));
- keys->edit_widget = NULL;
- keys->grab_widget = NULL;
+ gdk_keyboard_ungrab(event->time);
+ gdk_pointer_ungrab(event->time);
- if (edited)
- {
- g_signal_emit_by_name (G_OBJECT (keys), "accel_edited", path,
- accel_keyval, accel_mods, event->hardware_keycode);
- }
- else if (cleared)
- {
- g_signal_emit_by_name (G_OBJECT (keys), "accel_cleared", path);
- }
+ path = g_strdup(g_object_get_data(G_OBJECT(keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));
+
+ gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(keys->edit_widget));
+ gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(keys->edit_widget));
+ keys->edit_widget = NULL;
+ keys->grab_widget = NULL;
- g_free (path);
- return TRUE;
+ if (edited)
+ {
+ g_signal_emit_by_name(G_OBJECT(keys), "accel_edited", path, accel_keyval, accel_mods, event->hardware_keycode);
+ }
+ else if (cleared)
+ {
+ g_signal_emit_by_name(G_OBJECT(keys), "accel_cleared", path);
+ }
+
+ g_free (path);
+ return TRUE;
}
-static void
-ungrab_stuff (GtkWidget *widget, gpointer data)
+static void ungrab_stuff(GtkWidget* widget, gpointer data)
{
- EggCellRendererKeys *keys = EGG_CELL_RENDERER_KEYS (data);
+ EggCellRendererKeys* keys = EGG_CELL_RENDERER_KEYS(data);
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+ gdk_pointer_ungrab(GDK_CURRENT_TIME);
- g_signal_handlers_disconnect_by_func (G_OBJECT (keys->grab_widget),
- G_CALLBACK (grab_key_callback), data);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(keys->grab_widget), G_CALLBACK(grab_key_callback), data);
}
-static void
-pointless_eventbox_start_editing (GtkCellEditable *cell_editable,
- GdkEvent *event)
+static void pointless_eventbox_start_editing(GtkCellEditable* cell_editable, GdkEvent* event)
{
- /* do nothing, because we are pointless */
+ /* do nothing, because we are pointless */
}
-static void
-pointless_eventbox_cell_editable_init (GtkCellEditableIface *iface)
+static void pointless_eventbox_cell_editable_init(GtkCellEditableIface* iface)
{
- iface->start_editing = pointless_eventbox_start_editing;
+ iface->start_editing = pointless_eventbox_start_editing;
}
static GType
@@ -623,73 +620,69 @@ egg_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
return GTK_CELL_EDITABLE (keys->edit_widget);
}
-void
-egg_cell_renderer_keys_set_accelerator (EggCellRendererKeys *keys,
- guint keyval,
- guint keycode,
- EggVirtualModifierType mask)
+void egg_cell_renderer_keys_set_accelerator(EggCellRendererKeys* keys, guint keyval, guint keycode, EggVirtualModifierType mask)
{
- char *text;
- gboolean changed;
+ char *text;
+ gboolean changed;
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
+ g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
- g_object_freeze_notify (G_OBJECT (keys));
+ g_object_freeze_notify (G_OBJECT (keys));
- changed = FALSE;
+ changed = FALSE;
- if (keyval != keys->accel_key)
- {
- keys->accel_key = keyval;
- g_object_notify (G_OBJECT (keys), "accel_key");
- changed = TRUE;
- }
+ if (keyval != keys->accel_key)
+ {
+ keys->accel_key = keyval;
+ g_object_notify (G_OBJECT (keys), "accel_key");
+ changed = TRUE;
+ }
- if (mask != keys->accel_mask)
- {
- keys->accel_mask = mask;
+ if (mask != keys->accel_mask)
+ {
+ keys->accel_mask = mask;
- g_object_notify (G_OBJECT (keys), "accel_mask");
- changed = TRUE;
- }
+ g_object_notify (G_OBJECT (keys), "accel_mask");
+ changed = TRUE;
+ }
- if (keycode != keys->keycode)
- {
- keys->keycode = keycode;
+ if (keycode != keys->keycode)
+ {
+ keys->keycode = keycode;
- g_object_notify (G_OBJECT (keys), "keycode");
- changed = TRUE;
- }
- g_object_thaw_notify (G_OBJECT (keys));
+ g_object_notify (G_OBJECT (keys), "keycode");
+ changed = TRUE;
+ }
- if (changed)
- {
- /* sync string to the key values */
- text = convert_keysym_state_to_string (keys->accel_key, keys->keycode, keys->accel_mask);
- g_object_set (keys, "text", text, NULL);
- g_free (text);
- }
+ g_object_thaw_notify (G_OBJECT (keys));
+
+ if (changed)
+ {
+ /* sync string to the key values */
+ text = convert_keysym_state_to_string (keys->accel_key, keys->keycode, keys->accel_mask);
+ g_object_set (keys, "text", text, NULL);
+ g_free (text);
+ }
}
-void
-egg_cell_renderer_keys_get_accelerator (EggCellRendererKeys *keys,
- guint *keyval,
- EggVirtualModifierType *mask)
+void egg_cell_renderer_keys_get_accelerator(EggCellRendererKeys* keys, guint* keyval, EggVirtualModifierType* mask)
{
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
+ g_return_if_fail(EGG_IS_CELL_RENDERER_KEYS(keys));
- if (keyval)
- *keyval = keys->accel_key;
+ if (keyval)
+ {
+ *keyval = keys->accel_key;
+ }
- if (mask)
- *mask = keys->accel_mask;
+ if (mask)
+ {
+ *mask = keys->accel_mask;
+ }
}
-void
-egg_cell_renderer_keys_set_accel_mode (EggCellRendererKeys *keys,
- EggCellRendererKeysMode accel_mode)
+void egg_cell_renderer_keys_set_accel_mode (EggCellRendererKeys* keys, EggCellRendererKeysMode accel_mode)
{
- g_return_if_fail (EGG_IS_CELL_RENDERER_KEYS (keys));
- keys->accel_mode = accel_mode;
- g_object_notify (G_OBJECT (keys), "accel_mode");
+ g_return_if_fail(EGG_IS_CELL_RENDERER_KEYS(keys));
+ keys->accel_mode = accel_mode;
+ g_object_notify(G_OBJECT(keys), "accel_mode");
}
diff --git a/capplets/keybindings/mate-keybinding-properties.c b/capplets/keybindings/mate-keybinding-properties.c
index fb6c8785..5155d445 100644
--- a/capplets/keybindings/mate-keybinding-properties.c
+++ b/capplets/keybindings/mate-keybinding-properties.c
@@ -82,10 +82,9 @@ static GtkWidget *custom_shortcut_dialog = NULL;
static GtkWidget *custom_shortcut_name_entry = NULL;
static GtkWidget *custom_shortcut_command_entry = NULL;
-static GtkWidget*
-_gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
+static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
{
- return GTK_WIDGET (gtk_builder_get_object (builder, name));
+ return GTK_WIDGET (gtk_builder_get_object (builder, name));
}
static GtkBuilder *
@@ -421,72 +420,78 @@ typedef struct {
gboolean found;
} KeyMatchData;
-static gboolean
-key_match (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+static gboolean key_match(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
{
- KeyMatchData *match_data = data;
- KeyEntry *element;
+ KeyMatchData* match_data = data;
+ KeyEntry* element;
- gtk_tree_model_get (model, iter,
- KEYENTRY_COLUMN, &element,
- -1);
+ gtk_tree_model_get(model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
- if (element && g_strcmp0 (element->mateconf_key, match_data->key) == 0)
- {
- match_data->found = TRUE;
- return TRUE;
- }
+ if (element && g_strcmp0(element->mateconf_key, match_data->key) == 0)
+ {
+ match_data->found = TRUE;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-static gboolean
-key_is_already_shown (GtkTreeModel *model, const KeyListEntry *entry)
+static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
{
- KeyMatchData data;
+ KeyMatchData data;
- data.key = entry->name;
- data.found = FALSE;
- gtk_tree_model_foreach (model, key_match, &data);
+ data.key = entry->name;
+ data.found = FALSE;
+ gtk_tree_model_foreach(model, key_match, &data);
- return data.found;
+ return data.found;
}
-static gboolean
-should_show_key (const KeyListEntry *entry)
+static gboolean should_show_key(const KeyListEntry* entry)
{
- int value;
- MateConfClient *client;
+ int value;
+ MateConfClient *client;
- if (entry->comparison == COMPARISON_NONE)
- return TRUE;
+ if (entry->comparison == COMPARISON_NONE)
+ {
+ return TRUE;
+ }
- g_return_val_if_fail (entry->key != NULL, FALSE);
+ g_return_val_if_fail(entry->key != NULL, FALSE);
- client = mateconf_client_get_default();
- value = mateconf_client_get_int (client, entry->key, NULL);
- g_object_unref (client);
+ client = mateconf_client_get_default();
+ value = mateconf_client_get_int (client, entry->key, NULL);
+ g_object_unref (client);
- switch (entry->comparison) {
- case COMPARISON_NONE:
- /* For compiler warnings */
- g_assert_not_reached ();
- return FALSE;
- case COMPARISON_GT:
- if (value > entry->value)
- return TRUE;
- break;
- case COMPARISON_LT:
- if (value < entry->value)
- return TRUE;
- break;
- case COMPARISON_EQ:
- if (value == entry->value)
- return TRUE;
- break;
- }
+ switch (entry->comparison)
+ {
+ case COMPARISON_NONE:
+ /* For compiler warnings */
+ g_assert_not_reached ();
+ return FALSE;
+ case COMPARISON_GT:
+ if (value > entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ case COMPARISON_LT:
+ if (value < entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ case COMPARISON_EQ:
+ if (value == entry->value)
+ {
+ return TRUE;
+ }
+ break;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -1015,73 +1020,78 @@ key_entry_controlling_key_changed (MateConfClient *client,
reload_key_entries (user_data);
}
-static gboolean
-cb_check_for_uniqueness (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- KeyEntry *new_key)
+static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
{
- KeyEntry *element;
+ KeyEntry* element;
- gtk_tree_model_get (new_key->model, iter,
- KEYENTRY_COLUMN, &element,
- -1);
+ gtk_tree_model_get (new_key->model, iter,
+ KEYENTRY_COLUMN, &element,
+ -1);
- /* no conflict for : blanks, different modifiers, or ourselves */
- if (element == NULL || new_key->mask != element->mask ||
- !strcmp (new_key->mateconf_key, element->mateconf_key))
- return FALSE;
+ /* no conflict for : blanks, different modifiers, or ourselves */
+ if (element == NULL || new_key->mask != element->mask ||
+ !strcmp (new_key->mateconf_key, element->mateconf_key))
+ {
+ return FALSE;
+ }
- if (new_key->keyval != 0) {
- if (new_key->keyval != element->keyval)
- return FALSE;
- } else if (element->keyval != 0 || new_key->keycode != element->keycode)
- return FALSE;
+ if (new_key->keyval != 0)
+ {
+ if (new_key->keyval != element->keyval)
+ {
+ return FALSE;
+ }
+ }
+ else if (element->keyval != 0 || new_key->keycode != element->keycode)
+ {
+ return FALSE;
+ }
- new_key->editable = FALSE;
- new_key->mateconf_key = element->mateconf_key;
- new_key->description = element->description;
- new_key->desc_mateconf_key = element->desc_mateconf_key;
- new_key->desc_editable = element->desc_editable;
- return TRUE;
+ new_key->editable = FALSE;
+ new_key->mateconf_key = element->mateconf_key;
+ new_key->description = element->description;
+ new_key->desc_mateconf_key = element->desc_mateconf_key;
+ new_key->desc_editable = element->desc_editable;
+
+ return TRUE;
}
static const guint forbidden_keyvals[] = {
- /* Navigation keys */
- GDK_Home,
- GDK_Left,
- GDK_Up,
- GDK_Right,
- GDK_Down,
- GDK_Page_Up,
- GDK_Page_Down,
- GDK_End,
- GDK_Tab,
-
- /* Return */
- GDK_KP_Enter,
- GDK_Return,
-
- GDK_space,
- GDK_Mode_switch
+ /* Navigation keys */
+ GDK_Home,
+ GDK_Left,
+ GDK_Up,
+ GDK_Right,
+ GDK_Down,
+ GDK_Page_Up,
+ GDK_Page_Down,
+ GDK_End,
+ GDK_Tab,
+
+ /* Return */
+ GDK_KP_Enter,
+ GDK_Return,
+
+ GDK_space,
+ GDK_Mode_switch
};
-static gboolean
-keyval_is_forbidden (guint keyval)
+static gboolean keyval_is_forbidden(guint keyval)
{
- guint i;
+ guint i;
- for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals); i++) {
- if (keyval == forbidden_keyvals[i])
- return TRUE;
- }
+ for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals); i++)
+ {
+ if (keyval == forbidden_keyvals[i])
+ {
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
-static void
-show_error (GtkWindow *parent,
- GError *err)
+static void show_error(GtkWindow* parent, GError* err)
{
GtkWidget *dialog;
@@ -1097,24 +1107,18 @@ show_error (GtkWindow *parent,
gtk_widget_destroy (dialog);
}
-static void
-accel_edited_callback (GtkCellRendererText *cell,
- const char *path_string,
- guint keyval,
- EggVirtualModifierType mask,
- guint keycode,
- gpointer data)
+static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
{
- MateConfClient *client;
- GtkTreeView *view = (GtkTreeView *)data;
- GtkTreeModel *model;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- KeyEntry *key_entry, tmp_key;
- GError *err = NULL;
- char *str;
+ MateConfClient* client;
+ GtkTreeView* view = (GtkTreeView*) data;
+ GtkTreeModel* model;
+ GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
+ GtkTreeIter iter;
+ KeyEntry* key_entry, tmp_key;
+ GError* err = NULL;
+ char* str;
- block_accels = FALSE;
+ block_accels = FALSE;
model = gtk_tree_view_get_model (view);
gtk_tree_model_get_iter (model, &iter, path);
@@ -1123,171 +1127,172 @@ accel_edited_callback (GtkCellRendererText *cell,
KEYENTRY_COLUMN, &key_entry,
-1);
- /* sanity check */
- if (key_entry == NULL)
- return;
-
- /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
- mask &= ~EGG_VIRTUAL_LOCK_MASK;
+ /* sanity check */
+ if (key_entry == NULL)
+ {
+ return;
+ }
- tmp_key.model = model;
- tmp_key.keyval = keyval;
- tmp_key.keycode = keycode;
- tmp_key.mask = mask;
- tmp_key.mateconf_key = key_entry->mateconf_key;
- tmp_key.description = NULL;
- tmp_key.editable = TRUE; /* kludge to stuff in a return flag */
+ /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
+ mask &= ~EGG_VIRTUAL_LOCK_MASK;
- if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
- gtk_tree_model_foreach (model,
- (GtkTreeModelForeachFunc) cb_check_for_uniqueness,
- &tmp_key);
+ tmp_key.model = model;
+ tmp_key.keyval = keyval;
+ tmp_key.keycode = keycode;
+ tmp_key.mask = mask;
+ tmp_key.mateconf_key = key_entry->mateconf_key;
+ tmp_key.description = NULL;
+ tmp_key.editable = TRUE; /* kludge to stuff in a return flag */
- /* Check for unmodified keys */
- if (tmp_key.mask == 0 && tmp_key.keycode != 0)
- {
- if ((tmp_key.keyval >= GDK_a && tmp_key.keyval <= GDK_z)
- || (tmp_key.keyval >= GDK_A && tmp_key.keyval <= GDK_Z)
- || (tmp_key.keyval >= GDK_0 && tmp_key.keyval <= GDK_9)
- || (tmp_key.keyval >= GDK_kana_fullstop && tmp_key.keyval <= GDK_semivoicedsound)
- || (tmp_key.keyval >= GDK_Arabic_comma && tmp_key.keyval <= GDK_Arabic_sukun)
- || (tmp_key.keyval >= GDK_Serbian_dje && tmp_key.keyval <= GDK_Cyrillic_HARDSIGN)
- || (tmp_key.keyval >= GDK_Greek_ALPHAaccent && tmp_key.keyval <= GDK_Greek_omega)
- || (tmp_key.keyval >= GDK_hebrew_doublelowline && tmp_key.keyval <= GDK_hebrew_taf)
- || (tmp_key.keyval >= GDK_Thai_kokai && tmp_key.keyval <= GDK_Thai_lekkao)
- || (tmp_key.keyval >= GDK_Hangul && tmp_key.keyval <= GDK_Hangul_Special)
- || (tmp_key.keyval >= GDK_Hangul_Kiyeog && tmp_key.keyval <= GDK_Hangul_J_YeorinHieuh)
- || keyval_is_forbidden (tmp_key.keyval)) {
- GtkWidget *dialog;
- char *name;
-
- name = binding_name (keyval, keycode, mask, TRUE);
-
- dialog =
- gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
- "Please try with a key such as Control, Alt or Shift at the same time."),
- name);
-
- g_free (name);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- /* set it back to its previous value. */
- egg_cell_renderer_keys_set_accelerator
- (EGG_CELL_RENDERER_KEYS (cell),
- key_entry->keyval, key_entry->keycode, key_entry->mask);
- return;
- }
- }
+ if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
+ {
+ gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
+ }
- /* flag to see if the new accelerator was in use by something */
- if (!tmp_key.editable)
+ /* Check for unmodified keys */
+ if (tmp_key.mask == 0 && tmp_key.keycode != 0)
{
- GtkWidget *dialog;
- char *name;
- int response;
-
- name = binding_name (keyval, keycode, mask, TRUE);
-
- dialog =
- gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
+ if ((tmp_key.keyval >= GDK_a && tmp_key.keyval <= GDK_z)
+ || (tmp_key.keyval >= GDK_A && tmp_key.keyval <= GDK_Z)
+ || (tmp_key.keyval >= GDK_0 && tmp_key.keyval <= GDK_9)
+ || (tmp_key.keyval >= GDK_kana_fullstop && tmp_key.keyval <= GDK_semivoicedsound)
+ || (tmp_key.keyval >= GDK_Arabic_comma && tmp_key.keyval <= GDK_Arabic_sukun)
+ || (tmp_key.keyval >= GDK_Serbian_dje && tmp_key.keyval <= GDK_Cyrillic_HARDSIGN)
+ || (tmp_key.keyval >= GDK_Greek_ALPHAaccent && tmp_key.keyval <= GDK_Greek_omega)
+ || (tmp_key.keyval >= GDK_hebrew_doublelowline && tmp_key.keyval <= GDK_hebrew_taf)
+ || (tmp_key.keyval >= GDK_Thai_kokai && tmp_key.keyval <= GDK_Thai_lekkao)
+ || (tmp_key.keyval >= GDK_Hangul && tmp_key.keyval <= GDK_Hangul_Special)
+ || (tmp_key.keyval >= GDK_Hangul_Kiyeog && tmp_key.keyval <= GDK_Hangul_J_YeorinHieuh)
+ || keyval_is_forbidden (tmp_key.keyval))
+ {
+
+ GtkWidget *dialog;
+ char *name;
+
+ name = binding_name (keyval, keycode, mask, TRUE);
+
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_CANCEL,
- _("The shortcut \"%s\" is already used for\n\"%s\""),
- name, tmp_key.description ?
- tmp_key.description : tmp_key.mateconf_key);
- g_free (name);
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
- "will be disabled."),
- key_entry->description ?
- key_entry->description : key_entry->mateconf_key,
- tmp_key.description ?
- tmp_key.description : tmp_key.mateconf_key);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Reassign"),
- GTK_RESPONSE_ACCEPT);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
+ "Please try with a key such as Control, Alt or Shift at the same time."),
+ name);
+
+ g_free (name);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ /* set it back to its previous value. */
+ egg_cell_renderer_keys_set_accelerator(
+ EGG_CELL_RENDERER_KEYS(cell),
+ key_entry->keyval,
+ key_entry->keycode,
+ key_entry->mask);
+ return;
+ }
+ }
- if (response == GTK_RESPONSE_ACCEPT)
+ /* flag to see if the new accelerator was in use by something */
+ if (!tmp_key.editable)
{
- MateConfClient *client;
-
- client = mateconf_client_get_default ();
+ GtkWidget* dialog;
+ char* name;
+ int response;
+
+ name = binding_name(keyval, keycode, mask, TRUE);
+
+ dialog = gtk_message_dialog_new(
+ GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("The shortcut \"%s\" is already used for\n\"%s\""),
+ name,
+ tmp_key.description ? tmp_key.description : tmp_key.mateconf_key);
+ g_free (name);
+
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
+ "will be disabled."),
+ key_entry->description ? key_entry->description : key_entry->mateconf_key,
+ tmp_key.description ? tmp_key.description : tmp_key.mateconf_key);
+
+ gtk_dialog_add_button(GTK_DIALOG (dialog), _("_Reassign"), GTK_RESPONSE_ACCEPT);
+
+ gtk_dialog_set_default_response(GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ MateConfClient* client;
+
+ client = mateconf_client_get_default ();
+
+ mateconf_client_set_string(
+ client,
+ tmp_key.mateconf_key,
+ "",
+ &err);
+
+ if (err != NULL)
+ {
+ show_error(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+ g_object_unref (client);
+ return;
+ }
+
+ str = binding_name (keyval, keycode, mask, FALSE);
+ mateconf_client_set_string (client, key_entry->mateconf_key, str, &err);
+
+ if (err != NULL)
+ {
+ show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+
+ /* reset the previous shortcut */
+ mateconf_client_set_string (client, tmp_key.mateconf_key, str, NULL);
+ }
+
+ g_free (str);
+ g_object_unref (client);
+ }
+ else
+ {
+ /* set it back to its previous value. */
+ egg_cell_renderer_keys_set_accelerator(
+ EGG_CELL_RENDERER_KEYS(cell),
+ key_entry->keyval,
+ key_entry->keycode,
+ key_entry->mask);
+ }
+
+ return;
+ }
- mateconf_client_set_string (client,
- tmp_key.mateconf_key,
- "", &err);
+ str = binding_name (keyval, keycode, mask, FALSE);
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- err);
- g_error_free (err);
- g_object_unref (client);
- return;
- }
+ client = mateconf_client_get_default ();
+ mateconf_client_set_string(
+ client,
+ key_entry->mateconf_key,
+ str,
+ &err);
- str = binding_name (keyval, keycode, mask, FALSE);
- mateconf_client_set_string (client,
- key_entry->mateconf_key,
- str, &err);
+ g_free (str);
+ g_object_unref (client);
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- err);
- g_error_free (err);
-
- /* reset the previous shortcut */
- mateconf_client_set_string (client,
- tmp_key.mateconf_key,
- str, NULL);
- }
-
- g_free (str);
- g_object_unref (client);
- }
- else
+ if (err != NULL)
{
- /* set it back to its previous value. */
- egg_cell_renderer_keys_set_accelerator (EGG_CELL_RENDERER_KEYS (cell),
- key_entry->keyval,
- key_entry->keycode,
- key_entry->mask);
+ show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
+ g_error_free (err);
+ key_entry->editable = FALSE;
}
-
- return;
- }
-
- str = binding_name (keyval, keycode, mask, FALSE);
-
- client = mateconf_client_get_default ();
- mateconf_client_set_string (client,
- key_entry->mateconf_key,
- str,
- &err);
- g_free (str);
- g_object_unref (client);
-
- if (err != NULL)
- {
- show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), err);
- g_error_free (err);
- key_entry->editable = FALSE;
- }
}
static void
@@ -1733,16 +1738,14 @@ start_editing_cb (GtkTreeView *tree_view,
/* this handler is used to keep accels from activating while the user
* is assigning a new shortcut so that he won't accidentally trigger one
* of the widgets */
-static gboolean
-maybe_block_accels (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
+static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
{
- if (block_accels)
- {
- return gtk_window_propagate_key_event (GTK_WINDOW (widget), event);
- }
- return FALSE;
+ if (block_accels)
+ {
+ return gtk_window_propagate_key_event(GTK_WINDOW(widget), event);
+ }
+
+ return FALSE;
}
static void
diff --git a/capplets/keyboard/mate-keyboard-properties-xkb.c b/capplets/keyboard/mate-keyboard-properties-xkb.c
index 3316b4d4..6df6b16a 100644
--- a/capplets/keyboard/mate-keyboard-properties-xkb.c
+++ b/capplets/keyboard/mate-keyboard-properties-xkb.c
@@ -170,7 +170,7 @@ setup_xkb_tabs (GtkBuilder * dialog, MateConfChangeSet * changeset)
xkb_mateconf_client = mateconf_client_get_default ();
- engine = xkl_engine_get_instance (GDK_DISPLAY ());
+ engine = xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
config_registry = xkl_config_registry_get_instance (engine);
matekbd_desktop_config_init (&desktop_config, xkb_mateconf_client,
diff --git a/capplets/mouse/mate-mouse-properties.c b/capplets/mouse/mate-mouse-properties.c
index 8e9824b9..35e6e0f8 100644
--- a/capplets/mouse/mate-mouse-properties.c
+++ b/capplets/mouse/mate-mouse-properties.c
@@ -88,11 +88,11 @@ get_default_mouse_info (int *default_numerator, int *default_denominator, int *d
int tmp_num, tmp_den, tmp_threshold;
/* Query X for the default value */
- XGetPointerControl (GDK_DISPLAY (), &numerator, &denominator,
+ XGetPointerControl (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &numerator, &denominator,
&threshold);
- XChangePointerControl (GDK_DISPLAY (), True, True, -1, -1, -1);
- XGetPointerControl (GDK_DISPLAY (), &tmp_num, &tmp_den, &tmp_threshold);
- XChangePointerControl (GDK_DISPLAY (), True, True, numerator, denominator, threshold);
+ XChangePointerControl (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), True, True, -1, -1, -1);
+ XGetPointerControl (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &tmp_num, &tmp_den, &tmp_threshold);
+ XChangePointerControl (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), True, True, numerator, denominator, threshold);
if (default_numerator)
*default_numerator = tmp_num;
@@ -338,23 +338,23 @@ synaptics_check_capabilities (GtkBuilder *dialog)
unsigned long nitems, bytes_after;
unsigned char *data;
- prop = XInternAtom (GDK_DISPLAY (), "Synaptics Capabilities", True);
+ prop = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "Synaptics Capabilities", True);
if (!prop)
return;
- devicelist = XListInputDevices (GDK_DISPLAY (), &numdevices);
+ devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &numdevices);
for (i = 0; i < numdevices; i++) {
if (devicelist[i].use != IsXExtensionPointer)
continue;
gdk_error_trap_push ();
- XDevice *device = XOpenDevice (GDK_DISPLAY (),
+ XDevice *device = XOpenDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
devicelist[i].id);
if (gdk_error_trap_pop ())
continue;
gdk_error_trap_push ();
- if ((XGetDeviceProperty (GDK_DISPLAY (), device, prop, 0, 2, False,
+ if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device, prop, 0, 2, False,
XA_INTEGER, &realtype, &realformat, &nitems,
&bytes_after, &data) == Success) && (realtype != None)) {
/* Property data is booleans for has_left, has_middle,
@@ -371,7 +371,7 @@ synaptics_check_capabilities (GtkBuilder *dialog)
}
gdk_error_trap_pop ();
- XCloseDevice (GDK_DISPLAY (), device);
+ XCloseDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device);
}
XFreeDeviceList (devicelist);
#endif
@@ -391,30 +391,30 @@ find_synaptics (void)
XExtensionVersion *version;
/* Input device properties require version 1.5 or higher */
- version = XGetExtensionVersion (GDK_DISPLAY (), "XInputExtension");
+ version = XGetExtensionVersion (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "XInputExtension");
if (!version->present ||
(version->major_version * 1000 + version->minor_version) < 1005) {
XFree (version);
return False;
}
- prop = XInternAtom (GDK_DISPLAY (), "Synaptics Off", True);
+ prop = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "Synaptics Off", True);
if (!prop)
return False;
- devicelist = XListInputDevices (GDK_DISPLAY (), &numdevices);
+ devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &numdevices);
for (i = 0; i < numdevices; i++) {
if (devicelist[i].use != IsXExtensionPointer)
continue;
gdk_error_trap_push();
- XDevice *device = XOpenDevice (GDK_DISPLAY (),
+ XDevice *device = XOpenDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
devicelist[i].id);
if (gdk_error_trap_pop ())
continue;
gdk_error_trap_push ();
- if ((XGetDeviceProperty (GDK_DISPLAY (), device, prop, 0, 1, False,
+ if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device, prop, 0, 1, False,
XA_INTEGER, &realtype, &realformat, &nitems,
&bytes_after, &data) == Success) && (realtype != None)) {
XFree (data);
@@ -422,7 +422,7 @@ find_synaptics (void)
}
gdk_error_trap_pop ();
- XCloseDevice (GDK_DISPLAY (), device);
+ XCloseDevice (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), device);
if (ret)
break;