Skip to content

Commit

Permalink
Alternative splash screen remaining clock
Browse files Browse the repository at this point in the history
A simpler way than the svg and also highly portable would be an implementation via cairo as we do for
other "icons".
  • Loading branch information
jenshannoschwalm committed Dec 4, 2024
1 parent d19e145 commit 336efd9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 122 deletions.
114 changes: 0 additions & 114 deletions data/pixmaps/clock.svg

This file was deleted.

25 changes: 25 additions & 0 deletions src/dtgtk/paint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,31 @@ void dtgtk_cairo_paint_color_harmony(cairo_t *cr, gint x, gint y, gint w, gint h
FINISH
}

void dtgtk_cairo_paint_clock(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
{
PREAMBLE(1.2, 1.2, 0.5, 0.5)

static int clock = 0;

cairo_arc(cr, .0, .0, 0.5, 0, 2 * M_PI);
cairo_stroke(cr);

for(int i = 0; i < 12; i++)
{
cairo_arc(cr, .0, .35, i % 3 ? .03 : .05, 0, 2 * M_PI);
cairo_fill(cr);
cairo_rotate(cr, M_PI / 6);
}
cairo_rotate(cr, M_PI / 6 * clock++);
cairo_move_to(cr, 0.075, 0.0);
cairo_line_to(cr, 0.0, 0.4);
cairo_line_to(cr, -0.075, 0.0);
cairo_line_to(cr, 0.0, -0.05);
cairo_fill(cr);

FINISH
}

void dtgtk_cairo_paint_filmstrip(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
{
const double sw = 0.6;
Expand Down
2 changes: 2 additions & 0 deletions src/dtgtk/paint.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void dtgtk_cairo_paint_jzazbz(cairo_t *cr, gint x, gint y, gint w, gint h, gint
void dtgtk_cairo_paint_ryb(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
/** paint color harmony icon */
void dtgtk_cairo_paint_color_harmony(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
/** paint moving clock */
void dtgtk_cairo_paint_clock(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);

/** paint active modulegroup icon */
void dtgtk_cairo_paint_modulegroup_active(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data);
Expand Down
12 changes: 4 additions & 8 deletions src/gui/splash.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "control/conf.h"
#include "gui/gtk.h"
#include "dtgtk/button.h"
#include "splash.h"
#ifdef GDK_WINDOWING_QUARTZ
#include "osx/osx.h"
Expand Down Expand Up @@ -235,21 +236,15 @@ void darktable_splash_screen_create(GtkWindow *parent_window,
// and make that the top portion of the splash screen
gtk_box_pack_start(content, GTK_WIDGET(main_box), FALSE, FALSE, 0);
#endif

GtkWidget *hbar = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_name(hbar, "splashscreen-separator");
gtk_widget_show(hbar);
gtk_box_pack_start(content, hbar, FALSE, FALSE, 0);
gtk_box_pack_start(content, progress_text, FALSE, FALSE, 0);

GtkWidget *clock;
gchar *clock_file = g_strdup_printf("%s/pixmaps/clock.svg", darktable.datadir);
GdkPixbuf *clock_image = gdk_pixbuf_new_from_file_at_size(clock_file, -1, 20, NULL);
clock = gtk_image_new_from_pixbuf(clock_image);
g_free(clock_file);
g_object_unref(clock_image);

remaining_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_pack_start(remaining_box, GTK_WIDGET(clock), FALSE, FALSE, 0);
gtk_box_pack_start(remaining_box, dtgtk_button_new(dtgtk_cairo_paint_clock, 0, 0), FALSE, FALSE, 0);
gtk_box_pack_start(remaining_box, remaining_text, FALSE, FALSE, 0);
gtk_box_pack_start(content, GTK_WIDGET(remaining_box), FALSE, FALSE, 0);
gtk_widget_set_halign(GTK_WIDGET(remaining_box), GTK_ALIGN_CENTER);
Expand Down Expand Up @@ -296,6 +291,7 @@ void darktable_splash_screen_set_progress_percent(const char *msg,
char *rem_text = g_strdup_printf(" %4d:%02d", minutes, seconds);
gtk_label_set_text(GTK_LABEL(remaining_text), rem_text);
g_free(rem_text);
gtk_widget_queue_draw(GTK_WIDGET(remaining_box));
}
else
{
Expand Down

0 comments on commit 336efd9

Please sign in to comment.