Compare commits
	
		
			2 Commits
		
	
	
		
			5bae7c1bd2
			...
			d590d1da46
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d590d1da46 | |||
| d1d9caaa5e | 
							
								
								
									
										47
									
								
								fiv-view.c
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								fiv-view.c
									
									
									
									
									
								
							| @ -990,6 +990,34 @@ get_toplevel(GtkWidget *widget) | |||||||
| 	return NULL; | 	return NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void | ||||||
|  | copy(FivView *self) | ||||||
|  | { | ||||||
|  | 	double fractional_width = 0, fractional_height = 0; | ||||||
|  | 	cairo_matrix_t matrix = fiv_io_orientation_apply( | ||||||
|  | 		self->frame, self->orientation, &fractional_width, &fractional_height); | ||||||
|  | 	int w = ceil(fractional_width), h = ceil(fractional_height); | ||||||
|  | 
 | ||||||
|  | 	// XXX: SVG is rendered pre-scaled.
 | ||||||
|  | 	cairo_surface_t *transformed = | ||||||
|  | 		cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); | ||||||
|  | 	cairo_t *cr = cairo_create(transformed); | ||||||
|  | 	cairo_set_source_surface(cr, self->frame, 0, 0); | ||||||
|  | 	cairo_pattern_set_matrix(cairo_get_source(cr), &matrix); | ||||||
|  | 	cairo_paint(cr); | ||||||
|  | 	cairo_destroy(cr); | ||||||
|  | 
 | ||||||
|  | 	// TODO(p): Use 16-bit PNGs for >8-bit Cairo surfaces: PNG-encode them
 | ||||||
|  | 	// ourselves and fall back to gtk_selection_data_set_pixbuf().
 | ||||||
|  | 	GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(transformed, 0, 0, w, h); | ||||||
|  | 	cairo_surface_destroy(transformed); | ||||||
|  | 	gtk_clipboard_set_image( | ||||||
|  | 		gtk_clipboard_get_for_display( | ||||||
|  | 			gtk_widget_get_display(GTK_WIDGET(self)), GDK_SELECTION_CLIPBOARD), | ||||||
|  | 		pixbuf); | ||||||
|  | 	g_object_unref(pixbuf); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static void | static void | ||||||
| on_draw_page(G_GNUC_UNUSED GtkPrintOperation *operation, | on_draw_page(G_GNUC_UNUSED GtkPrintOperation *operation, | ||||||
| 	GtkPrintContext *context, G_GNUC_UNUSED int page_nr, FivView *self) | 	GtkPrintContext *context, G_GNUC_UNUSED int page_nr, FivView *self) | ||||||
| @ -1419,14 +1447,19 @@ fiv_view_class_init(FivViewClass *klass) | |||||||
| 	widget_class->scroll_event = fiv_view_scroll_event; | 	widget_class->scroll_event = fiv_view_scroll_event; | ||||||
| 	widget_class->key_press_event = fiv_view_key_press_event; | 	widget_class->key_press_event = fiv_view_key_press_event; | ||||||
| 
 | 
 | ||||||
|  | 	// _gtk_get_primary_accel_mod() is private.
 | ||||||
|  | 	GdkModifierType primary = GDK_CONTROL_MASK; | ||||||
|  | 	gtk_accelerator_parse_with_keycode("<Primary>", NULL, NULL, &primary); | ||||||
|  | 
 | ||||||
| 	GtkBindingSet *bs = gtk_binding_set_by_class(klass); | 	GtkBindingSet *bs = gtk_binding_set_by_class(klass); | ||||||
| 	// First, the standard, intuitive bindings.
 | 	// First, the standard, intuitive bindings.
 | ||||||
| 	bind(bs, GDK_KEY_0,      GDK_CONTROL_MASK, FIV_VIEW_COMMAND_ZOOM_1); | 	bind(bs, GDK_KEY_0,      primary,       FIV_VIEW_COMMAND_ZOOM_1); | ||||||
| 	bind(bs, GDK_KEY_plus,   GDK_CONTROL_MASK, FIV_VIEW_COMMAND_ZOOM_IN); | 	bind(bs, GDK_KEY_plus,   primary,       FIV_VIEW_COMMAND_ZOOM_IN); | ||||||
| 	bind(bs, GDK_KEY_minus,  GDK_CONTROL_MASK, FIV_VIEW_COMMAND_ZOOM_OUT); | 	bind(bs, GDK_KEY_minus,  primary,       FIV_VIEW_COMMAND_ZOOM_OUT); | ||||||
| 	bind(bs, GDK_KEY_p,      GDK_CONTROL_MASK, FIV_VIEW_COMMAND_PRINT); | 	bind(bs, GDK_KEY_c,      primary,       FIV_VIEW_COMMAND_COPY); | ||||||
| 	bind(bs, GDK_KEY_r,      GDK_CONTROL_MASK, FIV_VIEW_COMMAND_RELOAD); | 	bind(bs, GDK_KEY_p,      primary,       FIV_VIEW_COMMAND_PRINT); | ||||||
| 	bind(bs, GDK_KEY_s,      GDK_CONTROL_MASK, FIV_VIEW_COMMAND_SAVE_PAGE); | 	bind(bs, GDK_KEY_r,      primary,       FIV_VIEW_COMMAND_RELOAD); | ||||||
|  | 	bind(bs, GDK_KEY_s,      primary,       FIV_VIEW_COMMAND_SAVE_PAGE); | ||||||
| 	bind(bs, GDK_KEY_s,      GDK_MOD1_MASK, FIV_VIEW_COMMAND_SAVE_FRAME); | 	bind(bs, GDK_KEY_s,      GDK_MOD1_MASK, FIV_VIEW_COMMAND_SAVE_FRAME); | ||||||
| 	bind(bs, GDK_KEY_Return, GDK_MOD1_MASK, FIV_VIEW_COMMAND_INFO); | 	bind(bs, GDK_KEY_Return, GDK_MOD1_MASK, FIV_VIEW_COMMAND_INFO); | ||||||
| 
 | 
 | ||||||
