Thu Oct 19 09:35:18 2006 John Ellis <johne@verizon.net>
authorJohn Ellis <johne@verizon.net>
Thu, 19 Oct 2006 13:38:52 +0000 (13:38 +0000)
committerJohn Ellis <johne@verizon.net>
Thu, 19 Oct 2006 13:38:52 +0000 (13:38 +0000)
        * 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.

ChangeLog
TODO
src/layout.c
src/layout.h
src/main.c

index 6a91f84..a82800e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
diff --git a/TODO b/TODO
index f527653..458332d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -89,6 +89,7 @@ Major:
    > 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 @@ Wishlist?:
  > 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
index c696e21..a38ab2b 100644 (file)
@@ -1599,10 +1599,16 @@ static gint layout_delete_cb(GtkWidget *widget, GdkEventAny *event, gpointer dat
 }
 
 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 @@ LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden)
 
        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 @@ LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden)
        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);
 
index 7f50017..e78aa48 100644 (file)
@@ -17,6 +17,8 @@ extern GList *layout_window_list;
 
 
 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);
index 5dff9d4..8f7941c 100644 (file)
@@ -906,7 +906,8 @@ static void parse_command_line_process_file(const gchar *file_path, gchar **path
 }
 
 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 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                                {
                                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 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                                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 @@ int main (int argc, char *argv[])
        GList *cmd_list = NULL;
        GList *collection_list = NULL;
        CollectionData *first_collection = NULL;
+       gchar *geometry = NULL;
        gchar *buf;
        gchar *bufl;
 
@@ -1281,7 +1288,7 @@ int main (int argc, char *argv[])
        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 @@ int main (int argc, char *argv[])
                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 @@ int main (int argc, char *argv[])
                        }
                }
 
+       g_free(geometry);
        g_free(cmd_path);
        g_free(cmd_file);
        path_list_free(cmd_list);