comparison src/remote.c @ 2801:3e9ca298bb1d

Fix #251: Crop simulation Menu option to draw a rectangle. Rectangle co-ordinates can be obtained with the remote command: --remote --get-rectangle
author Colin Clark <colin.clark@cclark.uk>
date Fri, 20 Jul 2018 17:45:10 +0100
parents a03b5446e68f
children a58a176761eb
comparison
equal deleted inserted replaced
2800:0ecd4885dc09 2801:3e9ca298bb1d
685 } 685 }
686 } 686 }
687 else 687 else
688 { 688 {
689 return; 689 return;
690 }
691 }
692
693 static void gr_rectangle(const gchar *text, GIOChannel *channel, gpointer data)
694 {
695 gchar *rectangle_info;
696 PixbufRenderer *pr;
697 LayoutWindow *lw = NULL;
698 gint x1, y1, x2, y2;
699
700 if (!layout_valid(&lw_id)) return;
701
702 pr = (PixbufRenderer*)lw_id->image->pr;
703
704 if (pr)
705 {
706 image_get_rectangle(&x1, &y1, &x2, &y2);
707 rectangle_info = g_strdup_printf(_("%dx%d+%d+%d"),
708 (x2 > x1) ? x2 - x1 : x1 - x2,
709 (y2 > y1) ? y2 - y1 : y1 - y2,
710 (x2 > x1) ? x1 : x2,
711 (y2 > y1) ? y1 : y2);
712
713 g_io_channel_write_chars(channel, rectangle_info, -1, NULL, NULL);
714 g_io_channel_write_chars(channel, "\n", -1, NULL, NULL);
715
716 g_free(rectangle_info);
690 } 717 }
691 } 718 }
692 719
693 static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data) 720 static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data)
694 { 721 {
879 { NULL, "--get-destination:", gr_get_destination, TRUE, FALSE, N_("<FILE>"), N_("get destination path of FILE") }, 906 { NULL, "--get-destination:", gr_get_destination, TRUE, FALSE, N_("<FILE>"), N_("get destination path of FILE") },
880 { NULL, "file:", gr_file_load, TRUE, FALSE, N_("<FILE>"), N_("open FILE, bring Geeqie window to the top") }, 907 { NULL, "file:", gr_file_load, TRUE, FALSE, N_("<FILE>"), N_("open FILE, bring Geeqie window to the top") },
881 { NULL, "File:", gr_file_load_no_raise, TRUE, FALSE, N_("<FILE>"), N_("open FILE, do not bring Geeqie window to the top") }, 908 { NULL, "File:", gr_file_load_no_raise, TRUE, FALSE, N_("<FILE>"), N_("open FILE, do not bring Geeqie window to the top") },
882 { NULL, "--tell", gr_file_tell, FALSE, FALSE, NULL, N_("print filename of current image") }, 909 { NULL, "--tell", gr_file_tell, FALSE, FALSE, NULL, N_("print filename of current image") },
883 { NULL, "--pixel-info", gr_pixel_info, FALSE, FALSE, NULL, N_("print pixel info of mouse pointer on current image") }, 910 { NULL, "--pixel-info", gr_pixel_info, FALSE, FALSE, NULL, N_("print pixel info of mouse pointer on current image") },
911 { NULL, "--get-rectangle", gr_rectangle, FALSE, FALSE, NULL, N_("get rectangle co-ordinates") },
884 { NULL, "view:", gr_file_view, TRUE, FALSE, N_("<FILE>"), N_("open FILE in new window") }, 912 { NULL, "view:", gr_file_view, TRUE, FALSE, N_("<FILE>"), N_("open FILE in new window") },
885 { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL, N_("clear command line collection list") }, 913 { NULL, "--list-clear", gr_list_clear, FALSE, FALSE, NULL, N_("clear command line collection list") },
886 { NULL, "--list-add:", gr_list_add, TRUE, FALSE, N_("<FILE>"), N_("add FILE to command line collection list") }, 914 { NULL, "--list-add:", gr_list_add, TRUE, FALSE, N_("<FILE>"), N_("add FILE to command line collection list") },
887 { NULL, "raise", gr_raise, FALSE, FALSE, NULL, N_("bring the Geeqie window to the top") }, 915 { NULL, "raise", gr_raise, FALSE, FALSE, NULL, N_("bring the Geeqie window to the top") },
888 { NULL, "--id:", gr_lw_id, TRUE, FALSE, N_("<ID>"), N_("window id for following commands") }, 916 { NULL, "--id:", gr_lw_id, TRUE, FALSE, N_("<ID>"), N_("window id for following commands") },