Skip to content

Commit 2680d14

Browse files
committed
better handling of menu init in display bar
1 parent 56b0d63 commit 2680d14

File tree

6 files changed

+75
-52
lines changed

6 files changed

+75
-52
lines changed

TODO

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77

88
thumbnail gets falsecolour and scale, but not multipage or page number
99

10-
- "reset" in display bar resets the position of scale/offset widgets, but does
11-
not reset the menu items (eg. tick on falsecolour)
12-
13-
I forget how menu items are linked to actions, reread this
14-
15-
gaction bound to a gsetting? do we need to add to the settings
16-
schema?
17-
18-
likewise, load ws with locked tab, rightclick menu on locked tab does not
10+
- load ws with locked tab, rightclick menu on locked tab does not
1911
have tick selected
2012

2113
- the "new tab" icon is still broken in the windows build

org.libvips.nip4.gschema.xml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,6 @@
3131
</description>
3232
</key>
3333

34-
<key type="d" name="scale">
35-
<default>1.0</default>
36-
<summary>Scale</summary>
37-
<description>
38-
The display scale.
39-
</description>
40-
</key>
41-
42-
<key type="d" name="offset">
43-
<default>0.0</default>
44-
<summary>Offset</summary>
45-
<description>
46-
The display offset.
47-
</description>
48-
</key>
49-
50-
<key type="b" name="falsecolour">
51-
<default>false</default>
52-
<summary>Falsecolour</summary>
53-
<description>
54-
Show pixels with a falsecolour mapping.
55-
</description>
56-
</key>
57-
58-
<key type="b" name="log">
59-
<default>false</default>
60-
<summary>log</summary>
61-
<description>
62-
Show pixels with a log mapping.
63-
</description>
64-
</key>
65-
66-
<key name="background" enum="org.libvips.nip4.background">
67-
<default>'white'</default>
68-
<summary>Background</summary>
69-
<description>The background texture for image rendering</description>
70-
</key>
71-
7234
<key type="b" name="toolkits">
7335
<default>true</default>
7436
<summary>Toolkits viewer</summary>

src/gtkutil.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,62 @@ copy_state(GtkWidget *to, GtkWidget *from, const char *name)
194194
change_state(to, name, state);
195195
}
196196

197+
void
198+
set_state_bool(GtkWidget *to, const char *name, gboolean value)
199+
{
200+
GVariant *state = g_variant_new_boolean(value);
201+
202+
change_state(to, name, state);
203+
}
204+
205+
void
206+
set_state_double(GtkWidget *to, const char *name, double value)
207+
{
208+
GVariant *state = g_variant_new_double(value);
209+
210+
change_state(to, name, state);
211+
}
212+
213+
void
214+
set_state_int(GtkWidget *to, const char *name, int value)
215+
{
216+
GVariant *state = g_variant_new_int32(value);
217+
218+
change_state(to, name, state);
219+
}
220+
221+
void
222+
set_state_enum(GtkWidget *to, const char *name, const char *value)
223+
{
224+
GVariant *state = g_variant_new_string(value);
225+
226+
change_state(to, name, state);
227+
}
228+
229+
gboolean
230+
get_state_bool(GtkWidget *from, const char *name)
231+
{
232+
g_autoptr(GVariant) state = get_state(from, name);
233+
234+
return g_variant_get_boolean(state);
235+
}
236+
237+
double
238+
get_state_double(GtkWidget *from, const char *name)
239+
{
240+
g_autoptr(GVariant) state = get_state(from, name);
241+
242+
return g_variant_get_double(state);
243+
}
244+
245+
int
246+
get_state_int(GtkWidget *from, const char *name)
247+
{
248+
g_autoptr(GVariant) state = get_state(from, name);
249+
250+
return g_variant_get_int32(state);
251+
}
252+
197253
/* A 'safe' way to run a few events.
198254
*/
199255
void

src/gtkutil.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ void set_state(GtkWidget *to, GSettings *settings, const char *name);
7373
GVariant *get_state(GtkWidget *widget, const char *name);
7474
void copy_state(GtkWidget *to, GtkWidget *from, const char *name);
7575

76+
void set_state_bool(GtkWidget *to, const char *name, gboolean value);
77+
void set_state_double(GtkWidget *to, const char *name, double value);
78+
void set_state_int(GtkWidget *to, const char *name, int value);
79+
void set_state_enum(GtkWidget *to, const char *name, const char *value);
80+
81+
gboolean get_state_bool(GtkWidget *from, const char *name);
82+
double get_state_double(GtkWidget *from, const char *name);
83+
int get_state_int(GtkWidget *from, const char *name);
84+
7685
void process_events(void);
7786

7887
void block_scroll(GtkWidget *widget);

src/imagewindow.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,17 @@ imagewindow_reset_view(Imagewindow *win)
440440
printf("imagewindow_reset_view:\n");
441441

442442
if (tilesource) {
443+
set_state_bool(GTK_WIDGET(win), "falsecolour", FALSE);
444+
set_state_bool(GTK_WIDGET(win), "log", FALSE);
445+
set_state_bool(GTK_WIDGET(win), "icc", FALSE);
446+
set_state_bool(GTK_WIDGET(win), "preserve", FALSE);
447+
set_state_enum(GTK_WIDGET(win), "mode", "multipage");
448+
set_state_enum(GTK_WIDGET(win), "background", "checkerboard");
449+
443450
g_object_set(tilesource,
444-
"falsecolour", FALSE,
445-
"log", FALSE,
446-
"icc", FALSE,
447451
"scale", 1.0,
448452
"offset", 0.0,
453+
"page", 0,
449454
NULL);
450455
}
451456
}
@@ -1398,7 +1403,6 @@ imagewindow_init(Imagewindow *win)
13981403
set_state(GTK_WIDGET(win), win->settings, "properties");
13991404
set_state(GTK_WIDGET(win), win->settings, "control");
14001405
set_state(GTK_WIDGET(win), win->settings, "info");
1401-
set_state(GTK_WIDGET(win), win->settings, "background");
14021406

14031407
// some kind of gtk bug? hexpand on properties can't be set from .ui or in
14041408
// properties.c, but must be set after adding to a parent

src/tilesource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
/*
3131
#define DEBUG_VERBOSE
32-
#define DEBUG
3332
#define DEBUG_MAKE
3433
*/
34+
#define DEBUG
3535

3636
#include "nip4.h"
3737

0 commit comments

Comments
 (0)