/* PIKA - Photo and Image Kooker Application * a rebranding of The GNU Image Manipulation Program (created with heckimp) * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio * * Original copyright, applying to most contents (license remains unchanged): * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * pikadocumentview.c * Copyright (C) 2001 Michael Natterer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "config.h" #include #include #include "libpikawidgets/pikawidgets.h" #include "widgets-types.h" #include "core/pikacontainer.h" #include "core/pikacontext.h" #include "core/pikaimage.h" #include "pikacontainerview.h" #include "pikaeditor.h" #include "pikaimageview.h" #include "pikadnd.h" #include "pikamenufactory.h" #include "pikauimanager.h" #include "pikaviewrenderer.h" #include "pika-intl.h" static void pika_image_view_activate_item (PikaContainerEditor *editor, PikaViewable *viewable); G_DEFINE_TYPE (PikaImageView, pika_image_view, PIKA_TYPE_CONTAINER_EDITOR) #define parent_class pika_image_view_parent_class static void pika_image_view_class_init (PikaImageViewClass *klass) { PikaContainerEditorClass *editor_class = PIKA_CONTAINER_EDITOR_CLASS (klass); editor_class->activate_item = pika_image_view_activate_item; } static void pika_image_view_init (PikaImageView *view) { view->raise_button = NULL; view->new_button = NULL; view->delete_button = NULL; } GtkWidget * pika_image_view_new (PikaViewType view_type, PikaContainer *container, PikaContext *context, gint view_size, gint view_border_width, PikaMenuFactory *menu_factory) { PikaImageView *image_view; PikaContainerEditor *editor; g_return_val_if_fail (PIKA_IS_CONTAINER (container), NULL); g_return_val_if_fail (PIKA_IS_CONTEXT (context), NULL); g_return_val_if_fail (view_size > 0 && view_size <= PIKA_VIEWABLE_MAX_PREVIEW_SIZE, NULL); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= PIKA_VIEW_MAX_BORDER_WIDTH, NULL); g_return_val_if_fail (menu_factory == NULL || PIKA_IS_MENU_FACTORY (menu_factory), NULL); image_view = g_object_new (PIKA_TYPE_IMAGE_VIEW, "view-type", view_type, "container", container, "context", context, "view-size", view_size, "view-border-width", view_border_width, "menu-factory", menu_factory, "menu-identifier", "", "ui-path", "/images-popup", NULL); editor = PIKA_CONTAINER_EDITOR (image_view); image_view->raise_button = pika_editor_add_action_button (PIKA_EDITOR (editor->view), "images", "images-raise-views", NULL); image_view->new_button = pika_editor_add_action_button (PIKA_EDITOR (editor->view), "images", "images-new-view", NULL); image_view->delete_button = pika_editor_add_action_button (PIKA_EDITOR (editor->view), "images", "images-delete", NULL); if (view_type == PIKA_VIEW_TYPE_LIST) { GtkWidget *dnd_widget; dnd_widget = pika_container_view_get_dnd_widget (editor->view); pika_dnd_xds_source_add (dnd_widget, (PikaDndDragViewableFunc) pika_dnd_get_drag_viewable, NULL); } pika_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->raise_button), PIKA_TYPE_IMAGE); pika_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->new_button), PIKA_TYPE_IMAGE); pika_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->delete_button), PIKA_TYPE_IMAGE); pika_ui_manager_update (pika_editor_get_ui_manager (PIKA_EDITOR (editor->view)), editor); return GTK_WIDGET (image_view); } static void pika_image_view_activate_item (PikaContainerEditor *editor, PikaViewable *viewable) { PikaImageView *view = PIKA_IMAGE_VIEW (editor); PikaContainer *container; if (PIKA_CONTAINER_EDITOR_CLASS (parent_class)->activate_item) PIKA_CONTAINER_EDITOR_CLASS (parent_class)->activate_item (editor, viewable); container = pika_container_view_get_container (editor->view); if (viewable && pika_container_have (container, PIKA_OBJECT (viewable))) { gtk_button_clicked (GTK_BUTTON (view->raise_button)); } }