[anjal] Make Anjal usable on a desktop. Allow resize and save window sizes



commit 9debe98eff7f24eb02c4f3821db006142f06791b
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Mon Aug 17 09:17:15 2009 +0530

    Make Anjal usable on a desktop. Allow resize and save window sizes

 configure.ac          |    7 +++++++
 src/Makefile.am       |   12 +++++++++++-
 src/anjal.schemas.in  |   34 ++++++++++++++++++++++++++++++++++
 src/mail-decoration.c |   36 +++++++++++++++++++++++++++++++++---
 src/mail-shell.c      |    1 -
 5 files changed, 85 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ed44d56..22301e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,6 +123,13 @@ else
    AM_CONDITIONAL(ENABLE_ANERLEY, false)
 fi
 
+dnl ***********
+dnl GConf stuff
+dnl ***********
+AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
+AM_GCONF_SOURCE_2
+
+
 AC_OUTPUT([
 Makefile
 art/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 9596889..5748db0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,4 +99,14 @@ anjal_LDADD = $(ANJAL_LIBS) \
 	-L$(evolutioncomponentdir) -levolution-mail-shared $(MOZ_ADD_LIBS)
 
 
-EXTRA_DIST = $(glade_DATA)
+EXTRA_DIST = $(glade_DATA) \
+	     $(schema_in_files)
+
+
+# GConf
+
+schemadir   = $(GCONF_SCHEMA_FILE_DIR)
+schema_in_files = anjal.schemas.in
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+ INTLTOOL_SCHEMAS_RULE@
+
diff --git a/src/anjal.schemas.in b/src/anjal.schemas.in
new file mode 100644
index 0000000..a7c75c7
--- /dev/null
+++ b/src/anjal.schemas.in
@@ -0,0 +1,34 @@
+<gconfschemafile>
+  <schemalist>
+
+    <schema>
+      <key>/schemas/apps/anjal/window_width</key>
+      <applyto>/apps/anjal/window_width</applyto>
+      <owner>anjal</owner>
+      <type>int</type>
+      <default>1024</default>
+      <locale name="C">
+        <short>Anjal window width</short>
+        <long>
+		Width of Anjal window.
+        </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/anjal/window_height</key>
+      <applyto>/apps/anjal/window_height</applyto>
+      <owner>anjal</owner>
+      <type>int</type>
+      <default>500</default>
+      <locale name="C">
+        <short>Anjal window height</short>
+        <long>
+		Height of Anjal window.
+        </long>
+      </locale>
+    </schema>
+
+
+  </schemalist>
+</gconfschemafile>
diff --git a/src/mail-decoration.c b/src/mail-decoration.c
index 416694d..9eebbe8 100644
--- a/src/mail-decoration.c
+++ b/src/mail-decoration.c
@@ -27,6 +27,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#include <gconf/gconf-client.h>
 
 #define MAIL_DECORATION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MAIL_DECORATION_TYPE, MailDecorationPrivate))
 
@@ -41,6 +42,9 @@ struct _MailDecorationPrivate
 	gboolean check_window;
 	gboolean can_resize;
 	gboolean full_screen;
+
+	int window_width;
+	int window_height;
 };
 
 static GObjectClass *parent_class = NULL;
@@ -215,7 +219,22 @@ md_leave_event (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 static void                
 md_size_allocate_event (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
 {
+	int width=1024, height=500;
+	MailDecoration *md = (MailDecoration *)user_data;
+
 	gtk_widget_queue_draw (widget);
+	gtk_window_get_size ((GtkWindow *)widget, &width, &height);
+	if (width != md->priv->window_width || height != md->priv->window_height) {
+		GConfClient *client = gconf_client_get_default ();
+		
+		md->priv->window_height = height;
+		md->priv->window_width = width;
+		gconf_client_set_int (client, "/apps/anjal/window_width", width, NULL);
+		gconf_client_set_int (client, "/apps/anjal/window_height", height, NULL);
+		printf("Setting %d %d\n", width, height);
+		g_object_unref(client);
+	}
+
 }
 
 static gboolean            
@@ -234,6 +253,7 @@ md_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_d
         update_cursor (md, x, y, TRUE);
         if (md->priv->resizing && event->button == 1 && event->type != GDK_2BUTTON_PRESS) {
 		gtk_window_begin_resize_drag ((GtkWindow *)widget, md->priv->last_edge, 1, x_root, y_root, event->time);
+
         } else if ((md->priv->resizing && event->button == 2 && event->type != GDK_2BUTTON_PRESS) ||
                 (event->button == 1 && y <= md->priv->top_height && event->type != GDK_2BUTTON_PRESS)) {
                 gtk_window_begin_move_drag ((GtkWindow *)widget, event->button, x_root, y_root, event->time);
@@ -257,9 +277,8 @@ md_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user
 	MailDecoration *md = (MailDecoration *)user_data;
 
 	md_translate_position (event->window, event->x, event->y, &x, &y, (GtkWidget *)md->window);
- 
 	if (md->priv->resizing) {
-		update_cursor (md, x, y, TRUE);
+		update_cursor (md, x, y, TRUE);		
 	}
 
 	return FALSE;
@@ -268,6 +287,16 @@ md_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user
 MailDecoration* mail_decoration_new(GtkWindow *window)
 {
 	MailDecoration *md = g_object_new(mail_decoration_get_type(), NULL);
+	GConfClient *client = gconf_client_get_default ();
+	int width, height;
+
+	md->priv->window_width = width = gconf_client_get_int (client, "/apps/anjal/window_width", NULL);
+	if (!width)
+		md->priv->window_width = width = 1024;
+	md->priv->window_height = height = gconf_client_get_int (client, "/apps/anjal/window_height", NULL);
+	if (!height)
+		md->priv->window_height = height = 500;
+	g_object_unref (client);
 
 	md->window = window;
 	gtk_window_set_decorated (window, FALSE);
@@ -283,7 +312,8 @@ MailDecoration* mail_decoration_new(GtkWindow *window)
 	g_signal_connect (window, "button-press-event", G_CALLBACK(md_button_press_event), md);
 	g_signal_connect (window, "button-release-event", G_CALLBACK(md_button_release_event), md);
 	g_signal_connect (window, "size-allocate", G_CALLBACK(md_size_allocate_event), md);
-
+	gtk_window_set_default_size ((GtkWindow *)window , width, height);/* We officiall should support 800x600 */
+	
 	return md;
 }
 
diff --git a/src/mail-shell.c b/src/mail-shell.c
index fcfe2ff..592a07d 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -437,7 +437,6 @@ mail_shell_construct (MailShell *shell)
 		 gtk_window_set_decorated ((GtkWindow *)shell, FALSE);
 	} else  {
 		mail_decoration_new ((GtkWindow *)shell);
-		gtk_window_set_default_size ((GtkWindow *)shell, 1024, 500);/* We officiall should support 800x600 */
 	}
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]