changeset 81:0ef72a64930b

Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net> * layout.[ch] (layout_new_with_geometry): New function to create a layout sized to an X geometry string. * main.c: Add support for --geometry on the command line.
author gqview
date Thu, 19 Oct 2006 13:38:52 +0000
parents a10fc0308c12
children a4c1b7014e6e
files ChangeLog TODO src/layout.c src/layout.h src/main.c
diffstat 5 files changed, 46 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 19 11:45:14 2006 +0000
+++ b/ChangeLog	Thu Oct 19 13:38:52 2006 +0000
@@ -1,3 +1,9 @@
+Thu Oct 19 09:35:18 2006  John Ellis  <johne@verizon.net>
+
+	* layout.[ch] (layout_new_with_geometry): New function to create a
+	layout sized to an X geometry string.
+	* main.c: Add support for --geometry on the command line.
+
 Thu Oct 19 07:42:38 2006  John Ellis  <johne@verizon.net>
 
 	* utilops.c: Fix minimum allowed auto-rename value to be zero again,
--- a/TODO	Thu Oct 19 11:45:14 2006 +0000
+++ b/TODO	Thu Oct 19 13:38:52 2006 +0000
@@ -89,6 +89,7 @@
    > Added 'Fast jpeg thumbnailing'.
    > xvpics is now hidden option.
    > Holding down shift will now scroll more when panning with mouse.
+   > add --geometry command line option
 
    > add blurb about moving images between collections with shift+drag
 
@@ -117,6 +118,8 @@
  > Initiating full screen from the command line should not
    show main window until full screen is exited.
 
+d> add --geometry suipport
+
  > Add shortcut to jump to next folder within parent folder.
 
  > add animated image support
--- a/src/layout.c	Thu Oct 19 11:45:14 2006 +0000
+++ b/src/layout.c	Thu Oct 19 13:38:52 2006 +0000
@@ -1600,9 +1600,15 @@
 
 LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden)
 {
+	return layout_new_with_geometry(path, popped, hidden, NULL);
+}
+
+LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidden,
+				       const gchar *geometry)
+{
 	LayoutWindow *lw;
-	GdkGeometry geometry;
-	GdkWindowHints hints;
+	GdkGeometry hint;
+	GdkWindowHints hint_mask;
 
 	lw = g_new0(LayoutWindow, 1);
 
@@ -1661,19 +1667,19 @@
 
 	if (save_window_positions)
 		{
-		hints = GDK_HINT_USER_POS;
+		hint_mask = GDK_HINT_USER_POS;
 		}
 	else
 		{
-		hints = 0;
+		hint_mask = 0;
 		}
 
-	geometry.min_width = 32;
-	geometry.min_height = 32;
-	geometry.base_width = MAINWINDOW_DEF_WIDTH;
-	geometry.base_height = MAINWINDOW_DEF_HEIGHT;
-	gtk_window_set_geometry_hints(GTK_WINDOW(lw->window), NULL, &geometry,
-				      GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints);
+	hint.min_width = 32;
+	hint.min_height = 32;
+	hint.base_width = 0;
+	hint.base_height = 0;
+	gtk_window_set_geometry_hints(GTK_WINDOW(lw->window), NULL, &hint,
+				      GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hint_mask);
 
 	if (save_window_positions)
 		{
@@ -1721,6 +1727,14 @@
 	lw->last_time = 0;
 	lw->last_time_id = g_timeout_add(5000, layout_check_for_update_cb, lw);
 
+	if (geometry)
+		{
+		if (!gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry))
+			{
+			print_term(_("Invalid geometry\n"));
+			}
+		}
+
 	gtk_widget_show(lw->window);
 	layout_tools_hide(lw, lw->tools_hidden);
 
--- a/src/layout.h	Thu Oct 19 11:45:14 2006 +0000
+++ b/src/layout.h	Thu Oct 19 13:38:52 2006 +0000
@@ -17,6 +17,8 @@
 
 
 LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden);
+LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidden,
+				       const gchar *geometry);
 
 void layout_close(LayoutWindow *lw);
 void layout_free(LayoutWindow *lw);
--- a/src/main.c	Thu Oct 19 11:45:14 2006 +0000
+++ b/src/main.c	Thu Oct 19 13:38:52 2006 +0000
@@ -906,7 +906,8 @@
 }
 
 static void parse_command_line(int argc, char *argv[], gchar **path, gchar **file,
-			       GList **cmd_list, GList **collection_list)
+			       GList **cmd_list, GList **collection_list,
+			       gchar **geometry)
 {
 	GList *list = NULL;
 	GList *remote_list = NULL;
@@ -977,6 +978,10 @@
 				{
 				startup_command_line_collection = TRUE;
 				}
+			else if (strncmp(cmd_line, "--geometry=", 11) == 0)
+				{
+				if (!*geometry) *geometry = g_strdup(cmd_line + 11);
+				}
 			else if (strcmp(cmd_line, "-r") == 0 ||
 				 strcmp(cmd_line, "--remote") == 0)
 				{
@@ -1019,6 +1024,7 @@
 				print_term(_("  -f, --fullscreen           start in full screen mode\n"));
 				print_term(_("  -s, --slideshow            start in slideshow mode\n"));
 				print_term(_("  -l, --list                 open collection window for command line\n"));
+				print_term(_("      --geometry=GEOMETRY    set main window location\n"));
 				print_term(_("  -r, --remote               send following commands to open window\n"));
 				print_term(_("  -rh,--remote-help          print remote command list\n"));
 				print_term(_("  --debug                    turn on debug output\n"));
@@ -1261,6 +1267,7 @@
 	GList *cmd_list = NULL;
 	GList *collection_list = NULL;
 	CollectionData *first_collection = NULL;
+	gchar *geometry = NULL;
 	gchar *buf;
 	gchar *bufl;
 
@@ -1281,7 +1288,7 @@
 	setup_default_options();
 	load_options();
 
-	parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list);
+	parse_command_line(argc, argv, &cmd_path, &cmd_file, &cmd_list, &collection_list, &geometry);
 
 	gtk_init (&argc, &argv);
 
@@ -1341,7 +1348,7 @@
 		path = get_current_dir();
 		}
 
-	lw = layout_new(NULL, tools_float, tools_hidden);
+	lw = layout_new_with_geometry(NULL, tools_float, tools_hidden, geometry);
 	layout_sort_set(lw, file_sort_method, file_sort_ascending);
 
 	if (collection_list && !startup_command_line_collection)
@@ -1428,6 +1435,7 @@
 			}
 		}
 
+	g_free(geometry);
 	g_free(cmd_path);
 	g_free(cmd_file);
 	path_list_free(cmd_list);