[metacity/matching] move stuff into window.c (will clean up later)
- From: Thomas James Alexander Thurman <tthurman src gnome org>
- To: svn-commits-list gnome org
- Subject: [metacity/matching] move stuff into window.c (will clean up later)
- Date: Fri, 10 Jul 2009 13:32:53 +0000 (UTC)
commit b9c9711a379d74f83644d4b3a8b3d452a1d2eab9
Author: Thomas Thurman <tthurman gnome org>
Date: Fri Jul 10 08:24:59 2009 -0400
move stuff into window.c (will clean up later)
src/core/matching.c | 86 +--------------------------------------------
src/core/window.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 85 deletions(-)
---
diff --git a/src/core/matching.c b/src/core/matching.c
index 1888b12..ee8bf0c 100644
--- a/src/core/matching.c
+++ b/src/core/matching.c
@@ -22,93 +22,9 @@
*/
#include "matching.h"
+#include "constraints.h"
#include "window-private.h"
-/**
- * We currently keep this information in a GKeyFile.
- * This is just for an example and may change.
- */
-GKeyFile *matching_keyfile = NULL;
-
-static void
-load_matching_data (void)
-{
- if (matching_keyfile)
- return;
-
- /* load it, or... (stub) */
- matching_keyfile = g_key_file_new ();
- /* FIXME: would be helpful to add a leading comment */
-}
-
-static gchar*
-get_window_role (MetaWindow *window)
-{
- if (window->role)
- return window->role;
- else if (window->title) /* hacky fallback */
- return window->title;
- else /* give up */
- return NULL;
-}
-
-void
-meta_matching_load_from_role (MetaWindow *window)
-{
- gint x, y, w, h;
- gchar *role = get_window_role (window);
-
- if (!role)
- return;
-
- load_matching_data ();
-
- /* FIXME error checking */
- x = g_key_file_get_integer (matching_keyfile, role, "x", NULL);
- y = g_key_file_get_integer (matching_keyfile, role, "y", NULL);
- w = g_key_file_get_integer (matching_keyfile, role, "w", NULL);
- h = g_key_file_get_integer (matching_keyfile, role, "h", NULL);
-
-
-}
-
-void
-meta_matching_save_to_role (MetaWindow *window)
-{
- gint x, y, w, h;
- gchar *role = get_window_role (window);
-
- if (!role)
- return;
-
- load_matching_data ();
-
- meta_window_get_geometry (window, &x, &y, &w, &h);
-
- g_key_file_set_integer (matching_keyfile, role, "x", x);
- g_key_file_set_integer (matching_keyfile, role, "y", y);
- g_key_file_set_integer (matching_keyfile, role, "w", w);
- g_key_file_set_integer (matching_keyfile, role, "h", h);
-
- meta_matching_save_all ();
-}
-
-void
-meta_matching_save_all (void)
-{
- char *data = NULL;
-
- load_matching_data ();
-
- data = g_key_file_to_data (matching_keyfile, NULL, NULL);
-
- g_file_set_contents ("/tmp/metacity-matching.conf",
- data,
- -1,
- NULL);
-
- g_free (data);
-}
/* eof matching.c */
diff --git a/src/core/window.c b/src/core/window.c
index c4a93e9..b5ae7f8 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8147,3 +8147,100 @@ meta_window_get_xwindow (MetaWindow *window)
{
return window->xwindow;
}
+
+/*
+ * Window matching
+ */
+
+/**
+ * We currently keep this information in a GKeyFile.
+ * It is global.
+ * This is just for an example and may change.
+ */
+GKeyFile *matching_keyfile = NULL;
+
+static void
+load_matching_data (void)
+{
+ if (matching_keyfile)
+ return;
+
+ /* load it, or... (stub) */
+ matching_keyfile = g_key_file_new ();
+ /* FIXME: would be helpful to add a leading comment */
+}
+
+static gchar*
+get_window_role (MetaWindow *window)
+{
+ if (window->role)
+ return window->role;
+ else if (window->title) /* hacky fallback */
+ return window->title;
+ else /* give up */
+ return NULL;
+}
+
+void
+meta_matching_load_from_role (MetaWindow *window)
+{
+ gint x, y, w, h;
+ gchar *role = get_window_role (window);
+
+ if (!role)
+ return;
+
+ load_matching_data ();
+
+ /* FIXME error checking */
+ x = g_key_file_get_integer (matching_keyfile, role, "x", NULL);
+ y = g_key_file_get_integer (matching_keyfile, role, "y", NULL);
+ w = g_key_file_get_integer (matching_keyfile, role, "w", NULL);
+ h = g_key_file_get_integer (matching_keyfile, role, "h", NULL);
+
+ meta_window_move_resize_internal (window,
+ META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION,
+ 0,
+ x, y, w, h);
+
+}
+
+void
+meta_matching_save_to_role (MetaWindow *window)
+{
+ gint x, y, w, h;
+ gchar *role = get_window_role (window);
+
+ if (!role)
+ return;
+
+ load_matching_data ();
+
+ meta_window_get_geometry (window, &x, &y, &w, &h);
+
+ g_key_file_set_integer (matching_keyfile, role, "x", x);
+ g_key_file_set_integer (matching_keyfile, role, "y", y);
+ g_key_file_set_integer (matching_keyfile, role, "w", w);
+ g_key_file_set_integer (matching_keyfile, role, "h", h);
+
+ meta_matching_save_all ();
+}
+
+void
+meta_matching_save_all (void)
+{
+ char *data = NULL;
+
+ load_matching_data ();
+
+ data = g_key_file_to_data (matching_keyfile, NULL, NULL);
+
+ g_file_set_contents ("/tmp/metacity-matching.conf",
+ data,
+ -1,
+ NULL);
+
+ g_free (data);
+}
+
+/* eof window.c */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]