| @ -1668,6 +1701,8 @@ fiv_view_command(FivView *self, FivViewCommand command) | |||||||
| 			G_OBJECT(self), view_properties[PROP_ENHANCE]); | 			G_OBJECT(self), view_properties[PROP_ENHANCE]); | ||||||
| 		swap_enhanced_image(self); | 		swap_enhanced_image(self); | ||||||
| 
 | 
 | ||||||
|  | 	break; case FIV_VIEW_COMMAND_COPY: | ||||||
|  | 		copy(self); | ||||||
| 	break; case FIV_VIEW_COMMAND_PRINT: | 	break; case FIV_VIEW_COMMAND_PRINT: | ||||||
| 		print(self); | 		print(self); | ||||||
| 	break; case FIV_VIEW_COMMAND_SAVE_PAGE: | 	break; case FIV_VIEW_COMMAND_SAVE_PAGE: | ||||||
|  | |||||||
| @ -50,6 +50,7 @@ typedef enum _FivViewCommand { | |||||||
| 	XX(FIV_VIEW_COMMAND_TOGGLE_FILTER,       "toggle-filter")                  \ | 	XX(FIV_VIEW_COMMAND_TOGGLE_FILTER,       "toggle-filter")                  \ | ||||||
| 	XX(FIV_VIEW_COMMAND_TOGGLE_CHECKERBOARD, "toggle-checkerboard")            \ | 	XX(FIV_VIEW_COMMAND_TOGGLE_CHECKERBOARD, "toggle-checkerboard")            \ | ||||||
| 	XX(FIV_VIEW_COMMAND_TOGGLE_ENHANCE,      "toggle-enhance")                 \ | 	XX(FIV_VIEW_COMMAND_TOGGLE_ENHANCE,      "toggle-enhance")                 \ | ||||||
|  | 	XX(FIV_VIEW_COMMAND_COPY,                "copy")                           \ | ||||||
| 	XX(FIV_VIEW_COMMAND_PRINT,               "print")                          \ | 	XX(FIV_VIEW_COMMAND_PRINT,               "print")                          \ | ||||||
| 	XX(FIV_VIEW_COMMAND_SAVE_PAGE,           "save-page")                      \ | 	XX(FIV_VIEW_COMMAND_SAVE_PAGE,           "save-page")                      \ | ||||||
| 	XX(FIV_VIEW_COMMAND_SAVE_FRAME,          "save-frame")                     \ | 	XX(FIV_VIEW_COMMAND_SAVE_FRAME,          "save-frame")                     \ | ||||||
|  | |||||||
							
								
								
									
										45
									
								
								fiv.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								fiv.c
									
									
									
									
									
								
							| @ -82,23 +82,23 @@ struct key_section { | |||||||
| static struct key help_keys_general[] = { | static struct key help_keys_general[] = { | ||||||
| 	{"F1", "Show help"}, | 	{"F1", "Show help"}, | ||||||
| 	{"F10", "Open menu"}, | 	{"F10", "Open menu"}, | ||||||
| 	{"<control>question", "Keyboard shortcuts"}, | 	{"<Control>question", "Keyboard shortcuts"}, | ||||||
| 	{"q <control>q", "Quit"}, | 	{"q <Control>q", "Quit"}, | ||||||
| 	{"<control>w", "Quit"}, | 	{"<Control>w", "Quit"}, | ||||||
| 	{} | 	{} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static struct key help_keys_navigation[] = { | static struct key help_keys_navigation[] = { | ||||||
| 	{"<control>l", "Open location..."}, | 	{"<Control>l", "Open location..."}, | ||||||
| 	{"<control>n", "Open a new window"}, | 	{"<Control>n", "Open a new window"}, | ||||||
| 	{"<alt>Left", "Go back in history"}, | 	{"<Alt>Left", "Go back in history"}, | ||||||
| 	{"<alt>Right", "Go forward in history"}, | 	{"<Alt>Right", "Go forward in history"}, | ||||||
| 	{} | 	{} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static struct key help_keys_view[] = { | static struct key help_keys_view[] = { | ||||||
| 	{"F11 f", "Toggle fullscreen"}, | 	{"F11 f", "Toggle fullscreen"}, | ||||||
| 	{"<alt><shift>d", "Toggle dark theme variant"}, | 	{"<Alt><Shift>d", "Toggle dark theme variant"}, | ||||||
| 	{} | 	{} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -107,17 +107,17 @@ static struct key_group help_keys_browser[] = { | |||||||
| 	{"General: Navigation", help_keys_navigation}, | 	{"General: Navigation", help_keys_navigation}, | ||||||
| 	{"General: View", help_keys_view}, | 	{"General: View", help_keys_view}, | ||||||
| 	{"Navigation", (struct key[]) { | 	{"Navigation", (struct key[]) { | ||||||
| 		{"<alt>Up", "Go to parent directory"}, | 		{"<Alt>Up", "Go to parent directory"}, | ||||||
| 		{"<alt>Home", "Go home"}, | 		{"<Alt>Home", "Go home"}, | ||||||
| 		{"Return", "Open selected item"}, | 		{"Return", "Open selected item"}, | ||||||
| 		{} | 		{} | ||||||
| 	}}, | 	}}, | ||||||
| 	{"View", (struct key[]) { | 	{"View", (struct key[]) { | ||||||
| 		{"F9", "Toggle navigation sidebar"}, | 		{"F9", "Toggle navigation sidebar"}, | ||||||
| 		{"F5 r <control>r", "Reload"}, | 		{"F5 r <Control>r", "Reload"}, | ||||||
| 		{"h <control>h", "Toggle hiding unsupported files"}, | 		{"h <Control>h", "Toggle hiding unsupported files"}, | ||||||
| 		{"<control>plus", "Larger thumbnails"}, | 		{"<Control>plus", "Larger thumbnails"}, | ||||||
| 		{"<control>minus", "Smaller thumbnails"}, | 		{"<Control>minus", "Smaller thumbnails"}, | ||||||
| 		{} | 		{} | ||||||
| 	}}, | 	}}, | ||||||
| 	{} | 	{} | ||||||
| @ -135,14 +135,14 @@ static struct key_group help_keys_viewer[] = { | |||||||
| 	}}, | 	}}, | ||||||
| 	{"View", (struct key[]) { | 	{"View", (struct key[]) { | ||||||
| 		{"F8", "Toggle toolbar"}, | 		{"F8", "Toggle toolbar"}, | ||||||
| 		{"F5 r <control>r", "Reload"}, | 		{"F5 r <Primary>r", "Reload"}, | ||||||
| 		{} | 		{} | ||||||
| 	}}, | 	}}, | ||||||
| 	{"Zoom", (struct key[]) { | 	{"Zoom", (struct key[]) { | ||||||
| 		{"<control>0", "Set zoom to 100%"}, | 		{"<Primary>0", "Set zoom to 100%"}, | ||||||
| 		{"1...9", "Set zoom to N:1"}, | 		{"1...9", "Set zoom to N:1"}, | ||||||
| 		{"plus <control>plus", "Zoom in"}, | 		{"plus <Primary>plus", "Zoom in"}, | ||||||
| 		{"minus <control>minus", "Zoom out"}, | 		{"minus <Primary>minus", "Zoom out"}, | ||||||
| 		{"w", "Zoom to fit width if larger"}, | 		{"w", "Zoom to fit width if larger"}, | ||||||
| 		{"h", "Zoom to fit height if larger"}, | 		{"h", "Zoom to fit height if larger"}, | ||||||
| 		{} | 		{} | ||||||
| @ -175,10 +175,11 @@ static struct key_group help_keys_viewer[] = { | |||||||
| 		{} | 		{} | ||||||
| 	}}, | 	}}, | ||||||
| 	{"Tools", (struct key[]) { | 	{"Tools", (struct key[]) { | ||||||
| 		{"<control>p", "Print..."}, | 		{"<Primary>c", "Copy frame to clipboard"}, | ||||||
| 		{"<control>s", "Save page as..."}, | 		{"<Primary>p", "Print..."}, | ||||||
| 		{"<control><shift>s", "Save frame as..."}, | 		{"<Primary>s", "Save page as..."}, | ||||||
| 		{"<alt>Return", "Show file information"}, | 		{"<Primary><Shift>s", "Save frame as..."}, | ||||||
|  | 		{"<Alt>Return", "Show file information"}, | ||||||
| 		{} | 		{} | ||||||
| 	}}, | 	}}, | ||||||
| 	{} | 	{} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user