Add button for last image and directory
This commit is contained in:
parent
09ed10d85f
commit
83c86ac45d
39
camera.glade
39
camera.glade
|
@ -138,10 +138,45 @@
|
|||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkButton" id="open_directory">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-open</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkButton" id="open_last">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="thumb_last">
|
||||
<property name="width-request">24</property>
|
||||
<property name="height-request">24</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
37
main.c
37
main.c
|
@ -74,12 +74,14 @@ static int current_is_rear = 1;
|
|||
static cairo_surface_t *surface = NULL;
|
||||
static int preview_width = -1;
|
||||
static int preview_height = -1;
|
||||
static char *last_path = NULL;
|
||||
|
||||
// Widgets
|
||||
GtkWidget *preview;
|
||||
GtkWidget *error_box;
|
||||
GtkWidget *error_message;
|
||||
GtkWidget *main_stack;
|
||||
GtkWidget *thumb_last;
|
||||
|
||||
static int
|
||||
xioctl(int fd, int request, void *arg)
|
||||
|
@ -374,6 +376,7 @@ process_image(const int *p, int size)
|
|||
char timestamp[30];
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *pixbufrot;
|
||||
GdkPixbuf *thumb;
|
||||
GError *error = NULL;
|
||||
double scale;
|
||||
cairo_t *cr;
|
||||
|
@ -413,7 +416,10 @@ process_image(const int *p, int size)
|
|||
strftime(timestamp, 30, "%Y%m%d%H%M%S", &tim);
|
||||
sprintf(fname, "%s/Pictures/IMG%s.jpg", getenv("HOME"), timestamp);
|
||||
printf("Saving image\n");
|
||||
thumb = gdk_pixbuf_scale_simple(pixbufrot, 24, 24, GDK_INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(thumb_last), thumb);
|
||||
gdk_pixbuf_save(pixbufrot, fname, "jpeg", &error, "quality", "95", NULL);
|
||||
last_path = strdup(fname);
|
||||
if (error != NULL) {
|
||||
g_printerr("%s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
|
@ -812,6 +818,32 @@ find_media_fd()
|
|||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
on_open_last_clicked(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
char uri[270];
|
||||
GError *error = NULL;
|
||||
|
||||
if(!last_path) {
|
||||
return;
|
||||
}
|
||||
sprintf(uri, "file://%s", last_path);
|
||||
if(!g_app_info_launch_default_for_uri(uri, NULL, &error)){
|
||||
g_printerr("Could not launch image viewer: %s\n", error->message);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
on_open_directory_clicked(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
char uri[270];
|
||||
GError *error = NULL;
|
||||
sprintf(uri, "file://%s/Pictures", getenv("HOME"));
|
||||
if(!g_app_info_launch_default_for_uri(uri, NULL, &error)){
|
||||
g_printerr("Could not launch image viewer: %s\n", error->message);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
on_shutter_clicked(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
|
@ -938,16 +970,21 @@ main(int argc, char *argv[])
|
|||
GtkWidget *settings_btn = GTK_WIDGET(gtk_builder_get_object(builder, "settings"));
|
||||
GtkWidget *settings_back = GTK_WIDGET(gtk_builder_get_object(builder, "settings_back"));
|
||||
GtkWidget *error_close = GTK_WIDGET(gtk_builder_get_object(builder, "error_close"));
|
||||
GtkWidget *open_last = GTK_WIDGET(gtk_builder_get_object(builder, "open_last"));
|
||||
GtkWidget *open_directory = GTK_WIDGET(gtk_builder_get_object(builder, "open_directory"));
|
||||
preview = GTK_WIDGET(gtk_builder_get_object(builder, "preview"));
|
||||
error_box = GTK_WIDGET(gtk_builder_get_object(builder, "error_box"));
|
||||
error_message = GTK_WIDGET(gtk_builder_get_object(builder, "error_message"));
|
||||
main_stack = GTK_WIDGET(gtk_builder_get_object(builder, "main_stack"));
|
||||
thumb_last = GTK_WIDGET(gtk_builder_get_object(builder, "thumb_last"));
|
||||
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||
g_signal_connect(shutter, "clicked", G_CALLBACK(on_shutter_clicked), NULL);
|
||||
g_signal_connect(error_close, "clicked", G_CALLBACK(on_error_close_clicked), NULL);
|
||||
g_signal_connect(switch_btn, "clicked", G_CALLBACK(on_camera_switch_clicked), NULL);
|
||||
g_signal_connect(settings_btn, "clicked", G_CALLBACK(on_settings_btn_clicked), NULL);
|
||||
g_signal_connect(settings_back, "clicked", G_CALLBACK(on_back_clicked), NULL);
|
||||
g_signal_connect(open_last, "clicked", G_CALLBACK(on_open_last_clicked), NULL);
|
||||
g_signal_connect(open_directory, "clicked", G_CALLBACK(on_open_directory_clicked), NULL);
|
||||
g_signal_connect(preview, "draw", G_CALLBACK(preview_draw), NULL);
|
||||
g_signal_connect(preview, "configure-event", G_CALLBACK(preview_configure), NULL);
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 16.933333 16.933334"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 8.4666665 8.466667"
|
||||
version="1.1"
|
||||
id="svg8">
|
||||
<defs
|
||||
|
@ -25,14 +25,15 @@
|
|||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1">
|
||||
id="layer1"
|
||||
transform="matrix(0.49996357,0,0,0.49996357,0.01938007,0.00978634)">
|
||||
<path
|
||||
id="path833"
|
||||
style="fill:#bebebe;stroke-width:0.999999;fill-opacity:1"
|
||||
d="M 31.810547 0.07421875 A 31.916231 31.916231 0 0 0 0.14648438 31.990234 A 31.916231 31.916231 0 0 0 32.0625 63.90625 A 31.916231 31.916231 0 0 0 63.978516 31.990234 A 31.916231 31.916231 0 0 0 32.0625 0.07421875 A 31.916231 31.916231 0 0 0 31.810547 0.07421875 z M 31.919922 3.578125 A 28.472441 28.472441 0 0 1 60.392578 32.050781 A 28.472441 28.472441 0 0 1 31.919922 60.523438 A 28.472441 28.472441 0 0 1 3.4472656 32.050781 A 28.472441 28.472441 0 0 1 31.919922 3.578125 z "
|
||||
style="fill:#bebebe;fill-opacity:1;stroke-width:0.999999"
|
||||
d="M 31.810547,0.07421875 A 31.916231,31.916231 0 0 0 0.14648438,31.990234 31.916231,31.916231 0 0 0 32.0625,63.90625 31.916231,31.916231 0 0 0 63.978516,31.990234 31.916231,31.916231 0 0 0 32.0625,0.07421875 a 31.916231,31.916231 0 0 0 -0.251953,0 z M 31.919922,3.578125 A 28.472441,28.472441 0 0 1 60.392578,32.050781 28.472441,28.472441 0 0 1 31.919922,60.523438 28.472441,28.472441 0 0 1 3.4472656,32.050781 28.472441,28.472441 0 0 1 31.919922,3.578125 Z"
|
||||
transform="scale(0.26458333)" />
|
||||
<circle
|
||||
style="fill:#bebebe;stroke-width:0.254438;fill-opacity:1"
|
||||
style="fill:#bebebe;fill-opacity:1;stroke-width:0.254438"
|
||||
id="path840"
|
||||
cx="8.3893003"
|
||||
cy="8.432106"
|
||||
|
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue