summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Harper <jsh@eazel.com>2000-12-22 22:57:28 +0000
committerJohn Harper <jsh@src.gnome.org>2000-12-22 22:57:28 +0000
commit1b76518ed6486501f25b07abfbc60e489e5345fd (patch)
treee7b54ef57a7c1c9c63f8f474c056a0457cda6bc9
parent632ba58da933a54f5d43e33cba6be4546948cc1d (diff)
downloadnautilus-1b76518ed6486501f25b07abfbc60e489e5345fd.tar.gz
reviewed by: Darin Adler <darin@eazel.com>
2000-12-21 John Harper <jsh@eazel.com> reviewed by: Darin Adler <darin@eazel.com> Work to allow geometry of initial window to be specified on command line. Fixes bug #5135 * src/nautilus-shell.c (open_window): new arg `geometry'. When non-null, use nautilus_gtk_window_set_initial_geometry_from_string to affect the geometry of the unmapped window (corba_open_default_window, corba_open_windows): new arg, `geometry', passed to open_window () if a non-null string * src/nautilus-shell-interface.idl (open_windows, open_default_window): added `geometry' parameter. Pass a zero-length string to show no specified geometry * src/nautilus-main.c (main): new option `--geometry=GEOMETRY'. Pass the value to nautilus_application_startup (). This option is only allowed when no more than one URI is given on the command line (to prevent multiple windows appearing on top of one another) * src/nautilus-application.c, src/nautilus-application.h (nautilus_application_startup): added parameter `geometry', a string describing the geometry to give any created windows * src/nautilus-first-time-druid.c (druid_finished): pass null geometry parameter to nautilus_application_startup () * libnautilus/nautilus-gdk-extensions.c, libnautilus/nautilus-gdk-extensions.h (NautilusGdkGeometryFlags, nautilus_gdk_parse_geometry): a wrapper for XParseGeometry () and associated bit definitions. Required since gnome_parse_geometry () offers no reliable way of detecting which of the geometry components were parsed successfully * libnautilus/nautilus-gtk-extensions.c, libnautilus/nautilus-gtk-extensions.h (nautilus_gtk_window_set_initial_geometry): takes an extra parameter, a NautilusGdkGeometryFlags value specifying which of the geometry parameters are valid (nautilus_gtk_window_set_initial_geometry_from_string): changed to allow the geometry string to specify one or both of position and dimensions. Also doesn't use g_return_if_fail to test for validity of input string (since it may come from the user), instead just use the parseable parts of the geometry string
-rw-r--r--ChangeLog51
-rw-r--r--libnautilus-extensions/nautilus-gdk-extensions.c42
-rw-r--r--libnautilus-extensions/nautilus-gdk-extensions.h21
-rw-r--r--libnautilus-extensions/nautilus-gtk-extensions.c87
-rw-r--r--libnautilus-extensions/nautilus-gtk-extensions.h6
-rw-r--r--libnautilus-private/nautilus-gdk-extensions.c42
-rw-r--r--libnautilus-private/nautilus-gdk-extensions.h21
-rw-r--r--libnautilus-private/nautilus-gtk-extensions.c87
-rw-r--r--libnautilus-private/nautilus-gtk-extensions.h6
-rw-r--r--src/nautilus-application.c10
-rw-r--r--src/nautilus-application.h1
-rw-r--r--src/nautilus-first-time-druid.c2
-rw-r--r--src/nautilus-main.c8
-rw-r--r--src/nautilus-shell-interface.idl4
-rw-r--r--src/nautilus-shell.c23
15 files changed, 342 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 545b24531..4d4acd57c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,54 @@
+2000-12-21 John Harper <jsh@eazel.com>
+
+ reviewed by: Darin Adler <darin@eazel.com>
+
+ Work to allow geometry of initial window to be specified on
+ command line. Fixes bug #5135
+
+ * src/nautilus-shell.c (open_window): new arg `geometry'. When
+ non-null, use nautilus_gtk_window_set_initial_geometry_from_string
+ to affect the geometry of the unmapped window
+
+ (corba_open_default_window, corba_open_windows): new arg,
+ `geometry', passed to open_window () if a non-null string
+
+ * src/nautilus-shell-interface.idl (open_windows,
+ open_default_window): added `geometry' parameter. Pass a
+ zero-length string to show no specified geometry
+
+ * src/nautilus-main.c (main): new option `--geometry=GEOMETRY'.
+ Pass the value to nautilus_application_startup (). This option
+ is only allowed when no more than one URI is given on the
+ command line (to prevent multiple windows appearing on top of
+ one another)
+
+ * src/nautilus-application.c, src/nautilus-application.h
+ (nautilus_application_startup): added parameter `geometry', a
+ string describing the geometry to give any created windows
+
+ * src/nautilus-first-time-druid.c (druid_finished): pass null
+ geometry parameter to nautilus_application_startup ()
+
+ * libnautilus/nautilus-gdk-extensions.c,
+ libnautilus/nautilus-gdk-extensions.h
+ (NautilusGdkGeometryFlags, nautilus_gdk_parse_geometry): a
+ wrapper for XParseGeometry () and associated bit definitions.
+ Required since gnome_parse_geometry () offers no reliable way
+ of detecting which of the geometry components were parsed
+ successfully
+
+ * libnautilus/nautilus-gtk-extensions.c,
+ libnautilus/nautilus-gtk-extensions.h
+ (nautilus_gtk_window_set_initial_geometry): takes an extra
+ parameter, a NautilusGdkGeometryFlags value specifying which of
+ the geometry parameters are valid
+
+ (nautilus_gtk_window_set_initial_geometry_from_string): changed
+ to allow the geometry string to specify one or both of position
+ and dimensions. Also doesn't use g_return_if_fail to test for
+ validity of input string (since it may come from the user),
+ instead just use the parseable parts of the geometry string
+
2000-12-22 John Sullivan <sullivan@eazel.com>
reviewed by: Pavel Cisler <pavel@eazel.com>
diff --git a/libnautilus-extensions/nautilus-gdk-extensions.c b/libnautilus-extensions/nautilus-gdk-extensions.c
index a36702dad..7afde9b16 100644
--- a/libnautilus-extensions/nautilus-gdk-extensions.c
+++ b/libnautilus-extensions/nautilus-gdk-extensions.c
@@ -1071,4 +1071,46 @@ nautilus_self_check_gdk_extensions (void)
gdk_font_unref (font);
}
+NautilusGdkGeometryFlags
+nautilus_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
+ guint *width_return, guint *height_return)
+{
+ int x11_flags;
+ NautilusGdkGeometryFlags gdk_flags;
+
+ g_return_val_if_fail (string != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (x_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (y_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (width_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (height_return != NULL, NAUTILUS_GDK_NO_VALUE);
+
+ x11_flags = XParseGeometry (string, x_return, y_return,
+ width_return, height_return);
+
+ gdk_flags = NAUTILUS_GDK_NO_VALUE;
+ if (x11_flags & NoValue) {
+ gdk_flags |= NAUTILUS_GDK_NO_VALUE;
+ }
+ if (x11_flags & XValue) {
+ gdk_flags |= NAUTILUS_GDK_X_VALUE;
+ }
+ if (x11_flags & YValue) {
+ gdk_flags |= NAUTILUS_GDK_Y_VALUE;
+ }
+ if (x11_flags & WidthValue) {
+ gdk_flags |= NAUTILUS_GDK_WIDTH_VALUE;
+ }
+ if (x11_flags & HeightValue) {
+ gdk_flags |= NAUTILUS_GDK_HEIGHT_VALUE;
+ }
+ if (x11_flags & XNegative) {
+ gdk_flags |= NAUTILUS_GDK_X_NEGATIVE;
+ }
+ if (x11_flags & YNegative) {
+ gdk_flags |= NAUTILUS_GDK_Y_NEGATIVE;
+ }
+
+ return gdk_flags;
+}
+
#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-extensions/nautilus-gdk-extensions.h b/libnautilus-extensions/nautilus-gdk-extensions.h
index 3647e937a..b8a99ae0e 100644
--- a/libnautilus-extensions/nautilus-gdk-extensions.h
+++ b/libnautilus-extensions/nautilus-gdk-extensions.h
@@ -53,6 +53,18 @@
#define NAUTILUS_RGBA_COLOR_GET_B(color) (((color) >> 0) & 0xff)
#define NAUTILUS_RGBA_COLOR_GET_A(color) (((color) >> 24) & 0xff)
+/* Bits returned by nautilus_gdk_parse_geometry */
+typedef enum {
+ NAUTILUS_GDK_NO_VALUE = 0x00,
+ NAUTILUS_GDK_X_VALUE = 0x01,
+ NAUTILUS_GDK_Y_VALUE = 0x02,
+ NAUTILUS_GDK_WIDTH_VALUE = 0x04,
+ NAUTILUS_GDK_HEIGHT_VALUE = 0x08,
+ NAUTILUS_GDK_ALL_VALUES = 0x0f,
+ NAUTILUS_GDK_X_NEGATIVE = 0x10,
+ NAUTILUS_GDK_Y_NEGATIVE = 0x20,
+} NautilusGdkGeometryFlags;
+
/* A gradient spec. is a string that contains a specifier for either a
color or a gradient. If the string has a "-" in it, then it's a gradient.
The gradient is vertical by default and the spec. can end with ":v" to indicate that.
@@ -153,5 +165,12 @@ void nautilus_gdk_window_set_wm_hints_input (GdkWindow *w,
char * nautilus_string_ellipsize_start (const char *original,
GdkFont *font,
int length);
-
+
+/* Wrapper for XParseGeometry */
+NautilusGdkGeometryFlags nautilus_gdk_parse_geometry (const char *string,
+ int *x_return,
+ int *y_return,
+ guint *width_return,
+ guint *height_return);
+
#endif /* NAUTILUS_GDK_EXTENSIONS_H */
diff --git a/libnautilus-extensions/nautilus-gtk-extensions.c b/libnautilus-extensions/nautilus-gtk-extensions.c
index f9832666f..21cc43cb1 100644
--- a/libnautilus-extensions/nautilus-gtk-extensions.c
+++ b/libnautilus-extensions/nautilus-gtk-extensions.c
@@ -359,21 +359,11 @@ nautilus_gtk_window_set_up_close_accelerator (GtkWindow *window)
}
static void
-sanity_check_window_geometry (int *left, int *top, int *width, int *height)
+sanity_check_window_position (int *left, int *top)
{
g_assert (left != NULL);
g_assert (top != NULL);
- g_assert (width != NULL);
- g_assert (height != NULL);
- /* Pin the size of the window to the screen, so we don't end up in
- * a state where the window is so big essential parts of it can't
- * be reached (might not be necessary with all window managers,
- * but seems reasonable anyway).
- */
- *width = MIN (*width, gdk_screen_width());
- *height = MIN (*height, gdk_screen_height());
-
/* Make sure the top of the window is on screen, for
* draggability (might not be necessary with all window managers,
* but seems reasonable anyway). Make sure the top of the window
@@ -396,6 +386,20 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
*left = CLAMP (*left, 0, gdk_screen_width() - MINIMUM_ON_SCREEN_WIDTH);
}
+static void
+sanity_check_window_dimensions (int *width, int *height)
+{
+ g_assert (width != NULL);
+ g_assert (height != NULL);
+
+ /* Pin the size of the window to the screen, so we don't end up in
+ * a state where the window is so big essential parts of it can't
+ * be reached (might not be necessary with all window managers,
+ * but seems reasonable anyway).
+ */
+ *width = MIN (*width, gdk_screen_width());
+ *height = MIN (*height, gdk_screen_height());
+}
/**
* nautilus_gtk_window_set_initial_geometry:
@@ -406,6 +410,8 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
* some sanity-checking on the passed-in values.
*
* @window: A non-visible GtkWindow
+ * @geometry_flags: A NautilusGdkGeometryFlags value defining which of
+ * the following parameters have defined values
* @left: pixel coordinate for left of window
* @top: pixel coordinate for top of window
* @width: width of window in pixels
@@ -413,13 +419,17 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
*/
void
nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
+ NautilusGdkGeometryFlags geometry_flags,
int left,
int top,
- int width,
- int height)
+ guint width,
+ guint height)
{
+ int real_left, real_top;
+
g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (width > 0 && height > 0);
+ g_return_if_fail (!(geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) || width > 0);
+ g_return_if_fail (!(geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE) || height > 0);
/* Setting the default size doesn't work when the window is already showing.
* Someday we could make this move an already-showing window, but we don't
@@ -427,10 +437,31 @@ nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
*/
g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
- sanity_check_window_geometry (&left, &top, &width, &height);
-
- gtk_widget_set_uposition (GTK_WIDGET (window), left, top);
- gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+ if ((geometry_flags & NAUTILUS_GDK_X_VALUE) && (geometry_flags & NAUTILUS_GDK_Y_VALUE)) {
+ real_left = left;
+ real_top = top;
+
+ /* This is sub-optimal. GDK doesn't allow us to set win_gravity
+ * to South/East types, which should be done if using negative
+ * positions (so that the right or bottom edge of the window
+ * appears at the specified position, not the left or top).
+ * However it does seem to be consistent with other GNOME apps.
+ */
+ if (geometry_flags & NAUTILUS_GDK_X_NEGATIVE) {
+ real_left = gdk_screen_width () - real_left;
+ }
+ if (geometry_flags & NAUTILUS_GDK_Y_NEGATIVE) {
+ real_top = gdk_screen_height () - real_top;
+ }
+
+ sanity_check_window_position (&real_left, &real_top);
+ gtk_widget_set_uposition (GTK_WIDGET (window), real_left, real_top);
+ }
+
+ if ((geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) && (geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE)) {
+ sanity_check_window_dimensions (&width, &height);
+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+ }
}
/**
@@ -455,8 +486,9 @@ nautilus_gtk_window_set_initial_geometry_from_string (GtkWindow *window,
guint minimum_width,
guint minimum_height)
{
- int left, top, width, height;
- gboolean parsed;
+ int left, top;
+ guint width, height;
+ NautilusGdkGeometryFlags geometry_flags;
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (geometry_string != NULL);
@@ -467,18 +499,19 @@ nautilus_gtk_window_set_initial_geometry_from_string (GtkWindow *window,
*/
g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
- parsed = gnome_parse_geometry (geometry_string, &left, &top, &width, &height);
-
- /* Bogus string, dude. */
- g_return_if_fail (parsed);
+ geometry_flags = nautilus_gdk_parse_geometry (geometry_string, &left, &top, &width, &height);
/* Make sure the window isn't smaller than makes sense for this window.
* Other sanity checks are performed in set_initial_geometry.
*/
- width = MAX (width, (int) minimum_width);
- height = MAX (height, (int) minimum_height);
+ if (geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) {
+ width = MAX (width, minimum_width);
+ }
+ if (geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE) {
+ height = MAX (height, minimum_height);
+ }
- nautilus_gtk_window_set_initial_geometry (window, left, top, width, height);
+ nautilus_gtk_window_set_initial_geometry (window, geometry_flags, left, top, width, height);
}
/**
diff --git a/libnautilus-extensions/nautilus-gtk-extensions.h b/libnautilus-extensions/nautilus-gtk-extensions.h
index 8b5b1ef16..3c1a562c4 100644
--- a/libnautilus-extensions/nautilus-gtk-extensions.h
+++ b/libnautilus-extensions/nautilus-gtk-extensions.h
@@ -33,6 +33,7 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkpixmap.h>
#include <gtk/gtkwindow.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#define NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT 2
#define NAUTILUS_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w'
@@ -100,10 +101,11 @@ void nautilus_gtk_container_foreach_deep (GtkContainer *contain
/* GtkWindow */
void nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
+ NautilusGdkGeometryFlags geometry_flags,
int left,
int top,
- int width,
- int height);
+ guint width,
+ guint height);
void nautilus_gtk_window_set_initial_geometry_from_string
(GtkWindow *window,
const char *geometry_string,
diff --git a/libnautilus-private/nautilus-gdk-extensions.c b/libnautilus-private/nautilus-gdk-extensions.c
index a36702dad..7afde9b16 100644
--- a/libnautilus-private/nautilus-gdk-extensions.c
+++ b/libnautilus-private/nautilus-gdk-extensions.c
@@ -1071,4 +1071,46 @@ nautilus_self_check_gdk_extensions (void)
gdk_font_unref (font);
}
+NautilusGdkGeometryFlags
+nautilus_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
+ guint *width_return, guint *height_return)
+{
+ int x11_flags;
+ NautilusGdkGeometryFlags gdk_flags;
+
+ g_return_val_if_fail (string != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (x_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (y_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (width_return != NULL, NAUTILUS_GDK_NO_VALUE);
+ g_return_val_if_fail (height_return != NULL, NAUTILUS_GDK_NO_VALUE);
+
+ x11_flags = XParseGeometry (string, x_return, y_return,
+ width_return, height_return);
+
+ gdk_flags = NAUTILUS_GDK_NO_VALUE;
+ if (x11_flags & NoValue) {
+ gdk_flags |= NAUTILUS_GDK_NO_VALUE;
+ }
+ if (x11_flags & XValue) {
+ gdk_flags |= NAUTILUS_GDK_X_VALUE;
+ }
+ if (x11_flags & YValue) {
+ gdk_flags |= NAUTILUS_GDK_Y_VALUE;
+ }
+ if (x11_flags & WidthValue) {
+ gdk_flags |= NAUTILUS_GDK_WIDTH_VALUE;
+ }
+ if (x11_flags & HeightValue) {
+ gdk_flags |= NAUTILUS_GDK_HEIGHT_VALUE;
+ }
+ if (x11_flags & XNegative) {
+ gdk_flags |= NAUTILUS_GDK_X_NEGATIVE;
+ }
+ if (x11_flags & YNegative) {
+ gdk_flags |= NAUTILUS_GDK_Y_NEGATIVE;
+ }
+
+ return gdk_flags;
+}
+
#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-gdk-extensions.h b/libnautilus-private/nautilus-gdk-extensions.h
index 3647e937a..b8a99ae0e 100644
--- a/libnautilus-private/nautilus-gdk-extensions.h
+++ b/libnautilus-private/nautilus-gdk-extensions.h
@@ -53,6 +53,18 @@
#define NAUTILUS_RGBA_COLOR_GET_B(color) (((color) >> 0) & 0xff)
#define NAUTILUS_RGBA_COLOR_GET_A(color) (((color) >> 24) & 0xff)
+/* Bits returned by nautilus_gdk_parse_geometry */
+typedef enum {
+ NAUTILUS_GDK_NO_VALUE = 0x00,
+ NAUTILUS_GDK_X_VALUE = 0x01,
+ NAUTILUS_GDK_Y_VALUE = 0x02,
+ NAUTILUS_GDK_WIDTH_VALUE = 0x04,
+ NAUTILUS_GDK_HEIGHT_VALUE = 0x08,
+ NAUTILUS_GDK_ALL_VALUES = 0x0f,
+ NAUTILUS_GDK_X_NEGATIVE = 0x10,
+ NAUTILUS_GDK_Y_NEGATIVE = 0x20,
+} NautilusGdkGeometryFlags;
+
/* A gradient spec. is a string that contains a specifier for either a
color or a gradient. If the string has a "-" in it, then it's a gradient.
The gradient is vertical by default and the spec. can end with ":v" to indicate that.
@@ -153,5 +165,12 @@ void nautilus_gdk_window_set_wm_hints_input (GdkWindow *w,
char * nautilus_string_ellipsize_start (const char *original,
GdkFont *font,
int length);
-
+
+/* Wrapper for XParseGeometry */
+NautilusGdkGeometryFlags nautilus_gdk_parse_geometry (const char *string,
+ int *x_return,
+ int *y_return,
+ guint *width_return,
+ guint *height_return);
+
#endif /* NAUTILUS_GDK_EXTENSIONS_H */
diff --git a/libnautilus-private/nautilus-gtk-extensions.c b/libnautilus-private/nautilus-gtk-extensions.c
index f9832666f..21cc43cb1 100644
--- a/libnautilus-private/nautilus-gtk-extensions.c
+++ b/libnautilus-private/nautilus-gtk-extensions.c
@@ -359,21 +359,11 @@ nautilus_gtk_window_set_up_close_accelerator (GtkWindow *window)
}
static void
-sanity_check_window_geometry (int *left, int *top, int *width, int *height)
+sanity_check_window_position (int *left, int *top)
{
g_assert (left != NULL);
g_assert (top != NULL);
- g_assert (width != NULL);
- g_assert (height != NULL);
- /* Pin the size of the window to the screen, so we don't end up in
- * a state where the window is so big essential parts of it can't
- * be reached (might not be necessary with all window managers,
- * but seems reasonable anyway).
- */
- *width = MIN (*width, gdk_screen_width());
- *height = MIN (*height, gdk_screen_height());
-
/* Make sure the top of the window is on screen, for
* draggability (might not be necessary with all window managers,
* but seems reasonable anyway). Make sure the top of the window
@@ -396,6 +386,20 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
*left = CLAMP (*left, 0, gdk_screen_width() - MINIMUM_ON_SCREEN_WIDTH);
}
+static void
+sanity_check_window_dimensions (int *width, int *height)
+{
+ g_assert (width != NULL);
+ g_assert (height != NULL);
+
+ /* Pin the size of the window to the screen, so we don't end up in
+ * a state where the window is so big essential parts of it can't
+ * be reached (might not be necessary with all window managers,
+ * but seems reasonable anyway).
+ */
+ *width = MIN (*width, gdk_screen_width());
+ *height = MIN (*height, gdk_screen_height());
+}
/**
* nautilus_gtk_window_set_initial_geometry:
@@ -406,6 +410,8 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
* some sanity-checking on the passed-in values.
*
* @window: A non-visible GtkWindow
+ * @geometry_flags: A NautilusGdkGeometryFlags value defining which of
+ * the following parameters have defined values
* @left: pixel coordinate for left of window
* @top: pixel coordinate for top of window
* @width: width of window in pixels
@@ -413,13 +419,17 @@ sanity_check_window_geometry (int *left, int *top, int *width, int *height)
*/
void
nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
+ NautilusGdkGeometryFlags geometry_flags,
int left,
int top,
- int width,
- int height)
+ guint width,
+ guint height)
{
+ int real_left, real_top;
+
g_return_if_fail (GTK_IS_WINDOW (window));
- g_return_if_fail (width > 0 && height > 0);
+ g_return_if_fail (!(geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) || width > 0);
+ g_return_if_fail (!(geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE) || height > 0);
/* Setting the default size doesn't work when the window is already showing.
* Someday we could make this move an already-showing window, but we don't
@@ -427,10 +437,31 @@ nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
*/
g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
- sanity_check_window_geometry (&left, &top, &width, &height);
-
- gtk_widget_set_uposition (GTK_WIDGET (window), left, top);
- gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+ if ((geometry_flags & NAUTILUS_GDK_X_VALUE) && (geometry_flags & NAUTILUS_GDK_Y_VALUE)) {
+ real_left = left;
+ real_top = top;
+
+ /* This is sub-optimal. GDK doesn't allow us to set win_gravity
+ * to South/East types, which should be done if using negative
+ * positions (so that the right or bottom edge of the window
+ * appears at the specified position, not the left or top).
+ * However it does seem to be consistent with other GNOME apps.
+ */
+ if (geometry_flags & NAUTILUS_GDK_X_NEGATIVE) {
+ real_left = gdk_screen_width () - real_left;
+ }
+ if (geometry_flags & NAUTILUS_GDK_Y_NEGATIVE) {
+ real_top = gdk_screen_height () - real_top;
+ }
+
+ sanity_check_window_position (&real_left, &real_top);
+ gtk_widget_set_uposition (GTK_WIDGET (window), real_left, real_top);
+ }
+
+ if ((geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) && (geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE)) {
+ sanity_check_window_dimensions (&width, &height);
+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+ }
}
/**
@@ -455,8 +486,9 @@ nautilus_gtk_window_set_initial_geometry_from_string (GtkWindow *window,
guint minimum_width,
guint minimum_height)
{
- int left, top, width, height;
- gboolean parsed;
+ int left, top;
+ guint width, height;
+ NautilusGdkGeometryFlags geometry_flags;
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (geometry_string != NULL);
@@ -467,18 +499,19 @@ nautilus_gtk_window_set_initial_geometry_from_string (GtkWindow *window,
*/
g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
- parsed = gnome_parse_geometry (geometry_string, &left, &top, &width, &height);
-
- /* Bogus string, dude. */
- g_return_if_fail (parsed);
+ geometry_flags = nautilus_gdk_parse_geometry (geometry_string, &left, &top, &width, &height);
/* Make sure the window isn't smaller than makes sense for this window.
* Other sanity checks are performed in set_initial_geometry.
*/
- width = MAX (width, (int) minimum_width);
- height = MAX (height, (int) minimum_height);
+ if (geometry_flags & NAUTILUS_GDK_WIDTH_VALUE) {
+ width = MAX (width, minimum_width);
+ }
+ if (geometry_flags & NAUTILUS_GDK_HEIGHT_VALUE) {
+ height = MAX (height, minimum_height);
+ }
- nautilus_gtk_window_set_initial_geometry (window, left, top, width, height);
+ nautilus_gtk_window_set_initial_geometry (window, geometry_flags, left, top, width, height);
}
/**
diff --git a/libnautilus-private/nautilus-gtk-extensions.h b/libnautilus-private/nautilus-gtk-extensions.h
index 8b5b1ef16..3c1a562c4 100644
--- a/libnautilus-private/nautilus-gtk-extensions.h
+++ b/libnautilus-private/nautilus-gtk-extensions.h
@@ -33,6 +33,7 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkpixmap.h>
#include <gtk/gtkwindow.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#define NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT 2
#define NAUTILUS_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w'
@@ -100,10 +101,11 @@ void nautilus_gtk_container_foreach_deep (GtkContainer *contain
/* GtkWindow */
void nautilus_gtk_window_set_initial_geometry (GtkWindow *window,
+ NautilusGdkGeometryFlags geometry_flags,
int left,
int top,
- int width,
- int height);
+ guint width,
+ guint height);
void nautilus_gtk_window_set_initial_geometry_from_string
(GtkWindow *window,
const char *geometry_string,
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index f6247b0a8..93f65c41d 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -311,6 +311,7 @@ nautilus_application_startup (NautilusApplication *application,
gboolean restart_shell,
gboolean start_desktop,
gboolean no_default_window,
+ const char *geometry,
const char *urls[])
{
CORBA_Environment ev;
@@ -319,6 +320,7 @@ nautilus_application_startup (NautilusApplication *application,
const char *message, *detailed_message;
GnomeDialog *dialog;
Nautilus_URIList *url_list;
+ const CORBA_char *corba_geometry;
/* Perform check for nautilus being run as super user */
if (!check_for_and_run_as_super_user ()) {
@@ -438,13 +440,17 @@ nautilus_application_startup (NautilusApplication *application,
Nautilus_Shell_start_desktop (shell, &ev);
}
+ /* CORBA C mapping doesn't allow NULL to be passed
+ for string parameters */
+ corba_geometry = (geometry != NULL) ? geometry : "";
+
/* Create the other windows. */
if (urls != NULL) {
url_list = nautilus_make_uri_list_from_strv (urls);
- Nautilus_Shell_open_windows (shell, url_list, &ev);
+ Nautilus_Shell_open_windows (shell, url_list, corba_geometry, &ev);
CORBA_free (url_list);
} else if (!no_default_window) {
- Nautilus_Shell_open_default_window (shell, &ev);
+ Nautilus_Shell_open_default_window (shell, corba_geometry, &ev);
}
}
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index 751d6ffa6..fc0f1715c 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -59,6 +59,7 @@ void nautilus_application_startup (NautilusApplication *ap
gboolean restart_shell,
gboolean start_desktop,
gboolean no_default_window,
+ const char *default_geometry,
const char *urls[]);
GSList *nautilus_application_windows (void);
diff --git a/src/nautilus-first-time-druid.c b/src/nautilus-first-time-druid.c
index 7d9fb9e86..1a8643f8d 100644
--- a/src/nautilus-first-time-druid.c
+++ b/src/nautilus-first-time-druid.c
@@ -221,7 +221,7 @@ druid_finished (GtkWidget *druid_page)
signup_uris[1] = NULL;
nautilus_application_startup (save_application, FALSE, FALSE, save_manage_desktop,
- FALSE, (signup_uris[0] != NULL) ? signup_uris : NULL);
+ FALSE, NULL, (signup_uris[0] != NULL) ? signup_uris : NULL);
/* Destroy druid last because it may be the only thing keeping the main event loop alive. */
gtk_widget_destroy (gtk_widget_get_toplevel (druid_page));
diff --git a/src/nautilus-main.c b/src/nautilus-main.c
index f5ed18356..ac7de316f 100644
--- a/src/nautilus-main.c
+++ b/src/nautilus-main.c
@@ -128,6 +128,7 @@ main (int argc, char *argv[])
gboolean restart_shell;
gboolean start_desktop;
gboolean no_default_window;
+ char *geometry;
gboolean perform_self_check;
poptContext popt_context;
const char **args;
@@ -142,6 +143,7 @@ main (int argc, char *argv[])
{ "quit", '\0', POPT_ARG_NONE, &kill_shell, 0, N_("Quit Nautilus."), NULL },
{ "restart", '\0', POPT_ARG_NONE, &restart_shell, 0, N_("Restart Nautilus."), NULL },
{ "no-default-window", '\0', POPT_ARG_NONE, &no_default_window, 0, N_("Only create Nautilus windows for explicity specified URIs."), NULL },
+ { "geometry", '\0', POPT_ARG_STRING, &geometry, 0, N_("Create the initial window with the given geometry."), N_("GEOMETRY") },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &oaf_popt_options, 0, NULL, NULL },
POPT_AUTOHELP
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
@@ -207,6 +209,10 @@ main (int argc, char *argv[])
fprintf (stderr, _("nautilus: --restart cannot be used with URIs.\n"));
return EXIT_FAILURE;
}
+ if (geometry != NULL && args != NULL && args[0] != NULL && args[1] != NULL) {
+ fprintf (stderr, _("nautilus: --geometry cannot be used with more than one URI.\n"));
+ return EXIT_FAILURE;
+ }
/* Initialize the services that we use. */
LIBXML_TEST_VERSION
@@ -244,7 +250,7 @@ main (int argc, char *argv[])
application = nautilus_application_new ();
nautilus_application_startup
(application,
- kill_shell, restart_shell, start_desktop, no_default_window,
+ kill_shell, restart_shell, start_desktop, no_default_window, geometry,
args);
if (is_event_loop_needed ()) {
bonobo_main ();
diff --git a/src/nautilus-shell-interface.idl b/src/nautilus-shell-interface.idl
index 3b9d982ba..1856fd9b7 100644
--- a/src/nautilus-shell-interface.idl
+++ b/src/nautilus-shell-interface.idl
@@ -9,8 +9,8 @@
module Nautilus {
interface Shell : ::Bonobo::Unknown {
- oneway void open_windows (in URIList uris);
- oneway void open_default_window ();
+ oneway void open_windows (in URIList uris, in string geometry);
+ oneway void open_default_window (in string geometry);
oneway void start_desktop ();
oneway void stop_desktop ();
oneway void quit ();
diff --git a/src/nautilus-shell.c b/src/nautilus-shell.c
index a4a2bf26d..5121e3a7e 100644
--- a/src/nautilus-shell.c
+++ b/src/nautilus-shell.c
@@ -39,6 +39,7 @@
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
@@ -59,8 +60,10 @@ static void nautilus_shell_initialize_class (NautilusShellClass *klass);
static void destroy (GtkObject *shell);
static void corba_open_windows (PortableServer_Servant servant,
const Nautilus_URIList *list,
+ const CORBA_char *geometry,
CORBA_Environment *ev);
static void corba_open_default_window (PortableServer_Servant servant,
+ const CORBA_char *geometry,
CORBA_Environment *ev);
static void corba_start_desktop (PortableServer_Servant servant,
CORBA_Environment *ev);
@@ -72,6 +75,10 @@ static void corba_restart (PortableServer_Servant servant,
CORBA_Environment *ev);
static gboolean restore_window_states (NautilusShell *shell);
+/* Keep window from shrinking down ridiculously small; numbers are somewhat arbitrary */
+#define APPLICATION_WINDOW_MIN_WIDTH 300
+#define APPLICATION_WINDOW_MIN_HEIGHT 100
+
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusShell, nautilus_shell, BONOBO_OBJECT_TYPE)
static void
@@ -243,11 +250,19 @@ display_caveat_first_time (NautilusShell *shell, NautilusWindow *window)
}
static void
-open_window (NautilusShell *shell, const char *uri)
+open_window (NautilusShell *shell, const char *uri, const char *geometry)
{
NautilusWindow *window;
window = nautilus_application_create_window (shell->details->application);
+
+ if (geometry != NULL) {
+ nautilus_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
+ geometry,
+ APPLICATION_WINDOW_MIN_WIDTH,
+ APPLICATION_WINDOW_MIN_HEIGHT);
+ }
+
if (uri == NULL) {
nautilus_window_go_home (window);
} else {
@@ -259,6 +274,7 @@ open_window (NautilusShell *shell, const char *uri)
static void
corba_open_windows (PortableServer_Servant servant,
const Nautilus_URIList *list,
+ const CORBA_char *geometry,
CORBA_Environment *ev)
{
NautilusShell *shell;
@@ -269,12 +285,13 @@ corba_open_windows (PortableServer_Servant servant,
/* Open windows at each requested location. */
for (i = 0; i < list->_length; i++) {
g_assert (list->_buffer[i] != NULL);
- open_window (shell, list->_buffer[i]);
+ open_window (shell, list->_buffer[i], geometry);
}
}
static void
corba_open_default_window (PortableServer_Servant servant,
+ const CORBA_char *geometry,
CORBA_Environment *ev)
{
NautilusShell *shell;
@@ -283,7 +300,7 @@ corba_open_default_window (PortableServer_Servant servant,
if (!restore_window_states (shell)) {
/* Open a window pointing at the default location. */
- open_window (shell, NULL);
+ open_window (shell, NULL, geometry);
}
}