Skip to content
GitLab
Explore
Sign in
Commit
e12ce182
authored
8 years ago
by
Canek Peláez Valdés
Browse files
Options
Downloads
Patches
Plain Diff
Start photo zooming operations.
parent
c164714c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
data/gqpe.ui
+92
-16
92 additions, 16 deletions
data/gqpe.ui
src/application-window.vala
+30
-20
30 additions, 20 deletions
src/application-window.vala
src/photograph.vala
+19
-15
19 additions, 15 deletions
src/photograph.vala
with
141 additions
and
51 deletions
data/gqpe.ui
+
92
−
16
View file @
e12ce182
...
@@ -111,6 +111,77 @@
...
@@ -111,6 +111,77 @@
</style>
</style>
</object>
</object>
</child>
</child>
<child>
<object
class=
"GtkBox"
id=
"zoom_box"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"spacing"
>
0
</property>
<property
name=
"orientation"
>
horizontal
</property>
<child>
<object
class=
"GtkButton"
id=
"zoom_in"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Zoom in
</property>
<signal
name=
"clicked"
handler=
"on_zoom_in_clicked"
swapped=
"no"
/>
<child>
<object
class=
"GtkImage"
id=
"zoom_in_image"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"icon-name"
>
zoom-in-symbolic
</property>
<property
name=
"icon-size"
>
1
</property>
</object>
</child>
</object>
<packing>
<property
name=
"pack-type"
>
start
</property>
</packing>
</child>
<child>
<object
class=
"GtkButton"
id=
"zoom_out"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Zoom out
</property>
<signal
name=
"clicked"
handler=
"on_zoom_out_clicked"
swapped=
"no"
/>
<child>
<object
class=
"GtkImage"
id=
"zoom_out_image"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"icon-name"
>
zoom-out-symbolic
</property>
<property
name=
"icon-size"
>
1
</property>
</object>
</child>
</object>
<packing>
<property
name=
"pack-type"
>
start
</property>
</packing>
</child>
<child>
<object
class=
"GtkButton"
id=
"zoom_fit"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"tooltip-text"
translatable=
"yes"
>
Zoom fit best
</property>
<signal
name=
"clicked"
handler=
"on_zoom_fit_clicked"
swapped=
"no"
/>
<child>
<object
class=
"GtkImage"
id=
"zoom_fit_image"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"icon-name"
>
zoom-fit-best-symbolic
</property>
<property
name=
"icon-size"
>
1
</property>
</object>
</child>
</object>
<packing>
<property
name=
"pack-type"
>
start
</property>
</packing>
</child>
<style>
<class
name=
"linked"
/>
</style>
</object>
</child>
<child>
<child>
<object
class=
"GtkButton"
id=
"save"
>
<object
class=
"GtkButton"
id=
"save"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"visible"
>
True
</property>
...
@@ -157,6 +228,15 @@
...
@@ -157,6 +228,15 @@
<property
name=
"xalign"
>
0.0
</property>
<property
name=
"xalign"
>
0.0
</property>
</object>
</object>
</child>
</child>
<child>
<object
class=
"GtkScrolledWindow"
id=
"image_scroll"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"shadow-type"
>
GTK_SHADOW_NONE
</property>
<property
name=
"width_request"
>
500
</property>
<property
name=
"height_request"
>
500
</property>
<property
name=
"hscrollbar-policy"
>
automatic
</property>
<property
name=
"vscrollbar-policy"
>
automatic
</property>
<child>
<child>
<object
class=
"GtkImage"
id=
"image"
>
<object
class=
"GtkImage"
id=
"image"
>
<property
name=
"width_request"
>
500
</property>
<property
name=
"width_request"
>
500
</property>
...
@@ -167,7 +247,6 @@
...
@@ -167,7 +247,6 @@
<property
name=
"expand"
>
True
</property>
<property
name=
"expand"
>
True
</property>
<property
name=
"pixel-size"
>
420
</property>
<property
name=
"pixel-size"
>
420
</property>
<property
name=
"icon-name"
>
start-here-symbolic
</property>
<property
name=
"icon-name"
>
start-here-symbolic
</property>
<signal
name=
"size-allocate"
handler=
"on_image_resize"
swapped=
"no"
/>
<style>
<style>
<class
name=
"dark-bg"
/>
<class
name=
"dark-bg"
/>
</style>
</style>
...
@@ -176,6 +255,8 @@
...
@@ -176,6 +255,8 @@
</object>
</object>
</child>
</child>
</object>
</object>
</child>
</object>
<packing>
<packing>
<property
name=
"shrink"
>
False
</property>
<property
name=
"shrink"
>
False
</property>
</packing>
</packing>
...
@@ -260,11 +341,6 @@
...
@@ -260,11 +341,6 @@
</child>
</child>
</object>
</object>
</child>
</child>
</object>
</object>
<packing>
<packing>
<property
name=
"shrink"
>
False
</property>
<property
name=
"shrink"
>
False
</property>
...
...
This diff is collapsed.
Click to expand it.
src/application-window.vala
+
30
−
20
View file @
e12ce182
...
@@ -71,6 +71,9 @@ namespace GQPE {
...
@@ -71,6 +71,9 @@ namespace GQPE {
/* The save button. */
/* The save button. */
[
GtkChild
]
[
GtkChild
]
private
Gtk
.
Button
save
;
private
Gtk
.
Button
save
;
/* The image scroll. */
[
GtkChild
]
private
Gtk
.
ScrolledWindow
image_scroll
;
/* The image label. */
/* The image label. */
[
GtkChild
]
[
GtkChild
]
private
Gtk
.
Label
label
;
private
Gtk
.
Label
label
;
...
@@ -174,6 +177,33 @@ namespace GQPE {
...
@@ -174,6 +177,33 @@ namespace GQPE {
rotate
(
Rotate
.
RIGHT
);
rotate
(
Rotate
.
RIGHT
);
}
}
/**
* Callback for zoom in.
*/
[
GtkCallback
]
public
void
on_zoom_in_clicked
()
{
}
/**
* Callback for zoom out.
*/
[
GtkCallback
]
public
void
on_zoom_out_clicked
()
{
}
/**
* Callback for zoom fit.
*/
[
GtkCallback
]
public
void
on_zoom_fit_clicked
()
{
double
w
=
image_scroll
.
get_allocated_width
();
double
h
=
image_scroll
.
get_allocated_height
();
if
(
w
<=
0.0
||
h
<=
0.0
)
return
;
photograph
.
resize
(
w
,
h
);
image
.
set_from_pixbuf
(
photograph
.
pixbuf
);
}
/**
/**
* Callback for save button clicked.
* Callback for save button clicked.
*/
*/
...
@@ -210,26 +240,6 @@ namespace GQPE {
...
@@ -210,26 +240,6 @@ namespace GQPE {
enable_ui
(
Item
.
SAVE
);
enable_ui
(
Item
.
SAVE
);
}
}
/**
* Callback for image resized.
*/
[
GtkCallback
]
public
void
on_image_resize
()
{
double
w
=
image
.
get_allocated_width
();
double
h
=
image
.
get_allocated_height
();
if
(
w
<=
0.0
||
h
<=
0.0
)
return
;
double
W
=
photograph
.
pixbuf
.
width
;
double
H
=
photograph
.
pixbuf
.
height
;
double
s1
=
w
/
W
;
double
s2
=
h
/
H
;
if
(
H
*
s1
<=
h
)
photograph
.
scale
(
s1
);
else
photograph
.
scale
(
s2
);
}
/**
/**
* Opens an array of files.
* Opens an array of files.
* @param files the array of files.
* @param files the array of files.
...
...
This diff is collapsed.
Click to expand it.
src/photograph.vala
+
19
−
15
View file @
e12ce182
...
@@ -68,7 +68,7 @@ namespace GQPE {
...
@@ -68,7 +68,7 @@ namespace GQPE {
/* The photograph metadata. */
/* The photograph metadata. */
private
GExiv2
.
Metadata
metadata
;
private
GExiv2
.
Metadata
metadata
;
/* Private the original pixbuf. */
/* Private the original pixbuf. */
private
Gdk
.
Pixbuf
pixbuf
original
;
private
Gdk
.
Pixbuf
original
;
/**
/**
* Creates a new photograph.
* Creates a new photograph.
...
@@ -86,10 +86,10 @@ namespace GQPE {
...
@@ -86,10 +86,10 @@ namespace GQPE {
if
(
original
!=
null
)
if
(
original
!=
null
)
return
;
return
;
original
=
new
Gdk
.
Pixbuf
.
from_file
(
file
.
get_path
());
metadata
=
new
GExiv2
.
Metadata
();
metadata
=
new
GExiv2
.
Metadata
();
metadata
.
open_path
(
file
.
get_path
());
metadata
.
open_path
(
file
.
get_path
());
original
=
new
Gdk
.
Pixbuf
.
from_file
(
file
.
get_path
());
if
(
metadata
.
has_tag
(
Tag
.
ORIENTATION
))
{
if
(
metadata
.
has_tag
(
Tag
.
ORIENTATION
))
{
var
rot
=
Gdk
.
PixbufRotation
.
NONE
;
var
rot
=
Gdk
.
PixbufRotation
.
NONE
;
switch
(
metadata
.
get_tag_long
(
Tag
.
ORIENTATION
))
{
switch
(
metadata
.
get_tag_long
(
Tag
.
ORIENTATION
))
{
...
@@ -110,11 +110,11 @@ namespace GQPE {
...
@@ -110,11 +110,11 @@ namespace GQPE {
break
;
break
;
}
}
if
(
rot
!=
Gdk
.
PixbufRotation
.
NONE
)
if
(
rot
!=
Gdk
.
PixbufRotation
.
NONE
)
pixbuf
=
original
.
rotate_simple
(
rot
);
original
=
original
.
rotate_simple
(
rot
);
}
}
double
scale
=
50
0.0
/
double
.
max
(
pixbuf
.
width
,
pixbuf
.
height
);
double
scale
=
49
0.0
/
double
.
max
(
original
.
width
,
original
.
height
);
pixbuf
=
pixbuf
.
scale_simple
((
int
)(
pixbuf
.
width
*
scale
),
pixbuf
=
original
.
scale_simple
((
int
)(
original
.
width
*
scale
),
(
int
)(
pixbuf
.
height
*
scale
),
(
int
)(
original
.
height
*
scale
),
Gdk
.
InterpType
.
BILINEAR
);
Gdk
.
InterpType
.
BILINEAR
);
album
=
(
metadata
.
has_tag
(
Tag
.
SUBJECT
))
?
album
=
(
metadata
.
has_tag
(
Tag
.
SUBJECT
))
?
metadata
.
get_tag_string
(
Tag
.
SUBJECT
).
strip
()
:
""
;
metadata
.
get_tag_string
(
Tag
.
SUBJECT
).
strip
()
:
""
;
...
@@ -122,15 +122,19 @@ namespace GQPE {
...
@@ -122,15 +122,19 @@ namespace GQPE {
metadata
.
get_tag_string
(
Tag
.
CAPTION
).
strip
()
:
""
;
metadata
.
get_tag_string
(
Tag
.
CAPTION
).
strip
()
:
""
;
comment
=
(
metadata
.
has_tag
(
Tag
.
DESCRIPTION
))
?
comment
=
(
metadata
.
has_tag
(
Tag
.
DESCRIPTION
))
?
metadata
.
get_tag_string
(
Tag
.
DESCRIPTION
).
strip
()
:
""
;
metadata
.
get_tag_string
(
Tag
.
DESCRIPTION
).
strip
()
:
""
;
album
.
strip
();
caption
.
strip
();
comment
.
strip
();
}
}
public
void
scale
(
double
scale
)
{
/**
pixbuf
=
pixbuf
.
scale_simple
((
int
)(
pixbuf
.
width
*
scale
),
* Resizes the photograph so it fills the given width and height.
(
int
)(
pixbuf
.
height
*
scale
),
*/
public
void
resize
(
double
w
,
double
h
)
{
double
W
=
original
.
width
;
double
H
=
original
.
height
;
double
s1
=
w
/
W
;
double
s2
=
h
/
H
;
double
scale
=
(
H
*
s1
<=
h
)
?
s1
:
s2
;
pixbuf
=
original
.
scale_simple
((
int
)(
original
.
width
*
scale
),
(
int
)(
original
.
height
*
scale
),
Gdk
.
InterpType
.
BILINEAR
);
Gdk
.
InterpType
.
BILINEAR
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment