[nautilus-actions] Fix position and size of LegendDialog
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Subject: [nautilus-actions] Fix position and size of LegendDialog
- Date: Tue, 14 Jul 2009 18:48:30 +0000 (UTC)
commit a2cf987cc8aacb0194ff92637540ff671b38d096
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Jun 30 23:52:42 2009 +0200
Fix position and size of LegendDialog
src/nact/nact-iprefs.c | 74 ++++++++++++++++++++++------------
src/nact/nact-iprefs.h | 5 ++-
src/nact/nact-iprofile-conditions.c | 5 +-
src/nact/nautilus-actions-config.ui | 1 -
4 files changed, 55 insertions(+), 30 deletions(-)
---
diff --git a/src/nact/nact-iprefs.c b/src/nact/nact-iprefs.c
index 358c32e..f448a9b 100644
--- a/src/nact/nact-iprefs.c
+++ b/src/nact/nact-iprefs.c
@@ -133,31 +133,41 @@ interface_base_finalize( NactIPrefsInterface *klass )
*
* @window: this NactWindow-derived window.
*
- * @code: the IPrefs identifiant of the window
- *
* A window position is stored as a list of integers "x,y,width,height".
*/
void
nact_iprefs_position_window( NactWindow *window )
{
- static const gchar *thisfn = "nact_iprefs_position_window";
-
gchar *key = v_get_iprefs_window_id( window );
if( key ){
+ GtkWindow *toplevel = base_window_get_toplevel_widget( BASE_WINDOW( window ));
+ nact_iprefs_position_named_window( window, toplevel, key );
+ g_free( key );
+ }
+}
- GSList *list = read_key_listint( window, key );
- if( list ){
+/**
+ * Position the specified window on the screen.
+ *
+ * @window: this NactWindow-derived window.
+ *
+ * @name: the name of the window
+ */
+void
+nact_iprefs_position_named_window( NactWindow *window, GtkWindow *toplevel, const gchar *key )
+{
+ static const gchar *thisfn = "nact_iprefs_position_named_window";
- gint x=0, y=0, width=0, height=0;
- listint_to_position( window, list, &x, &y, &width, &height );
- g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
- free_listint( list );
+ GSList *list = read_key_listint( window, key );
+ if( list ){
- GtkWindow *toplevel = base_window_get_toplevel_widget( BASE_WINDOW( window ));
- gtk_window_move( toplevel, x, y );
- gtk_window_resize( toplevel, width, height );
- }
- g_free( key );
+ gint x=0, y=0, width=0, height=0;
+ listint_to_position( window, list, &x, &y, &width, &height );
+ g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
+ free_listint( list );
+
+ gtk_window_move( toplevel, x, y );
+ gtk_window_resize( toplevel, width, height );
}
}
@@ -171,24 +181,36 @@ nact_iprefs_position_window( NactWindow *window )
void
nact_iprefs_save_window_position( NactWindow *window )
{
- static const gchar *thisfn = "nact_iprefs_save_window_position";
-
gchar *key = v_get_iprefs_window_id( window );
if( key ){
- gint x, y, width, height;
-
GtkWindow *toplevel = base_window_get_toplevel_widget( BASE_WINDOW( window ));
- gtk_window_get_position( toplevel, &x, &y );
- gtk_window_get_size( toplevel, &width, &height );
- g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
-
- GSList *list = position_to_listint( window, x, y, width, height );
- write_key_listint( window, key, list );
- free_listint( list );
+ nact_iprefs_save_named_window_position( window, toplevel, key );
g_free( key );
}
}
+/**
+ * Save the position of the specified window.
+ *
+ * @window: this NactWindow-derived window.
+ *
+ * @key: the name of the window
+ */
+void
+nact_iprefs_save_named_window_position( NactWindow *window, GtkWindow *toplevel, const gchar *key )
+{
+ static const gchar *thisfn = "nact_iprefs_save_named_window_position";
+ gint x, y, width, height;
+
+ gtk_window_get_position( toplevel, &x, &y );
+ gtk_window_get_size( toplevel, &width, &height );
+ g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
+
+ GSList *list = position_to_listint( window, x, y, width, height );
+ write_key_listint( window, key, list );
+ free_listint( list );
+}
+
static gchar *
v_get_iprefs_window_id( NactWindow *window )
{
diff --git a/src/nact/nact-iprefs.h b/src/nact/nact-iprefs.h
index bad0417..b90f5d2 100644
--- a/src/nact/nact-iprefs.h
+++ b/src/nact/nact-iprefs.h
@@ -39,6 +39,7 @@
*/
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "nact-window.h"
@@ -65,10 +66,12 @@ typedef struct {
GType nact_iprefs_get_type( void );
void nact_iprefs_position_window( NactWindow *window );
+void nact_iprefs_position_named_window( NactWindow *window, GtkWindow *toplevel, const gchar *name );
+
void nact_iprefs_save_window_position( NactWindow *window );
+void nact_iprefs_save_named_window_position( NactWindow *window, GtkWindow *toplevel, const gchar *name );
/* .. */
-#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
typedef struct _NactPreferences NactPreferences;
diff --git a/src/nact/nact-iprofile-conditions.c b/src/nact/nact-iprofile-conditions.c
index 9bc9b74..8e6e800 100644
--- a/src/nact/nact-iprofile-conditions.c
+++ b/src/nact/nact-iprofile-conditions.c
@@ -40,6 +40,7 @@
#include <common/na-utils.h>
#include "nact-iprofile-conditions.h"
+#include "nact-iprefs.h"
/* private interface data
*/
@@ -563,7 +564,6 @@ on_legend_clicked( GtkButton *button, gpointer user_data )
}
}
-/* TODO: get back the last position saved */
static void
show_legend_dialog( NactWindow *window )
{
@@ -573,14 +573,15 @@ show_legend_dialog( NactWindow *window )
GtkWindow *toplevel = base_window_get_toplevel_widget( BASE_WINDOW( window ));
gtk_window_set_transient_for( GTK_WINDOW( legend_dialog ), toplevel );
+ nact_iprefs_position_named_window( window, legend_dialog, "legend-dialog" );
gtk_widget_show( GTK_WIDGET( legend_dialog ));
}
-/* TODO: save the current position */
static void
hide_legend_dialog( NactWindow *window )
{
GtkWindow *legend_dialog = get_legend_dialog( window );
+ nact_iprefs_save_named_window_position( window, legend_dialog, "legend-dialog" );
gtk_widget_hide( GTK_WIDGET( legend_dialog ));
/* set the legend button state consistent for when the dialog is
diff --git a/src/nact/nautilus-actions-config.ui b/src/nact/nautilus-actions-config.ui
index b817dde..5d6b747 100644
--- a/src/nact/nautilus-actions-config.ui
+++ b/src/nact/nautilus-actions-config.ui
@@ -1020,7 +1020,6 @@
</object>
<object class="GtkWindow" id="LegendDialog">
<property name="resizable">False</property>
- <property name="window_position">mouse</property>
<property name="type_hint">dialog</property>
<child>
<object class="GtkVBox" id="vbox11">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]