Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format popover #207

Merged
merged 34 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c798771
add Popover
gort818 Oct 22, 2017
56d78f3
add popover
gort818 Oct 22, 2017
cf4cd7c
update with GtkMenuButton
gort818 Oct 22, 2017
25a3ad4
Update with GtkMenuButton
gort818 Oct 22, 2017
7c17680
Set popmenu to titlebar style
gort818 Oct 23, 2017
b2cc7e0
Update application-window.vala
gort818 Oct 24, 2017
4f15596
change style for popover gnome
gort818 Oct 24, 2017
7e1f7a6
Update application-window.vala
gort818 Oct 24, 2017
20f9806
Change syle for users with ambiance
gort818 Oct 24, 2017
eaac4d6
Change record label per format
gort818 Oct 26, 2017
cf92f4f
Change poover
gort818 Oct 26, 2017
8159452
Merge pull request #1 from phw/master
gort818 Oct 26, 2017
1abbd16
add ambiance style sheet
gort818 Oct 26, 2017
562d2df
added style sheet to resources
gort818 Oct 26, 2017
67e051e
load ambiance style sheet
gort818 Oct 26, 2017
00bd103
added style group for format buttons
gort818 Oct 26, 2017
7f5c9e9
Change record button label
gort818 Oct 28, 2017
31b95e2
Merge pull request #2 from phw/master
gort818 Oct 28, 2017
afa8b3d
Merge pull request #3 from phw/master
gort818 Nov 9, 2017
27e96c5
Add get_theme_name
gort818 Nov 9, 2017
8eaf362
fix whitespace and call get_theme_name
gort818 Nov 9, 2017
db6ca8e
Add fucntion select_format()
gort818 Nov 9, 2017
18409ad
Fix formating and white space
gort818 Nov 11, 2017
d24dc6a
Fix formating and whitespace
gort818 Nov 11, 2017
4e5d3a1
Fixed formatting and whitespace
gort818 Nov 11, 2017
16dc234
Change record icon.
gort818 Nov 11, 2017
5d7b0e4
Fixed Formatting and white space
gort818 Nov 11, 2017
56fc03c
Fixed formatting
gort818 Nov 11, 2017
98a4500
Fixed Formatting
gort818 Nov 11, 2017
3e0310b
Fixed formatting
gort818 Nov 11, 2017
f901664
Fixed formatting
gort818 Nov 11, 2017
d1d8688
File in wrong location
gort818 Nov 12, 2017
a69647d
Change record button icon
gort818 Nov 14, 2017
042198e
Update record button label
gort818 Nov 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ namespace Peek {

private void load_stylesheets () {
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/peek.css");

if (DesktopIntegration.get_theme_name () == "Ambiance") {
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/ambiance.css");
}
if (DesktopIntegration.is_unity ()) {
load_stylesheet_from_uri ("resource:///com/uploadedlobster/peek/css/unity.css");
}
Expand Down
6 changes: 6 additions & 0 deletions src/desktop-integration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ namespace Peek {
return desktop.contains (text);
}

public static string get_theme_name () {
var theme = new GLib.Settings ("org.gnome.desktop.interface"); //grab the users' settings
var theme_name = theme.get_string ("gtk-theme"); //find the users' theme
return theme_name;
}

#if ! DISABLE_OPEN_FILE_MANAGER
private static bool file_manager_highlights_file (AppInfo app_info) {
var exe = app_info.get_executable ();
Expand Down
60 changes: 60 additions & 0 deletions src/ui/application-window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ namespace Peek.Ui {
[GtkChild]
private Button stop_button;

[GtkChild]
private Popover pop_format;

[GtkChild]
private MenuButton pop_format_menu;

[GtkChild]
private Label size_indicator;

Expand Down Expand Up @@ -156,8 +162,13 @@ namespace Peek.Ui {
// Make sure the close button is on the left if desktop environment
// is configured that way.
this.set_close_button_position ();

// Set record button label
// Grab the current format and set the record label with the selected format
select_format ("%s".printf(this.recorder.config.output_format));
}


public void hide_headerbar () {
this.get_style_context ().add_class ("headerbar-hidden");
this.headerbar.hide ();
Expand Down Expand Up @@ -213,6 +224,24 @@ namespace Peek.Ui {
return false;
}

//set format
private string get_format_name (string format) {
switch (format) {
case OUTPUT_FORMAT_APNG: return _("APNG");
case OUTPUT_FORMAT_GIF: return _("GIF");
case OUTPUT_FORMAT_MP4: return _("MP4");
case OUTPUT_FORMAT_WEBM: return _("WebM");
default: return "";
}
}

private void select_format (string format) {
recorder.config.output_format = format;
var format_name = get_format_name (format);
record_button.set_label (_("Record as %s").printf (format_name));
pop_format.hide ();
}

[GtkCallback]
public void on_window_screen_changed (Gdk.Screen? previous_screen) {
var screen = this.get_screen ();
Expand Down Expand Up @@ -284,6 +313,23 @@ namespace Peek.Ui {
}
}

[GtkCallback]
private void on_gif_button_clicked (Button source) {
select_format("gif");
}
[GtkCallback]
private void on_apng_button_clicked (Button source) {
select_format("apng");
}
[GtkCallback]
private void on_webm_button_clicked (Button source) {
select_format("webm");
}
[GtkCallback]
private void on_mp4_button_clicked (Button source) {
select_format("mp4");
}

[GtkCallback]
private void on_record_button_clicked (Button source) {
prepare_start_recording ();
Expand Down Expand Up @@ -368,6 +414,7 @@ namespace Peek.Ui {
if (!is_recording) {
is_recording = true;
size_indicator.opacity = 0.0;
pop_format_menu.hide();
record_button.hide ();
if (get_window_width () >= SMALL_WINDOW_SIZE) {
stop_button.set_label (stop_button_label);
Expand All @@ -386,6 +433,7 @@ namespace Peek.Ui {
is_recording = false;
is_postprocessing = false;
stop_button.hide ();
pop_format_menu.show();
record_button.show ();
unfreeze_window_size ();

Expand All @@ -410,10 +458,22 @@ namespace Peek.Ui {

private void update_input_shape () {
// Set an input shape so that the recording view is not clickable


var window_region = create_region_from_widget (recording_view.get_toplevel ());
var recording_view_region = create_region_from_widget (recording_view);
window_region.subtract (recording_view_region);

//popover menu
if (pop_format.visible) {
var pop_style = pop_format.get_style_context();
if (DesktopIntegration.get_theme_name () == "Ambiance") {
pop_style.add_class(Gtk.STYLE_CLASS_TITLEBAR);
}
var pop_format_region = create_region_from_widget (pop_format);
window_region.union (pop_format_region);
}

// The fallback app menu overlaps the recording area
var fallback_app_menu = get_fallback_app_menu ();
if (fallback_app_menu != null && fallback_app_menu.visible) {
Expand Down
105 changes: 102 additions & 3 deletions ui/application-window.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0
<!-- Generated with glade 3.20.1

Copyright (C) Philipp Wolfer <ph.wolfer@gmail.com>

Expand Down Expand Up @@ -31,7 +31,7 @@ Author: Philipp Wolfer <ph.wolfer@gmail.com>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Start recording</property>
<property name="icon_name">media-playback-start-symbolic</property>
<property name="icon_name">media-record-symbolic</property>
</object>
<object class="GtkImage" id="icon_stop_button">
<property name="visible">True</property>
Expand All @@ -48,8 +48,8 @@ Author: Philipp Wolfer <ph.wolfer@gmail.com>
<property name="default_height">250</property>
<property name="icon_name">com.uploadedlobster.peek</property>
<property name="show_menubar">False</property>
<signal name="screen-changed" handler="on_window_screen_changed" swapped="no"/>
<signal name="draw" handler="on_window_draw" swapped="no"/>
<signal name="screen-changed" handler="on_window_screen_changed" swapped="no"/>
<child>
<object class="GtkBox" id="content_area">
<property name="visible">True</property>
Expand Down Expand Up @@ -124,13 +124,15 @@ Author: Philipp Wolfer <ph.wolfer@gmail.com>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="record_button">
<property name="label" translatable="yes">_Record</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">45</property>
<property name="image">icon_record_button</property>
<property name="relief">half</property>
<property name="use_underline">True</property>
Expand Down Expand Up @@ -179,9 +181,106 @@ Author: Philipp Wolfer <ph.wolfer@gmail.com>
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="pop_format_menu">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_right">45</property>
<property name="popover">pop_format</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkPopover" id="pop_format">
<property name="can_focus">False</property>
<property name="relative_to">record_button</property>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="gif_button">
<property name="label" translatable="yes">GIF</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_gif_button_clicked" swapped="no"/>
<style>
<class name="format_button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="apng_button">
<property name="label" translatable="yes">APNG</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_apng_button_clicked" swapped="no"/>
<style>
<class name="format_button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="webm_button">
<property name="label" translatable="yes">WebM</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_webm_button_clicked" swapped="no"/>
<style>
<class name="format_button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="mp4_button">
<property name="label" translatable="yes">MP4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_mp4_button_clicked" swapped="no"/>
<style>
<class name="format_button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
9 changes: 9 additions & 0 deletions ui/css/ambiance.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.peek-recording-view-overlay {
opacity: 0.8;
background-color: rgb(40, 44, 52);
color: white;
}

.format_button:hover{
background-color:#e55d2f;
}
1 change: 1 addition & 0 deletions ui/peek.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<!-- Stylesheets -->
<file>css/peek.css</file>
<file>css/unity.css</file>
<file>css/ambiance.css</file>
</gresource>
</gresources>