mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make slider labels consistent in print dialog
To make this easier I created a new helper function create_label that takes printf style arguments. I assumed this would be usable in many places but ended up finding just one other obvious use for it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6a98588ed0
commit
487fe8784c
3 changed files with 24 additions and 9 deletions
|
@ -73,6 +73,8 @@ extern const char *get_active_text(GtkComboBox *);
|
||||||
extern void set_active_text(GtkComboBox *, const char *);
|
extern void set_active_text(GtkComboBox *, const char *);
|
||||||
extern GtkWidget *combo_box_with_model_and_entry(GtkListStore *);
|
extern GtkWidget *combo_box_with_model_and_entry(GtkListStore *);
|
||||||
|
|
||||||
|
extern GtkWidget *create_label(const char *fmt, ...);
|
||||||
|
|
||||||
extern gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data);
|
extern gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data);
|
||||||
|
|
||||||
unsigned int amount_selected;
|
unsigned int amount_selected;
|
||||||
|
|
|
@ -1981,11 +1981,9 @@ int confirm_dialog(int when, char *action_text, char *event_text)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog, *vbox, *label;
|
GtkWidget *dialog, *vbox, *label;
|
||||||
int confirmed;
|
int confirmed;
|
||||||
char buffer[256];
|
|
||||||
char title[80];
|
char title[80];
|
||||||
|
|
||||||
snprintf(title, sizeof(title), "%s %s", action_text, event_text);
|
snprintf(title, sizeof(title), "%s %s", action_text, event_text);
|
||||||
snprintf(buffer, sizeof(buffer), _("%s event at %d:%02u"), title, FRACTION(when, 60));
|
|
||||||
dialog = gtk_dialog_new_with_buttons(title,
|
dialog = gtk_dialog_new_with_buttons(title,
|
||||||
GTK_WINDOW(main_window),
|
GTK_WINDOW(main_window),
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
@ -1994,7 +1992,7 @@ int confirm_dialog(int when, char *action_text, char *event_text)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||||
label = gtk_label_new(buffer);
|
label = create_label(_("%s event at %d:%02u"), title, FRACTION(when, 60));
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
||||||
gtk_widget_show_all(dialog);
|
gtk_widget_show_all(dialog);
|
||||||
confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
|
confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
|
||||||
|
|
27
print.c
27
print.c
|
@ -907,14 +907,26 @@ OPTIONSELECTEDCALLBACK(color_selection_toggle, print_options.color_selected)
|
||||||
#define SCALECALLBACK(name, scale1, scale2)\
|
#define SCALECALLBACK(name, scale1, scale2)\
|
||||||
static void name(GtkWidget *hscale, gpointer *data)\
|
static void name(GtkWidget *hscale, gpointer *data)\
|
||||||
{ \
|
{ \
|
||||||
print_options.scale1 = gtk_range_get_value(GTK_RANGE(hscale)); \
|
print_options.scale1 = gtk_range_get_value(GTK_RANGE(hscale)); \
|
||||||
print_options.notes_height = 93 - print_options.scale1 - print_options.scale2;\
|
print_options.notes_height = 93 - print_options.scale1 - print_options.scale2; \
|
||||||
gtk_range_set_value (GTK_RANGE(data), print_options.notes_height);\
|
gtk_range_set_value (GTK_RANGE(data), print_options.notes_height); \
|
||||||
}
|
}
|
||||||
|
|
||||||
SCALECALLBACK (prof_hscale, profile_height, tanks_height)
|
SCALECALLBACK (prof_hscale, profile_height, tanks_height)
|
||||||
SCALECALLBACK (tanks_hscale, tanks_height, profile_height)
|
SCALECALLBACK (tanks_hscale, tanks_height, profile_height)
|
||||||
|
|
||||||
|
|
||||||
|
GtkWidget *create_label(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return gtk_label_new(buf);
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
|
static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *vbox, *radio1, *radio2, *radio3, *radio4, *radio5,
|
GtkWidget *vbox, *radio1, *radio2, *radio3, *radio4, *radio5,
|
||||||
|
@ -1004,9 +1016,9 @@ static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
|
||||||
box4 = gtk_vbox_new (FALSE, 5);
|
box4 = gtk_vbox_new (FALSE, 5);
|
||||||
gtk_box_pack_start(GTK_BOX(box2), box4, TRUE, TRUE, 5);
|
gtk_box_pack_start(GTK_BOX(box2), box4, TRUE, TRUE, 5);
|
||||||
|
|
||||||
label1 = gtk_label_new(_("Profile height (37% - 77%)"));
|
label1 = create_label(_("Profile height (%d%% - %d%%)"), profile_height_min, profile_height_max);
|
||||||
label2 = gtk_label_new(_("Other data height (7% - 16%)"));
|
label2 = create_label(_("Other data height (%d%% - %d%%)"), tanks_height_min, tanks_height_max);
|
||||||
label3 = gtk_label_new(_("Notes height (7% - 77%)"));
|
label3 = create_label(_("Notes height (%d%% - %d%%)"), notes_height_min, notes_height_max);
|
||||||
gtk_box_pack_start (GTK_BOX(box3), label1, TRUE, TRUE, 10);
|
gtk_box_pack_start (GTK_BOX(box3), label1, TRUE, TRUE, 10);
|
||||||
gtk_box_pack_start (GTK_BOX(box3), label2, TRUE, TRUE, 10);
|
gtk_box_pack_start (GTK_BOX(box3), label2, TRUE, TRUE, 10);
|
||||||
gtk_box_pack_start (GTK_BOX(box3), label3, TRUE, TRUE, 10);
|
gtk_box_pack_start (GTK_BOX(box3), label3, TRUE, TRUE, 10);
|
||||||
|
@ -1020,6 +1032,9 @@ static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
|
||||||
gtk_range_set_value (GTK_RANGE(scale_tanks_hscale), print_options.tanks_height);
|
gtk_range_set_value (GTK_RANGE(scale_tanks_hscale), print_options.tanks_height);
|
||||||
gtk_range_set_increments (GTK_RANGE(scale_tanks_hscale),1,1);
|
gtk_range_set_increments (GTK_RANGE(scale_tanks_hscale),1,1);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE(scale_tanks_hscale), GTK_POS_LEFT);
|
gtk_scale_set_value_pos (GTK_SCALE(scale_tanks_hscale), GTK_POS_LEFT);
|
||||||
|
|
||||||
|
/* this third scale just shows how much is left for the notes;
|
||||||
|
* it can't be directly changed by the user */
|
||||||
scale_notes_hscale = gtk_hscale_new_with_range (notes_height_min, notes_height_max, 1);
|
scale_notes_hscale = gtk_hscale_new_with_range (notes_height_min, notes_height_max, 1);
|
||||||
gtk_range_set_value (GTK_RANGE(scale_notes_hscale), print_options.notes_height);
|
gtk_range_set_value (GTK_RANGE(scale_notes_hscale), print_options.notes_height);
|
||||||
gtk_range_set_increments (GTK_RANGE(scale_notes_hscale),1,1);
|
gtk_range_set_increments (GTK_RANGE(scale_notes_hscale),1,1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue