implement slider to select number of copies. limits and default specified in .ini
This commit is contained in:
parent
4f17559d92
commit
a751a991d2
7 changed files with 124 additions and 10 deletions
|
@ -13,6 +13,9 @@ screensaver_file = /home/fraxinas/Desktop/Troye Sivan - Youth (1080p AAC).mkv
|
|||
|
||||
[printer]
|
||||
backend = mitsu9550
|
||||
copies_min = 1
|
||||
copies_max = 5
|
||||
copies_default = 2
|
||||
dpi = 346
|
||||
width = 2100
|
||||
height = 1400
|
||||
|
@ -48,3 +51,5 @@ Can't spawn %s = Fehler beim Starten von %s
|
|||
Can't print, no printer connected! = Kann nicht Drucken weil kein Drucker verbunden ist!
|
||||
Can't print, out of paper! = Kann nicht Drucken weil kein Papier übrig ist!
|
||||
No printer configured! = Kein Drucker konfiguriert!
|
||||
1 print = 1 Abzug
|
||||
%d prints = %d Abzüge
|
||||
|
|
37
photobooth.c
37
photobooth.c
|
@ -55,6 +55,7 @@ struct _PhotoBoothPrivate
|
|||
guint save_filename_count;
|
||||
|
||||
gchar *printer_backend;
|
||||
gint print_copies_min, print_copies_default, print_copies_max, print_copies;
|
||||
gint print_dpi, print_width, print_height;
|
||||
gdouble print_x_offset, print_y_offset;
|
||||
gchar *print_icc_profile;
|
||||
|
@ -224,6 +225,8 @@ static void photo_booth_init (PhotoBooth *pb)
|
|||
priv->preview_fps = PREVIEW_FPS;
|
||||
priv->preview_width = PREVIEW_WIDTH;
|
||||
priv->preview_height = PREVIEW_HEIGHT;
|
||||
priv->print_copies_min = priv->print_copies_max = priv->print_copies_default = 1;
|
||||
priv->print_copies = 1;
|
||||
priv->print_dpi = PRINT_DPI;
|
||||
priv->print_width = PRINT_WIDTH;
|
||||
priv->print_height = PRINT_HEIGHT;
|
||||
|
@ -326,6 +329,7 @@ static void photo_booth_dispose (GObject *object)
|
|||
g_free (priv->overlay_image);
|
||||
g_free (priv->save_path_template);
|
||||
g_hash_table_destroy (G_strings_table);
|
||||
G_strings_table = NULL;
|
||||
g_mutex_clear (&priv->processing_mutex);
|
||||
g_mutex_clear (&priv->upload_mutex);
|
||||
G_OBJECT_CLASS (photo_booth_parent_class)->dispose (object);
|
||||
|
@ -429,6 +433,9 @@ void photo_booth_load_settings (PhotoBooth *pb, const gchar *filename)
|
|||
if (g_key_file_has_group (gkf, "printer"))
|
||||
{
|
||||
priv->printer_backend = g_key_file_get_string (gkf, "printer", "backend", NULL);
|
||||
priv->print_copies_min = g_key_file_get_integer (gkf, "printer", "copies_min", NULL);
|
||||
priv->print_copies_max = g_key_file_get_integer (gkf, "printer", "copies_max", NULL);
|
||||
priv->print_copies_default = g_key_file_get_integer (gkf, "printer", "copies_default", NULL);
|
||||
priv->print_dpi = g_key_file_get_integer (gkf, "printer", "dpi", NULL);
|
||||
priv->print_width = g_key_file_get_integer (gkf, "printer", "width", NULL);
|
||||
priv->print_height = g_key_file_get_integer (gkf, "printer", "height", NULL);
|
||||
|
@ -1511,6 +1518,8 @@ static GstPadProbeReturn photo_booth_catch_photo_buffer (GstPad * pad, GstPadPro
|
|||
{
|
||||
photo_booth_change_state (pb, PB_STATE_ASK_PRINT);
|
||||
GST_DEBUG_OBJECT (pb, "second buffer caught -> will be caught for printing. waiting for answer, hide spinner");
|
||||
if (priv->print_copies_min != priv->print_copies_max)
|
||||
photo_booth_window_set_copies_show (priv->win, priv->print_copies_min, priv->print_copies_max, priv->print_copies_default);
|
||||
photo_booth_window_set_spinner (priv->win, FALSE);
|
||||
break;
|
||||
}
|
||||
|
@ -1717,8 +1726,11 @@ void photo_booth_cancel (PhotoBooth *pb)
|
|||
priv = photo_booth_get_instance_private (pb);
|
||||
switch (priv->state) {
|
||||
case PB_STATE_ASK_PRINT:
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (priv->win->button_print));
|
||||
photo_booth_window_get_copies_hide (priv->win);
|
||||
break;
|
||||
}
|
||||
case PB_STATE_ASK_UPLOAD:
|
||||
gtk_widget_hide (GTK_WIDGET (priv->win->button_upload));
|
||||
break;
|
||||
|
@ -1728,21 +1740,32 @@ void photo_booth_cancel (PhotoBooth *pb)
|
|||
SEND_COMMAND (pb, CONTROL_UNPAUSE);
|
||||
}
|
||||
|
||||
void photo_booth_copies_value_changed (GtkRange *range, PhotoBoothWindow *win)
|
||||
{
|
||||
PhotoBooth *pb = PHOTO_BOOTH_FROM_WINDOW (win);
|
||||
PhotoBoothPrivate *priv;
|
||||
priv = photo_booth_get_instance_private (pb);
|
||||
priv->print_copies = (int) gtk_range_get_value (range);
|
||||
GST_DEBUG_OBJECT (range, "\n\nphoto_booth_copies_value_changed value=%d", priv->print_copies);
|
||||
}
|
||||
|
||||
#define ALWAYS_PRINT_DIALOG 1
|
||||
|
||||
static void photo_booth_print (PhotoBooth *pb)
|
||||
{
|
||||
PhotoBoothPrivate *priv;
|
||||
gint num_copies = 0;
|
||||
priv = photo_booth_get_instance_private (pb);
|
||||
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pb->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "photo_booth_photo_print");
|
||||
photo_booth_get_printer_status (pb);
|
||||
GST_INFO_OBJECT (pb, "PRINT! prints_remaining=%i", priv->prints_remaining);
|
||||
gtk_widget_hide (GTK_WIDGET (priv->win->button_print));
|
||||
num_copies = photo_booth_window_get_copies_hide (priv->win);
|
||||
|
||||
#ifdef ALWAYS_PRINT_DIALOG
|
||||
if (1)
|
||||
#else
|
||||
if (priv->prints_remaining > 1)
|
||||
if (priv->prints_remaining > num_copies)
|
||||
#endif
|
||||
{
|
||||
gtk_label_set_text (priv->win->status, _("Printing..."));
|
||||
|
@ -1759,13 +1782,14 @@ static void photo_booth_print (PhotoBooth *pb)
|
|||
printop = gtk_print_operation_new ();
|
||||
|
||||
if (priv->printer_settings != NULL)
|
||||
{
|
||||
// action = GTK_PRINT_OPERATION_ACTION_PRINT;
|
||||
gtk_print_operation_set_print_settings (printop, priv->printer_settings);
|
||||
}
|
||||
action = GTK_PRINT_OPERATION_ACTION_PRINT;
|
||||
else
|
||||
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
|
||||
{
|
||||
priv->printer_settings = gtk_print_settings_new ();
|
||||
action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
|
||||
}
|
||||
|
||||
gtk_print_operation_set_print_settings (printop, priv->printer_settings);
|
||||
g_signal_connect (printop, "begin_print", G_CALLBACK (photo_booth_begin_print), NULL);
|
||||
g_signal_connect (printop, "draw_page", G_CALLBACK (photo_booth_draw_page), pb);
|
||||
g_signal_connect (printop, "done", G_CALLBACK (photo_booth_print_done), pb);
|
||||
|
@ -1778,6 +1802,7 @@ static void photo_booth_print (PhotoBooth *pb)
|
|||
gtk_print_operation_set_default_page_setup (printop, page_setup);
|
||||
gtk_print_operation_set_use_full_page (printop, TRUE);
|
||||
gtk_print_operation_set_unit (printop, GTK_UNIT_POINTS);
|
||||
gtk_print_settings_set_n_copies (priv->printer_settings, num_copies);
|
||||
|
||||
res = gtk_print_operation_run (printop, action, GTK_WINDOW (priv->win), &print_error);
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||
|
|
|
@ -39,3 +39,15 @@ button.cancel {
|
|||
font-size: 10px;
|
||||
}
|
||||
|
||||
.copies value {
|
||||
/* background-color: #df784e; */
|
||||
font-size: 24px;
|
||||
color: rgba (188, 255, 188, 0.8);
|
||||
text-shadow: 2px 2px 1px #0c0d24;
|
||||
color: #BBFFBB;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.copies marks.bottom mark indicator {
|
||||
color: rgb (0, 50, 0);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef enum
|
|||
gchar *G_template_filename;
|
||||
gchar *G_stylesheet_filename;
|
||||
GHashTable *G_strings_table;
|
||||
#define _(key) (g_hash_table_contains (G_strings_table, key) ? g_hash_table_lookup (G_strings_table, key) : key)
|
||||
#define _(key) (G_strings_table && g_hash_table_contains (G_strings_table, key) ? g_hash_table_lookup (G_strings_table, key) : key)
|
||||
|
||||
#define PHOTO_BOOTH_TYPE (photo_booth_get_type ())
|
||||
#define PHOTO_BOOTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),PHOTO_BOOTH_TYPE,PhotoBooth))
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkAdjustment" id="adjustment_copies">
|
||||
<property name="lower">1</property>
|
||||
<property name="upper">1</property>
|
||||
<property name="value">1</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">1</property>
|
||||
<property name="page_size">0</property>
|
||||
</object>
|
||||
<template class="PhotoBoothWindow" parent="GtkApplicationWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title">Schaffenburg Photobooth</property>
|
||||
|
@ -13,6 +21,9 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="events">GDK_BUTTON_PRESS_MASK</property>
|
||||
<signal name="button-press-event" handler="photo_booth_background_clicked" swapped="no"/>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="overlay">
|
||||
<object class="GtkLabel" id="countdown_label">
|
||||
<property name="width_request">400</property>
|
||||
|
@ -46,7 +57,6 @@
|
|||
<property name="label" translatable="yes">Ausdrucken!</property>
|
||||
<property name="width_request">360</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
|
@ -66,7 +76,6 @@
|
|||
<property name="label" translatable="yes">Abbrechen</property>
|
||||
<property name="width_request">360</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
|
@ -86,7 +95,6 @@
|
|||
<property name="label" translatable="yes">Auf Facebook teilen</property>
|
||||
<property name="width_request">360</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
|
@ -101,6 +109,28 @@
|
|||
<property name="y">700</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="copies">
|
||||
<property name="width_request">1120</property>
|
||||
<property name="height_request">80</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment_copies</property>
|
||||
<property name="show_fill_level">True</property>
|
||||
<property name="round_digits">0</property>
|
||||
<property name="digits">0</property>
|
||||
<property name="value_pos">bottom</property>
|
||||
<signal name="format-value" handler="photo_booth_window_format_copies_value" swapped="no"/>
|
||||
<signal name="value-changed" handler="photo_booth_copies_value_changed" swapped="no"/>
|
||||
<style>
|
||||
<class name="copies"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x">80</property>
|
||||
<property name="y">100</property>
|
||||
</packing>
|
||||
</child>
|
||||
<style>
|
||||
<class name="transparentbg"/>
|
||||
</style>
|
||||
|
|
|
@ -26,6 +26,7 @@ struct _PhotoBoothWindowPrivate
|
|||
GtkWidget *overlay;
|
||||
GtkWidget *spinner, *statusbar;
|
||||
GtkLabel *countdown_label;
|
||||
GtkScale *copies;
|
||||
gint countdown;
|
||||
};
|
||||
|
||||
|
@ -62,6 +63,7 @@ static void photo_booth_window_class_init (PhotoBoothWindowClass *klass)
|
|||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, overlay);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, spinner);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, countdown_label);
|
||||
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, copies);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, button_cancel);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, button_print);
|
||||
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), PhotoBoothWindow, button_upload);
|
||||
|
@ -75,6 +77,8 @@ static void photo_booth_window_init (PhotoBoothWindow *win)
|
|||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
PhotoBoothWindowPrivate *priv;
|
||||
priv = photo_booth_window_get_instance_private (win);
|
||||
GST_DEBUG_OBJECT (priv->countdown_label, "countdown_label @%p", priv->countdown_label);
|
||||
GST_DEBUG_OBJECT (priv->copies, "copies @%p", priv->copies);
|
||||
GdkScreen *screen = gdk_screen_get_default ();
|
||||
gtk_window_fullscreen_on_monitor (GTK_WINDOW (win), screen, 0);
|
||||
if (G_stylesheet_filename)
|
||||
|
@ -187,6 +191,42 @@ void photo_booth_window_start_countdown (PhotoBoothWindow *win, gint count)
|
|||
g_timeout_add (1000, (GSourceFunc) _pbw_tick_countdown, win);
|
||||
}
|
||||
|
||||
void photo_booth_window_set_copies_show (PhotoBoothWindow *win, gint min, gint max, gint def)
|
||||
{
|
||||
PhotoBoothWindowPrivate *priv;
|
||||
priv = photo_booth_window_get_instance_private (win);
|
||||
GST_DEBUG ("photo_booth_window_set_copies_limit [%i-%i]", min, max);
|
||||
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (priv->copies));
|
||||
gtk_adjustment_set_lower (adj, (gdouble) min);
|
||||
gtk_adjustment_set_upper (adj, (gdouble) max);
|
||||
priv = photo_booth_window_get_instance_private (win);
|
||||
gtk_range_set_value (GTK_RANGE (priv->copies), (gdouble) def);
|
||||
for (int x = min; x <= max; x++)
|
||||
{
|
||||
gtk_scale_add_mark (priv->copies, (gdouble) x, GTK_POS_BOTTOM, NULL);
|
||||
}
|
||||
gtk_widget_show (GTK_WIDGET (priv->copies));
|
||||
}
|
||||
|
||||
gint photo_booth_window_get_copies_hide (PhotoBoothWindow *win)
|
||||
{
|
||||
PhotoBoothWindowPrivate *priv;
|
||||
gint copies = 0;
|
||||
priv = photo_booth_window_get_instance_private (win);
|
||||
copies = (gint) gtk_range_get_value (GTK_RANGE (priv->copies));
|
||||
gtk_widget_hide (GTK_WIDGET (priv->copies));
|
||||
GST_DEBUG ("photo_booth_window_get_copies_hide %i", copies);
|
||||
return copies;
|
||||
}
|
||||
|
||||
gchar* photo_booth_window_format_copies_value (GtkScale *scale, gdouble value, gpointer user_data)
|
||||
{
|
||||
int intval = (int) value;
|
||||
if (intval == 1)
|
||||
return g_strdup_printf (_("1 print"));
|
||||
return g_strdup_printf (_("%d prints"), intval);
|
||||
}
|
||||
|
||||
PhotoBoothWindow * photo_booth_window_new (PhotoBooth *pb)
|
||||
{
|
||||
return g_object_new (PHOTO_BOOTH_WINDOW_TYPE, "application", pb, NULL);
|
||||
|
|
|
@ -50,6 +50,8 @@ void photo_booth_window_set_spinner (PhotoBoothWindow *w
|
|||
void photo_booth_window_start_countdown (PhotoBoothWindow *win, gint count);
|
||||
void photo_booth_window_hide_cursor (PhotoBoothWindow *win);
|
||||
void photo_booth_window_show_cursor (PhotoBoothWindow *win);
|
||||
void photo_booth_window_set_copies_show (PhotoBoothWindow *win, gint min, gint max, gint def);
|
||||
gint photo_booth_window_get_copies_hide (PhotoBoothWindow *win);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue