1 /* 2 * Photos - access, organize and share your photos on GNOME 3 * Copyright © 2012 – 2020 Red Hat, Inc. 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 /* Based on code from: 20 * + Documents 21 * + Eye of GNOME 22 * + Shotwell 23 */ 24 25 #ifndef PHOTOS_UTILS_H 26 #define PHOTOS_UTILS_H 27 28 #include <cairo.h> 29 #include <gdk-pixbuf/gdk-pixbuf.h> 30 #include <gio/gio.h> 31 #include <glib.h> 32 #include <gtk/gtk.h> 33 34 #include "photos-base-item.h" 35 #include "photos-base-manager.h" 36 #include "photos-item-manager.h" 37 #include "photos-offset-controller.h" 38 #include "photos-tracker-controller.h" 39 40 G_BEGIN_DECLS 41 42 #define PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME "photos-base-item" 43 #define PHOTOS_SHARE_POINT_EXTENSION_POINT_NAME "photos-share-point" 44 #define PHOTOS_SHARE_POINT_ONLINE_EXTENSION_POINT_NAME "photos-share-point-online" 45 #define PHOTOS_TOOL_EXTENSION_POINT_NAME "photos-tool" 46 #define PHOTOS_TRACKER_CONTROLLER_EXTENSION_POINT_NAME "photos-tracker-controller" 47 48 #define PHOTOS_COLLECTION_SCREENSHOT "http://tracker.api.gnome.org/ontology/v3/nfo#image-category-screenshot" 49 #define PHOTOS_EXPORT_SUBPATH "Exports" 50 #define PHOTOS_PICTURES_GRAPH "http://tracker.api.gnome.org/ontology/v3/tracker#Pictures" 51 52 typedef enum 53 { 54 PHOTOS_ZOOM_EVENT_NONE, 55 PHOTOS_ZOOM_EVENT_KEYBOARD_ACCELERATOR, 56 PHOTOS_ZOOM_EVENT_MOUSE_CLICK, 57 PHOTOS_ZOOM_EVENT_SCROLL, 58 PHOTOS_ZOOM_EVENT_TOUCH 59 } PhotosZoomEvent; 60 61 GdkPixbuf *photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size); 62 63 gchar *photos_utils_convert_path_to_uri (const gchar *path); 64 65 GStrv photos_utils_convert_paths_to_uris (const gchar *const *paths); 66 67 GIcon *photos_utils_create_collection_icon (gint base_size, GList *pixbufs); 68 69 GdkPixbuf *photos_utils_create_placeholder_icon_for_scale (const gchar *name, gint size, gint scale); 70 71 GIcon *photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size, gint scale); 72 73 gboolean photos_utils_create_thumbnail (GFile *file, 74 const gchar *mime_type, 75 gint64 mtime, 76 GQuark orientation, 77 gint64 original_height, 78 gint64 original_width, 79 const gchar *const *pipeline_uris, 80 const gchar *thumbnail_path, 81 GCancellable *cancellable, 82 GError **error); 83 84 GVariant *photos_utils_create_zoom_target_value (gdouble delta, PhotosZoomEvent event); 85 86 GIcon *photos_utils_get_icon_from_item (PhotosBaseItem *item); 87 88 gdouble photos_utils_get_zoom_delta (GVariant *dictionary); 89 90 PhotosZoomEvent photos_utils_get_zoom_event (GVariant *dictionary); 91 92 GdkPixbuf *photos_utils_downscale_pixbuf_for_scale (GdkPixbuf *pixbuf, gint size, gint scale); 93 94 void photos_utils_draw_rectangle_handles (cairo_t *cr, 95 gdouble x, 96 gdouble y, 97 gdouble width, 98 gdouble height, 99 gdouble offset, 100 gdouble radius); 101 102 void photos_utils_draw_rectangle_thirds (cairo_t *cr, 103 gdouble x, 104 gdouble y, 105 gdouble width, 106 gdouble height); 107 108 void photos_utils_ensure_builtins (void); 109 110 void photos_utils_ensure_extension_points (void); 111 112 gdouble photos_utils_eval_radial_line (gdouble crop_center_x, 113 gdouble crop_center_y, 114 gdouble corner_x, 115 gdouble corner_y, 116 gdouble event_x); 117 118 gboolean photos_utils_file_copy_as_thumbnail (GFile *source, 119 GFile *destination, 120 const gchar *original_uri, 121 gint64 original_height, 122 gint64 original_width, 123 GCancellable *cancellable, 124 GError **error); 125 126 void photos_utils_get_controller (PhotosWindowMode mode, 127 PhotosOffsetController **out_offset_cntrlr, 128 PhotosTrackerController **out_trk_cntrlr); 129 130 gdouble photos_utils_get_double_from_sparql_cursor_with_default (TrackerSparqlCursor *cursor, 131 PhotosQueryColumns column, 132 gdouble default_value); 133 134 gchar *photos_utils_get_extension_from_mime_type (const gchar *mime_type); 135 136 137 gint photos_utils_get_icon_size (void); 138 139 gint photos_utils_get_icon_size_unscaled (void); 140 141 gint64 photos_utils_get_integer_from_sparql_cursor_with_default (TrackerSparqlCursor *cursor, 142 PhotosQueryColumns column, 143 gint64 default_value); 144 145 gint64 photos_utils_get_mtime_from_sparql_cursor (TrackerSparqlCursor *cursor); 146 147 char* photos_utils_get_pixbuf_common_suffix (GdkPixbufFormat *format); 148 149 const gchar *photos_utils_get_provider_name (PhotosBaseManager *src_mngr, PhotosBaseItem *item); 150 151 gboolean photos_utils_get_selection_mode (void); 152 153 GList *photos_utils_get_urns_from_items (GList *items); 154 155 const gchar *photos_utils_get_version (void); 156 157 gboolean photos_utils_is_flatpak (void); 158 159 void photos_utils_launch_online_accounts (const gchar *account_id); 160 161 void photos_utils_list_box_header_func (GtkListBoxRow *row, 162 GtkListBoxRow *before, 163 gpointer user_data); 164 165 GAppLaunchContext *photos_utils_new_app_launch_context_from_widget (GtkWidget *widget); 166 167 void photos_utils_object_list_free_full (GList *objects); 168 169 gchar *photos_utils_print_zoom_action_detailed_name (const gchar *action_name, 170 gdouble delta, 171 PhotosZoomEvent event); 172 173 gboolean photos_utils_scrolled_window_can_scroll (GtkScrolledWindow *scrolled_window); 174 175 void photos_utils_scrolled_window_scroll (GtkScrolledWindow *scrolled_window, 176 gdouble delta_x, 177 gdouble delta_y); 178 179 void photos_utils_set_edited_name (const gchar *urn, const gchar *title); 180 181 void photos_utils_set_favorite (const gchar *urn, gboolean is_favorite); 182 183 gboolean photos_utils_set_string (gchar **string_ptr, const gchar *new_string); 184 185 gboolean photos_utils_take_string (gchar **string_ptr, gchar *new_string); 186 187 G_END_DECLS 188 189 #endif /* PHOTOS_UTILS_H */ 190