Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Viewnior - Fast and elegant image viewer

This is Viewnior, an image viewer program. Created to be simple, fast and elegant. It's minimalistic interface provides more screenspace for your images. Among its features are:
This is Viewnior, an image viewer program. Created to be simple, fast and elegant. Its minimalistic interface provides more screenspace for your images. Among its features are:

* Fullscreen & Slideshow
* Rotate, flip, crop, save, delete images
Expand All @@ -11,8 +11,10 @@ This is Viewnior, an image viewer program. Created to be simple, fast and elegan
* EXIF and IPTC metadata
* Simple interface
* Configurable mouse actions
* Recursively opens images in subfolders
* Updates when images are added or removed from folder

Most of the Viewnior's sources handling image viewing are adopted from the GtkImageView library by Björn Lindqvist. The files were cleaned up and modified, so that unused functionalities were removed (GtkImageToolSelector, GtkImageToolPainter, GtkZooms). Prefixes were changed from gtk_ to uni_ for clarity.
Most of the Viewnior's sources handling image viewing are adopted from the GtkImageView library by Björn Lindqvist. The files were cleaned up and modified, so that unused functionality were removed (GtkImageToolSelector, GtkImageToolPainter, GtkZooms). Prefixes were changed from gtk_ to uni_ for clarity.

## Requirements

