code style
This commit is contained in:
parent
0fe08f5ffe
commit
d1068871d7
9 changed files with 156 additions and 149 deletions
|
@ -51,7 +51,7 @@ namespace Webpin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gtk.Window mainwindow;
|
public Gtk.Window mainwindow { get; private set; default = null; }
|
||||||
|
|
||||||
protected override void activate () {
|
protected override void activate () {
|
||||||
if (mainwindow != null) {
|
if (mainwindow != null) {
|
||||||
|
@ -66,14 +66,14 @@ namespace Webpin {
|
||||||
start_webapp (files [0].get_uri ());
|
start_webapp (files [0].get_uri ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start_webapp (string url) {
|
private void start_webapp (string url) {
|
||||||
if (mainwindow != null ) {
|
if (mainwindow != null ) {
|
||||||
mainwindow.present ();
|
mainwindow.present ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var app_info = Services.DesktopFilesManager.get_app_by_url (url);
|
var app_info = Services.DesktopFilesManager.get_app_by_url (url);
|
||||||
var desktop_file = new Webpin.DesktopFile.from_desktopappinfo (app_info);
|
var desktop_file = new Webpin.DesktopFile.from_desktopappinfo (app_info);
|
||||||
mainwindow = new WebWindow (desktop_file);
|
mainwindow = new Windows.WebApp (desktop_file);
|
||||||
mainwindow.set_application (this);
|
mainwindow.set_application (this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
vala_precompile(VALA_C ${CMAKE_PROJECT_NAME}
|
vala_precompile(VALA_C ${CMAKE_PROJECT_NAME}
|
||||||
Widgets/ApplicationIcon.vala
|
Widgets/WebItem.vala
|
||||||
Widgets/ApplicationsView.vala
|
Widgets/Views/WebItemsView.vala
|
||||||
Widgets/Assistant.vala
|
Widgets/Views/Editor.vala
|
||||||
Widgets/WebApp.vala
|
Widgets/Browser.vala
|
||||||
|
Windows/WebApp.vala
|
||||||
Objects/DesktopFile.vala
|
Objects/DesktopFile.vala
|
||||||
Dialogs/Preferences.vala
|
Dialogs/Preferences.vala
|
||||||
Services/DesktopFilesManager.vala
|
Services/DesktopFilesManager.vala
|
||||||
Settings.vala
|
Settings.vala
|
||||||
MainWindow.vala
|
MainWindow.vala
|
||||||
WebWindow.vala
|
|
||||||
Application.vala
|
Application.vala
|
||||||
PACKAGES
|
PACKAGES
|
||||||
gtk+-3.0
|
gtk+-3.0
|
||||||
|
|
|
@ -36,8 +36,8 @@ namespace Webpin {
|
||||||
Gtk.Button add_button;
|
Gtk.Button add_button;
|
||||||
Gtk.MenuButton app_menu;
|
Gtk.MenuButton app_menu;
|
||||||
|
|
||||||
Assistant assistant;
|
Widgets.Views.Editor editor;
|
||||||
ApplicationsView apps_view;
|
Widgets.Views.WebItemsView web_items_view;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
settings = Settings.get_default ();
|
settings = Settings.get_default ();
|
||||||
|
@ -106,44 +106,44 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
apps_view = new ApplicationsView();
|
web_items_view = new Widgets.Views.WebItemsView ();
|
||||||
assistant = new Assistant();
|
editor = new Widgets.Views.Editor ();
|
||||||
stack = new Gtk.Stack ();
|
stack = new Gtk.Stack ();
|
||||||
stack.set_transition_duration (500);
|
stack.set_transition_duration (500);
|
||||||
|
|
||||||
stack.add_named (welcome, "welcome");
|
stack.add_named (welcome, "welcome");
|
||||||
stack.add_named (apps_view, "apps_view");
|
stack.add_named (web_items_view, "apps_view");
|
||||||
stack.add_named (assistant, "assistant");
|
stack.add_named (editor, "editor");
|
||||||
|
|
||||||
add (stack);
|
add (stack);
|
||||||
|
|
||||||
apps_view.add_request.connect (() => {
|
web_items_view.add_request.connect (() => {
|
||||||
show_assistant ();
|
show_assistant ();
|
||||||
});
|
});
|
||||||
|
|
||||||
apps_view.edit_request.connect ((desktop_file) => {
|
web_items_view.edit_request.connect ((desktop_file) => {
|
||||||
show_assistant (desktop_file);
|
show_assistant (desktop_file);
|
||||||
});
|
});
|
||||||
|
|
||||||
apps_view.app_deleted.connect (() => {
|
web_items_view.app_deleted.connect (() => {
|
||||||
if (!apps_view.has_items) {
|
if (!web_items_view.has_items) {
|
||||||
show_welcome_view (Gtk.StackTransitionType.NONE);
|
show_welcome_view (Gtk.StackTransitionType.NONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
assistant.application_created.connect ((new_file) => {
|
editor.application_created.connect ((new_file) => {
|
||||||
apps_view.add_button (new_file);
|
web_items_view.add_web_item (new_file);
|
||||||
apps_view.select_last_item ();
|
web_items_view.select_last_item ();
|
||||||
show_apps_view ();
|
show_apps_view ();
|
||||||
});
|
});
|
||||||
|
|
||||||
assistant.application_edited.connect ((edited_file) => {
|
editor.application_edited.connect ((edited_file) => {
|
||||||
apps_view.update_button (edited_file);
|
web_items_view.update_button (edited_file);
|
||||||
show_apps_view ();
|
show_apps_view ();
|
||||||
});
|
});
|
||||||
|
|
||||||
back_button.clicked.connect (() => {
|
back_button.clicked.connect (() => {
|
||||||
if (apps_view.has_items) {
|
if (web_items_view.has_items) {
|
||||||
show_apps_view ();
|
show_apps_view ();
|
||||||
} else {
|
} else {
|
||||||
show_welcome_view ();
|
show_welcome_view ();
|
||||||
|
@ -162,7 +162,7 @@ namespace Webpin {
|
||||||
this.restore_settings ();
|
this.restore_settings ();
|
||||||
show_all ();
|
show_all ();
|
||||||
|
|
||||||
if (apps_view.has_items) {
|
if (web_items_view.has_items) {
|
||||||
show_apps_view (Gtk.StackTransitionType.NONE);
|
show_apps_view (Gtk.StackTransitionType.NONE);
|
||||||
} else {
|
} else {
|
||||||
show_welcome_view (Gtk.StackTransitionType.NONE);
|
show_welcome_view (Gtk.StackTransitionType.NONE);
|
||||||
|
@ -173,10 +173,10 @@ namespace Webpin {
|
||||||
|
|
||||||
private void show_assistant (DesktopFile? desktop_file = null) {
|
private void show_assistant (DesktopFile? desktop_file = null) {
|
||||||
stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);
|
stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);
|
||||||
stack.set_visible_child_name("assistant");
|
stack.set_visible_child_name("editor");
|
||||||
back_button.show_all ();
|
back_button.show_all ();
|
||||||
add_button.hide ();
|
add_button.hide ();
|
||||||
assistant.edit_desktop_file (desktop_file);
|
editor.edit_desktop_file (desktop_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_apps_view (Gtk.StackTransitionType slide = Gtk.StackTransitionType.SLIDE_RIGHT) {
|
private void show_apps_view (Gtk.StackTransitionType slide = Gtk.StackTransitionType.SLIDE_RIGHT) {
|
||||||
|
@ -184,7 +184,7 @@ namespace Webpin {
|
||||||
stack.set_visible_child_name ("apps_view");
|
stack.set_visible_child_name ("apps_view");
|
||||||
back_button.hide ();
|
back_button.hide ();
|
||||||
add_button.show_all ();
|
add_button.show_all ();
|
||||||
assistant.reset_fields ();
|
editor.reset_fields ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_welcome_view (Gtk.StackTransitionType slide = Gtk.StackTransitionType.SLIDE_RIGHT) {
|
private void show_welcome_view (Gtk.StackTransitionType slide = Gtk.StackTransitionType.SLIDE_RIGHT) {
|
||||||
|
@ -192,7 +192,7 @@ namespace Webpin {
|
||||||
stack.set_visible_child_name ("welcome");
|
stack.set_visible_child_name ("welcome");
|
||||||
back_button.hide ();
|
back_button.hide ();
|
||||||
add_button.hide ();
|
add_button.hide ();
|
||||||
assistant.reset_fields ();
|
editor.reset_fields ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restore_settings () {
|
private void restore_settings () {
|
||||||
|
|
|
@ -62,5 +62,42 @@ namespace Webpin.Services {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Gdk.Pixbuf? align_and_scale_pixbuf (Gdk.Pixbuf p, int size) {
|
||||||
|
Gdk.Pixbuf? pixbuf = p;
|
||||||
|
if (pixbuf.width != pixbuf.height) {
|
||||||
|
if (pixbuf.width > pixbuf.height) {
|
||||||
|
int dif = (pixbuf.width - pixbuf.height) / 2;
|
||||||
|
pixbuf = new Gdk.Pixbuf.subpixbuf (pixbuf, dif, 0, pixbuf.height, pixbuf.height);
|
||||||
|
} else {
|
||||||
|
int dif = (pixbuf.height - pixbuf.width) / 2;
|
||||||
|
pixbuf = new Gdk.Pixbuf.subpixbuf (pixbuf, 0, dif, pixbuf.width, pixbuf.width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pixbuf = pixbuf.scale_simple (size, size, Gdk.InterpType.BILINEAR);
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string? choose_new_icon () {
|
||||||
|
string? return_value = null;
|
||||||
|
var dialog = new Gtk.FileChooserDialog (
|
||||||
|
_("Choose an image…"), WebpinApp.instance.mainwindow,
|
||||||
|
Gtk.FileChooserAction.OPEN,
|
||||||
|
_("_Cancel"), Gtk.ResponseType.CANCEL,
|
||||||
|
_("_Open"), Gtk.ResponseType.ACCEPT);
|
||||||
|
|
||||||
|
var filter = new Gtk.FileFilter ();
|
||||||
|
filter.set_filter_name (_("Images"));
|
||||||
|
filter.add_mime_type ("image/*");
|
||||||
|
|
||||||
|
dialog.add_filter (filter);
|
||||||
|
|
||||||
|
if (dialog.run () == Gtk.ResponseType.ACCEPT) {
|
||||||
|
return_value = dialog.get_filename ();
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.destroy();
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Webpin {
|
namespace Webpin.Widgets {
|
||||||
public class WebApp : Gtk.Stack {
|
public class Browser : Gtk.Stack {
|
||||||
public WebKit.WebView app_view { get; private set; }
|
public WebKit.WebView app_view { get; private set; }
|
||||||
public DesktopFile desktop_file { get; private set; }
|
public DesktopFile desktop_file { get; private set; }
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace Webpin {
|
||||||
public signal void found_website_color (Gdk.RGBA color);
|
public signal void found_website_color (Gdk.RGBA color);
|
||||||
|
|
||||||
|
|
||||||
public WebApp (DesktopFile desktop_file) {
|
public Browser (DesktopFile desktop_file) {
|
||||||
this.desktop_file = desktop_file;
|
this.desktop_file = desktop_file;
|
||||||
this.transition_duration = 350;
|
this.transition_duration = 350;
|
||||||
this.transition_type = Gtk.StackTransitionType.SLIDE_UP;
|
this.transition_type = Gtk.StackTransitionType.SLIDE_UP;
|
|
@ -26,8 +26,8 @@
|
||||||
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Webpin {
|
namespace Webpin.Widgets.Views {
|
||||||
public class Assistant : Gtk.Box {
|
public class Editor : Gtk.Box {
|
||||||
|
|
||||||
public enum assistant_mode { new_app, edit_app }
|
public enum assistant_mode { new_app, edit_app }
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace Webpin {
|
||||||
default_color = { 222, 222, 222, 255 };
|
default_color = { 222, 222, 222, 255 };
|
||||||
}
|
}
|
||||||
|
|
||||||
public Assistant () {
|
public Editor () {
|
||||||
|
|
||||||
GLib.Object (orientation: Gtk.Orientation.VERTICAL);
|
GLib.Object (orientation: Gtk.Orientation.VERTICAL);
|
||||||
apps = Services.DesktopFilesManager.get_applications ();
|
apps = Services.DesktopFilesManager.get_applications ();
|
|
@ -26,33 +26,33 @@
|
||||||
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Webpin {
|
namespace Webpin.Widgets.Views {
|
||||||
public class ApplicationsView : Gtk.Box {
|
public class WebItemsView : Gtk.Box {
|
||||||
|
|
||||||
public signal void add_request ();
|
public signal void add_request ();
|
||||||
public signal void edit_request (DesktopFile desktop_file);
|
public signal void edit_request (DesktopFile desktop_file);
|
||||||
public signal void app_deleted ();
|
public signal void app_deleted ();
|
||||||
|
|
||||||
Gtk.FlowBox icon_view;
|
Gtk.FlowBox web_items;
|
||||||
|
|
||||||
public bool has_items { get { return icon_view.get_children ().length () > 0; } }
|
public bool has_items { get { return web_items.get_children ().length () > 0; } }
|
||||||
|
|
||||||
public ApplicationsView () {
|
public WebItemsView () {
|
||||||
|
|
||||||
GLib.Object (orientation: Gtk.Orientation.VERTICAL);
|
GLib.Object (orientation: Gtk.Orientation.VERTICAL);
|
||||||
var scrolled = new Gtk.ScrolledWindow (null, null);
|
var scrolled = new Gtk.ScrolledWindow (null, null);
|
||||||
scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
|
scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
|
||||||
|
|
||||||
icon_view = new Gtk.FlowBox();
|
web_items = new Gtk.FlowBox();
|
||||||
icon_view.valign = Gtk.Align.START;
|
web_items.valign = Gtk.Align.START;
|
||||||
icon_view.vexpand = false;
|
web_items.vexpand = false;
|
||||||
icon_view.homogeneous = true;
|
web_items.homogeneous = true;
|
||||||
icon_view.column_spacing = 24;
|
web_items.column_spacing = 12;
|
||||||
icon_view.row_spacing = 24;
|
web_items.row_spacing = 12;
|
||||||
icon_view.margin = 24;
|
web_items.margin = 24;
|
||||||
icon_view.child_activated.connect ((child) => {
|
web_items.child_activated.connect ((child) => {
|
||||||
if ((child as Gtk.FlowBoxChild).get_child () is ApplicationIcon) {
|
if (child is WebItem) {
|
||||||
var app_icon = (child as Gtk.FlowBoxChild).get_child () as ApplicationIcon;
|
var app_icon = child as WebItem;
|
||||||
try {
|
try {
|
||||||
Process.spawn_command_line_async ("com.github.artemanufrij.webpin " + app_icon.desktop_file.url.replace("%%", "%"));
|
Process.spawn_command_line_async ("com.github.artemanufrij.webpin " + app_icon.desktop_file.url.replace("%%", "%"));
|
||||||
} catch (SpawnError err) {
|
} catch (SpawnError err) {
|
||||||
|
@ -62,7 +62,7 @@ namespace Webpin {
|
||||||
});
|
});
|
||||||
load_applications ();
|
load_applications ();
|
||||||
|
|
||||||
scrolled.add (icon_view);
|
scrolled.add (web_items);
|
||||||
this.pack_start (scrolled, true, true, 0);
|
this.pack_start (scrolled, true, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,40 +70,39 @@ namespace Webpin {
|
||||||
var applications = Services.DesktopFilesManager.get_webpin_applications ();
|
var applications = Services.DesktopFilesManager.get_webpin_applications ();
|
||||||
|
|
||||||
foreach (GLib.DesktopAppInfo app in applications.values) {
|
foreach (GLib.DesktopAppInfo app in applications.values) {
|
||||||
this.add_button (app);
|
this.add_web_item (app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add_button (GLib.DesktopAppInfo app) {
|
public void add_web_item (GLib.DesktopAppInfo app) {
|
||||||
var image = new ApplicationIcon (app);
|
var web_item = new WebItem (app);
|
||||||
image.edit_request.connect ((desktop_file) => {
|
web_item.edit_request.connect ((desktop_file) => {
|
||||||
edit_request (desktop_file);
|
edit_request (desktop_file);
|
||||||
icon_view.unselect_all ();
|
web_items.unselect_all ();
|
||||||
});
|
});
|
||||||
image.deleted.connect ((parent) => {
|
web_item.deleted.connect (() => {
|
||||||
this.icon_view.remove (parent);
|
|
||||||
app_deleted ();
|
app_deleted ();
|
||||||
});
|
});
|
||||||
icon_view.add (image);
|
web_items.add (web_item);
|
||||||
icon_view.show_all ();
|
web_items.show_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select_last_item () {
|
public void select_last_item () {
|
||||||
icon_view.select_child (icon_view.get_child_at_index ((int)icon_view.get_children ().length () - 1));
|
web_items.select_child (web_items.get_child_at_index ((int)web_items.get_children ().length () - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select_first_item () {
|
public void select_first_item () {
|
||||||
icon_view.select_child (icon_view.get_child_at_index (0));
|
web_items.select_child (web_items.get_child_at_index (0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_button (GLib.DesktopAppInfo app) {
|
public void update_button (GLib.DesktopAppInfo app) {
|
||||||
foreach (var item in icon_view.get_children ()) {
|
foreach (var item in web_items.get_children ()) {
|
||||||
if ((item as Gtk.FlowBoxChild).get_child () is ApplicationIcon) {
|
if (item is WebItem) {
|
||||||
var app_icon = (item as Gtk.FlowBoxChild).get_child () as ApplicationIcon;
|
var app_icon = item as WebItem;
|
||||||
|
|
||||||
if (app_icon.desktop_file.name == app.get_display_name ()) {
|
if (app_icon.desktop_file.name == app.get_display_name ()) {
|
||||||
app_icon.set_new_desktopfile (new DesktopFile.from_desktopappinfo (app));
|
app_icon.set_new_desktopfile (new DesktopFile.from_desktopappinfo (app));
|
||||||
icon_view.select_child (item as Gtk.FlowBoxChild);
|
web_items.select_child (item as Gtk.FlowBoxChild);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,51 +26,48 @@
|
||||||
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Webpin {
|
namespace Webpin.Widgets {
|
||||||
public class ApplicationIcon : Gtk.Overlay {
|
public class WebItem : Gtk.FlowBoxChild {
|
||||||
|
|
||||||
Gtk.Image image;
|
Gtk.Image image;
|
||||||
Gtk.Label label;
|
Gtk.Label label;
|
||||||
Gtk.Box box;
|
|
||||||
|
|
||||||
internal DesktopFile desktop_file { get; private set; }
|
internal DesktopFile desktop_file { get; private set; }
|
||||||
|
|
||||||
public signal void deleted (Gtk.Container? parent);
|
public signal void deleted ();
|
||||||
public signal void edit_request (DesktopFile desktop_file);
|
public signal void edit_request (DesktopFile desktop_file);
|
||||||
|
|
||||||
public ApplicationIcon (GLib.DesktopAppInfo app) {
|
public WebItem (GLib.DesktopAppInfo app) {
|
||||||
this.desktop_file = new DesktopFile.from_desktopappinfo (app);
|
this.desktop_file = new DesktopFile.from_desktopappinfo (app);
|
||||||
|
build_ui ();
|
||||||
|
}
|
||||||
|
|
||||||
hexpand = false;
|
private void build_ui () {
|
||||||
vexpand = false;
|
var content = new Gtk.Grid ();
|
||||||
|
content.margin = 12;
|
||||||
|
content.halign = Gtk.Align.CENTER;
|
||||||
|
content.row_spacing = 6;
|
||||||
|
|
||||||
|
image = new Gtk.Image ();
|
||||||
label = new Gtk.Label (this.desktop_file.name);
|
label = new Gtk.Label (this.desktop_file.name);
|
||||||
|
|
||||||
set_icon (this.desktop_file.icon);
|
set_icon (this.desktop_file.icon);
|
||||||
|
|
||||||
this.margin = 6;
|
|
||||||
this.margin_start = 20;
|
|
||||||
this.margin_end = 20;
|
|
||||||
|
|
||||||
var menu = new ActionMenu ();
|
var menu = new ActionMenu ();
|
||||||
menu.halign = Gtk.Align.CENTER;
|
menu.halign = Gtk.Align.CENTER;
|
||||||
menu.delete_clicked.connect (() => { remove_application (); });
|
menu.delete_clicked.connect (() => { remove_application (); });
|
||||||
menu.edit_clicked.connect (() => { edit_request (desktop_file); });
|
menu.edit_clicked.connect (() => { edit_request (desktop_file); });
|
||||||
|
|
||||||
box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
content.attach (image, 0, 0);
|
||||||
box.pack_start (image, false, false, 0);
|
content.attach (label, 0, 1);
|
||||||
box.pack_start (label, false, false, 0);
|
content.attach (menu, 0, 2);
|
||||||
box.pack_start (menu, false, false, 0);
|
|
||||||
|
|
||||||
box.hexpand = false;
|
|
||||||
box.vexpand = false;
|
|
||||||
|
|
||||||
var event_box = new Gtk.EventBox ();
|
var event_box = new Gtk.EventBox ();
|
||||||
event_box.add (box);
|
event_box.add (content);
|
||||||
event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK;
|
event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK;
|
||||||
|
|
||||||
event_box.enter_notify_event.connect ((event) => {
|
event_box.enter_notify_event.connect ((event) => {
|
||||||
menu.set_reveal_child (true);
|
menu.opacity = 0.5;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +75,7 @@ namespace Webpin {
|
||||||
if (event.detail == Gdk.NotifyType.INFERIOR) {
|
if (event.detail == Gdk.NotifyType.INFERIOR) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
menu.set_reveal_child (false);
|
menu.opacity = 0;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,30 +95,9 @@ namespace Webpin {
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning (e.message);
|
warning (e.message);
|
||||||
}
|
}
|
||||||
int new_height = 64;
|
pix = Services.DesktopFilesManager.align_and_scale_pixbuf (pix, 64);
|
||||||
int new_width = 64;
|
image.set_from_pixbuf (pix);
|
||||||
int margin_vertical = 0;
|
|
||||||
int margin_horizontal = 0;
|
|
||||||
|
|
||||||
if (pix.height > pix.width) {
|
|
||||||
new_width = new_width * pix.width / pix.height;
|
|
||||||
margin_horizontal = (new_height - new_width) / 2;
|
|
||||||
} else if (pix.height < pix.width) {
|
|
||||||
new_height = new_height * pix.height / pix.width;
|
|
||||||
margin_vertical = (new_width - new_height) / 2;
|
|
||||||
}
|
|
||||||
if (image == null) {
|
|
||||||
image = new Gtk.Image.from_pixbuf (pix.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR));
|
|
||||||
} else {
|
} else {
|
||||||
image.set_from_pixbuf (pix.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
image.margin_top = margin_vertical;
|
|
||||||
image.margin_bottom = margin_vertical;
|
|
||||||
image.margin_right = margin_horizontal;
|
|
||||||
image.margin_left = margin_horizontal;
|
|
||||||
} else {
|
|
||||||
image = new Gtk.Image ();
|
|
||||||
image.icon_name = icon;
|
image.icon_name = icon;
|
||||||
image.pixel_size = 64;
|
image.pixel_size = 64;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +105,12 @@ namespace Webpin {
|
||||||
|
|
||||||
private void remove_application () {
|
private void remove_application () {
|
||||||
desktop_file.delete_file ();
|
desktop_file.delete_file ();
|
||||||
deleted (this.get_parent());
|
deleted ();
|
||||||
this.destroy ();
|
this.destroy ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionMenu : Gtk.Revealer {
|
public class ActionMenu : Gtk.Grid {
|
||||||
|
|
||||||
public signal void delete_clicked ();
|
public signal void delete_clicked ();
|
||||||
public signal void edit_clicked ();
|
public signal void edit_clicked ();
|
||||||
|
@ -150,14 +126,9 @@ namespace Webpin {
|
||||||
edit_button.relief = Gtk.ReliefStyle.NONE;
|
edit_button.relief = Gtk.ReliefStyle.NONE;
|
||||||
edit_button.clicked.connect (() => { edit_clicked (); });
|
edit_button.clicked.connect (() => { edit_clicked (); });
|
||||||
|
|
||||||
var buttons = new Gtk.Grid ();
|
this.add (edit_button);
|
||||||
buttons.orientation = Gtk.Orientation.HORIZONTAL;
|
this.add (delete_button);
|
||||||
buttons.add (edit_button);
|
this.opacity = 0;
|
||||||
buttons.add (delete_button);
|
|
||||||
buttons.opacity = 0.5;
|
|
||||||
|
|
||||||
this.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
|
|
||||||
this.add (buttons);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,17 +26,17 @@
|
||||||
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
* Authored by: Artem Anufrij <artem.anufrij@live.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Webpin {
|
namespace Webpin.Windows {
|
||||||
public class WebWindow : Gtk.Window {
|
public class WebApp : Gtk.Window {
|
||||||
|
|
||||||
Gdk.WindowState current_state;
|
Gdk.WindowState current_state;
|
||||||
|
|
||||||
WebApp web_app;
|
Widgets.Browser browser;
|
||||||
Gtk.Spinner spinner;
|
Gtk.Spinner spinner;
|
||||||
|
|
||||||
public DesktopFile desktop_file { get; private set; }
|
public DesktopFile desktop_file { get; private set; }
|
||||||
|
|
||||||
public WebWindow (DesktopFile desktop_file) {
|
public WebApp (DesktopFile desktop_file) {
|
||||||
this.desktop_file = desktop_file;
|
this.desktop_file = desktop_file;
|
||||||
this.set_wmclass (desktop_file.url, desktop_file.url);
|
this.set_wmclass (desktop_file.url, desktop_file.url);
|
||||||
this.events |= Gdk.EventMask.STRUCTURE_MASK;
|
this.events |= Gdk.EventMask.STRUCTURE_MASK;
|
||||||
|
@ -45,7 +45,7 @@ namespace Webpin {
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
set_color (color);
|
set_color (color);
|
||||||
}
|
}
|
||||||
web_app = new WebApp (desktop_file);
|
browser = new Widgets.Browser (desktop_file);
|
||||||
|
|
||||||
var headerbar = new Gtk.HeaderBar ();
|
var headerbar = new Gtk.HeaderBar ();
|
||||||
headerbar.title = desktop_file.name;
|
headerbar.title = desktop_file.name;
|
||||||
|
@ -54,7 +54,7 @@ namespace Webpin {
|
||||||
var copy_url = new Gtk.Button.from_icon_name ("insert-link-symbolic", Gtk.IconSize.MENU);
|
var copy_url = new Gtk.Button.from_icon_name ("insert-link-symbolic", Gtk.IconSize.MENU);
|
||||||
copy_url.tooltip_text = _("Copy URL into clipboard");
|
copy_url.tooltip_text = _("Copy URL into clipboard");
|
||||||
copy_url.clicked.connect (() => {
|
copy_url.clicked.connect (() => {
|
||||||
Gtk.Clipboard.get_default (Gdk.Display.get_default ()).set_text (web_app.app_view.uri, -1);
|
Gtk.Clipboard.get_default (Gdk.Display.get_default ()).set_text (browser.app_view.uri, -1);
|
||||||
});
|
});
|
||||||
headerbar.pack_end (copy_url);
|
headerbar.pack_end (copy_url);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace Webpin {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.external_request.connect ((action) => {
|
browser.external_request.connect ((action) => {
|
||||||
debug ("Web app external request: %s", action.get_request ().uri);
|
debug ("Web app external request: %s", action.get_request ().uri);
|
||||||
try {
|
try {
|
||||||
Process.spawn_command_line_async ("xdg-open " + action.get_request ().uri);
|
Process.spawn_command_line_async ("xdg-open " + action.get_request ().uri);
|
||||||
|
@ -96,7 +96,7 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.desktop_notification.connect ((title, body, icon) => {
|
browser.desktop_notification.connect ((title, body, icon) => {
|
||||||
var desktop_notification = new Notification (title);
|
var desktop_notification = new Notification (title);
|
||||||
desktop_notification.set_body (body);
|
desktop_notification.set_body (body);
|
||||||
desktop_notification.set_icon (icon);
|
desktop_notification.set_icon (icon);
|
||||||
|
@ -104,15 +104,15 @@ namespace Webpin {
|
||||||
WebpinApp.instance.send_notification (null, desktop_notification);
|
WebpinApp.instance.send_notification (null, desktop_notification);
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.request_begin.connect (() => {
|
browser.request_begin.connect (() => {
|
||||||
spinner.active = true;
|
spinner.active = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.request_finished.connect (() => {
|
browser.request_finished.connect (() => {
|
||||||
spinner.active = false;
|
spinner.active = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.found_website_color.connect ((color) => {
|
browser.found_website_color.connect ((color) => {
|
||||||
int gray_val = (int)(desktop_file.color.red * 255);
|
int gray_val = (int)(desktop_file.color.red * 255);
|
||||||
if (desktop_file.color == null || (gray_val == 222 && desktop_file.color.red == desktop_file.color.green && desktop_file.color.red == desktop_file.color.blue)) {
|
if (desktop_file.color == null || (gray_val == 222 && desktop_file.color.red == desktop_file.color.green && desktop_file.color.red == desktop_file.color.blue)) {
|
||||||
set_color (color);
|
set_color (color);
|
||||||
|
@ -120,7 +120,7 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.add (web_app);
|
this.add (browser);
|
||||||
|
|
||||||
load_settings ();
|
load_settings ();
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoom != null) {
|
if (zoom != null) {
|
||||||
web_app.app_view.zoom_level = double.parse (zoom);
|
browser.app_view.zoom_level = double.parse (zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,43 +186,43 @@ namespace Webpin {
|
||||||
case Gdk.Key.KP_Add:
|
case Gdk.Key.KP_Add:
|
||||||
case Gdk.Key.plus:
|
case Gdk.Key.plus:
|
||||||
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
||||||
web_app.app_view.zoom_level += 0.1;
|
browser.app_view.zoom_level += 0.1;
|
||||||
desktop_file.edit_property ("X-Webpin-WindowZoom", web_app.app_view.zoom_level.to_string ());
|
desktop_file.edit_property ("X-Webpin-WindowZoom", browser.app_view.zoom_level.to_string ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Gdk.Key.KP_Subtract:
|
case Gdk.Key.KP_Subtract:
|
||||||
case Gdk.Key.minus:
|
case Gdk.Key.minus:
|
||||||
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
||||||
web_app.app_view.zoom_level -= 0.1;
|
browser.app_view.zoom_level -= 0.1;
|
||||||
desktop_file.edit_property ("X-Webpin-WindowZoom", web_app.app_view.zoom_level.to_string ());
|
desktop_file.edit_property ("X-Webpin-WindowZoom", browser.app_view.zoom_level.to_string ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Gdk.Key.KP_0:
|
case Gdk.Key.KP_0:
|
||||||
case Gdk.Key.@0:
|
case Gdk.Key.@0:
|
||||||
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
||||||
web_app.app_view.zoom_level = 1;
|
browser.app_view.zoom_level = 1;
|
||||||
desktop_file.edit_property ("X-Webpin-WindowZoom", web_app.app_view.zoom_level.to_string ());
|
desktop_file.edit_property ("X-Webpin-WindowZoom", browser.app_view.zoom_level.to_string ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Gdk.Key.F5:
|
case Gdk.Key.F5:
|
||||||
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
if (Gdk.ModifierType.CONTROL_MASK in event.state) {
|
||||||
web_app.app_view.reload ();
|
browser.app_view.reload ();
|
||||||
} else {
|
} else {
|
||||||
web_app.app_view.reload_bypass_cache ();
|
browser.app_view.reload_bypass_cache ();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Gdk.Key.Left:
|
case Gdk.Key.Left:
|
||||||
if (Gdk.ModifierType.MOD1_MASK in event.state) {
|
if (Gdk.ModifierType.MOD1_MASK in event.state) {
|
||||||
web_app.app_view.go_back ();
|
browser.app_view.go_back ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Gdk.Key.Right:
|
case Gdk.Key.Right:
|
||||||
if (Gdk.ModifierType.MOD1_MASK in event.state) {
|
if (Gdk.ModifierType.MOD1_MASK in event.state) {
|
||||||
web_app.app_view.go_forward ();
|
browser.app_view.go_forward ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
Loading…
Reference in a new issue