Expand All @@ -34,4 +36,4 @@ This program is released under the terms of the [GNU General Public License](htt

object-rotate-left.png, object-rotate-right.png are taken from Elementary icon theme by ~DanRabbit (under GPL). object-flip-horizontal.png, object-flip-vertical.png are taken from Gnome icon theme (under GPL).

*Last Edited - 28 April 2018*
*Last Edited - 21 August 2018*
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

* GTK+3 migration
* Add documentation
* Add file monitoring
* Add lossless JPG rotation
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ subdir('po')
subdir('data')
subdir('man')
subdir('src')
subdir('tests')

meson.add_install_script('meson_post_install.py')
55 changes: 21 additions & 34 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <config.h>
#include <gtk/gtk.h>
#include "config.h"
#include "vnr-tree.h"
#include "vnr-window.h"
#include "vnr-message-area.h"
#include "vnr-file.h"
Expand All @@ -34,6 +35,7 @@ static gchar **files = NULL; //array of files specified to be opened
static gboolean version = FALSE;
static gboolean slideshow = FALSE;
static gboolean fullscreen = FALSE;
static gboolean recursive = FALSE;

/* List of option entries
* The only option is for specifying file to be opened. */
Expand All @@ -42,18 +44,17 @@ static GOptionEntry opt_entries[] = {
{"version", 0, 0, G_OPTION_ARG_NONE, &version, NULL, NULL},
{"slideshow", 0, 0, G_OPTION_ARG_NONE, &slideshow, NULL, NULL},
{"fullscreen", 0, 0, G_OPTION_ARG_NONE, &fullscreen, NULL, NULL},
{"recursive", 0, 0, G_OPTION_ARG_NONE, &recursive, NULL, NULL},
{NULL}
};

int
main (int argc, char *argv[])
{
int main(int argc, char *argv[]) {
GError *error = NULL;
GOptionContext *opt_context;
GtkWindow *window;

GSList *uri_list = NULL;
GList *file_list = NULL;
GNode *tree = NULL;


bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
Expand All @@ -65,15 +66,12 @@ main (int argc, char *argv[])
g_option_context_add_group (opt_context, gtk_get_option_group (TRUE));
g_option_context_parse (opt_context, &argc, &argv, &error);

if (error != NULL)
{
if(error != NULL) {
printf
("%s\nRun 'viewnior --help' to see a full list of available command line options.\n",
error->message);
return 1;
}
else if(version)
{
} else if(version) {
printf("%s\n", PACKAGE_STRING);
return 0;
}
Expand All @@ -86,47 +84,36 @@ main (int argc, char *argv[])

uri_list = vnr_tools_get_list_from_array (files);

if(uri_list != NULL)
{
if (g_slist_length(uri_list) == 1)
{
vnr_file_load_single_uri (uri_list->data, &file_list, VNR_WINDOW(window)->prefs->show_hidden, &error);
}
else
{
vnr_file_load_uri_list (uri_list, &file_list, VNR_WINDOW(window)->prefs->show_hidden, &error);
if(uri_list != NULL) {
if(g_slist_length(uri_list) == 1) {
tree = create_tree_from_single_uri (uri_list->data, VNR_WINDOW(window)->prefs->show_hidden, recursive, tree_changed_callback, window, &error);
} else {
tree = create_tree_from_uri_list (uri_list, VNR_WINDOW(window)->prefs->show_hidden, recursive, tree_changed_callback, window, &error);
}

if(error != NULL && file_list != NULL)
{
if(error != NULL && tree != NULL) {
deny_slideshow(VNR_WINDOW(window));
vnr_message_area_show(VNR_MESSAGE_AREA (VNR_WINDOW(window)->msg_area),
TRUE, error->message, TRUE);
vnr_window_set_list(VNR_WINDOW(window), file_list, TRUE);
}
else if(error != NULL)
{
vnr_window_set_tree(VNR_WINDOW(window), tree, TRUE);
} else if(error != NULL) {
deny_slideshow(VNR_WINDOW(window));
vnr_message_area_show(VNR_MESSAGE_AREA (VNR_WINDOW(window)->msg_area),
TRUE, error->message, TRUE);
}
else if(file_list == NULL)
{
} else if(tree == NULL) {
deny_slideshow(VNR_WINDOW(window));
vnr_message_area_show(VNR_MESSAGE_AREA (VNR_WINDOW(window)->msg_area),
TRUE, _("The given locations contain no images."),
TRUE);
}
else
{
vnr_window_set_list(VNR_WINDOW(window), file_list, TRUE);
} else {
vnr_window_set_tree(VNR_WINDOW(window), tree, TRUE);
}
}

VNR_WINDOW(window)->prefs->start_slideshow = slideshow;
VNR_WINDOW(window)->prefs->start_fullscreen = fullscreen;
if ( VNR_WINDOW(window)->prefs->start_maximized ) {
gtk_window_maximize(window);
if(VNR_WINDOW(window)->prefs->start_maximized) {
gtk_window_maximize(window);
}
gtk_widget_show (GTK_WIDGET (window));
gtk_main ();
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ viewnior_sources = [
'uni-image-view.c',
'vnr-message-area.c',
'vnr-properties-dialog.c',
'vnr-tree.c',
'vnr-file.c',
'uni-utils.c',
'vnr-prefs.c',
Expand Down
60 changes: 60 additions & 0 deletions src/vnr-callback-interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright © 2009-2018 Siyan Panayotov <siyan.panayotov@gmail.com>
*
* This file is part of Viewnior.
*
* Viewnior 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.
*
* Viewnior 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 Viewnior. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __CALLBACK_INTERFACE_H__
#define __CALLBACK_INTERFACE_H__

#include <glib.h>

/**
* A callback function that will be called when a file or directory with
* a file monitor have reported a change, i.e. a file or directory has
* been added or removed.
*
* @deleted@ is TRUE if a file or directory has been deleted. If it was
* created, it will be FALSE.
* @path@ is the path to the file or directory that was affected. The
* memory will be freed after the call to callback.
* @changed_node@ is the subtree that was affected. If the file or
* directory was created, then it has been added to @root@ already. If
* it was deleted, @changed_node@ has been removed from @root@ and it
* along with its subnodes have been freed. The pointer may thus point
* to an invalid structure.
* @root@ is the root node of the tree that @changed_node@ is/was part
* of.
* @data@ is user provided data that will be sent back to the callback
* function unaltered.
*/
typedef void (*callback)(gboolean deleted,
char *path,
GNode *changed_node,
GNode *root,
gpointer data);


struct MonitoringData {
gboolean include_hidden;
gboolean include_dirs;
gboolean set_file_monitor_for_file;
GNode* tree;
callback cb;
gpointer cb_data;
};

#endif /* __CALLBACK_INTERFACE_H__ */
Loading