removed unused code and fixed some warnings

This commit is contained in:
Artem Anufrij 2017-07-31 23:20:13 +02:00
parent 661dd3d5cb
commit 713146cb1e
4 changed files with 52 additions and 25 deletions

View file

@ -39,7 +39,6 @@ namespace Webpin {
private Gtk.Entry app_name_entry; private Gtk.Entry app_name_entry;
private Gtk.Entry app_url_entry; private Gtk.Entry app_url_entry;
private Gtk.Entry icon_name_entry; private Gtk.Entry icon_name_entry;
private Gtk.ComboBox app_category_combo;
private Gtk.CheckButton save_cookies_check; private Gtk.CheckButton save_cookies_check;
private Gtk.CheckButton save_password_check; private Gtk.CheckButton save_password_check;
private Gtk.Popover icon_selector_popover; private Gtk.Popover icon_selector_popover;
@ -72,7 +71,7 @@ namespace Webpin {
//welcome message //welcome message
message = new Gtk.Label (_("Create a new web app with webby")); message = new Gtk.Label (_("Create a new web app with webby"));
message.get_style_context ().add_class ("h2");
//app information //app information
icon_button = new Gtk.Button (); icon_button = new Gtk.Button ();
icon_button.set_image (new Gtk.Image.from_icon_name (default_app_icon, Gtk.IconSize.DIALOG) ); icon_button.set_image (new Gtk.Image.from_icon_name (default_app_icon, Gtk.IconSize.DIALOG) );
@ -257,12 +256,12 @@ namespace Webpin {
} }
} }
if (pix!=null){ if (pix != null){
preview.set_from_pixbuf (pix); preview.set_from_pixbuf (pix);
file_chooser.set_preview_widget_active (true); file_chooser.set_preview_widget_active (true);
file_chooser.set_preview_widget (preview); file_chooser.set_preview_widget (preview);
} else { } else {
file_chooser.set_preview_widget (null); file_chooser.set_preview_widget_active (false);
} }
}); });

View file

@ -56,7 +56,11 @@ namespace Webpin {
this.icon = icon; this.icon = icon;
file = new GLib.KeyFile(); file = new GLib.KeyFile();
try {
file.load_from_data (template, -1, GLib.KeyFileFlags.NONE); file.load_from_data (template, -1, GLib.KeyFileFlags.NONE);
} catch (Error e) {
warning (e.message);
}
//TODO: Category //TODO: Category
file.set_string ("Desktop Entry", "Name", name); file.set_string ("Desktop Entry", "Name", name);
file.set_string ("Desktop Entry", "GenericName", name); file.set_string ("Desktop Entry", "GenericName", name);
@ -68,31 +72,53 @@ namespace Webpin {
public DesktopFile.from_desktopappinfo(GLib.DesktopAppInfo info) { public DesktopFile.from_desktopappinfo(GLib.DesktopAppInfo info) {
file = new GLib.KeyFile(); file = new GLib.KeyFile();
try {
file.load_from_file (info.filename, KeyFileFlags.NONE); file.load_from_file (info.filename, KeyFileFlags.NONE);
} catch (Error e) {
warning (e.message);
}
this.name = info.get_display_name (); this.name = info.get_display_name ();
this.icon = info.get_icon ().to_string (); this.icon = info.get_icon ().to_string ();
try {
this.url = file.get_string ("Desktop Entry", "Exec").substring (31); this.url = file.get_string ("Desktop Entry", "Exec").substring (31);
} catch (Error e) {
warning (e.message);
}
} }
public bool edit_propertie (string propertie, string val) { public bool edit_propertie (string propertie, string val) {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop"; bool return_value = false;
try {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" + file.get_string("Desktop Entry", "Name") + "-webpin.desktop";
file = new GLib.KeyFile(); file = new GLib.KeyFile();
file.load_from_file (filename, KeyFileFlags.NONE); file.load_from_file (filename, KeyFileFlags.NONE);
file.set_string ("Desktop Entry", propertie, val); file.set_string ("Desktop Entry", propertie, val);
return file.save_to_file (filename); return_value = file.save_to_file (filename);
} catch (Error e) {
warning (e.message);
}
return return_value;
} }
public GLib.DesktopAppInfo save_to_file () { public GLib.DesktopAppInfo save_to_file () {
GLib.DesktopAppInfo return_value = null;
try {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop"; string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop";
print("Desktop file created: " + filename); print("Desktop file created: " + filename);
file.save_to_file (filename); file.save_to_file (filename);
return new GLib.DesktopAppInfo.from_filename (filename); return_value = new GLib.DesktopAppInfo.from_filename (filename);
} catch (Error e) {
warning (e.message);
}
return return_value;
} }
public bool delete_file () { public bool delete_file () {
try {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop"; string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop";
File file = File.new_for_path (filename); File file = File.new_for_path (filename);
try {
file.delete (); file.delete ();
} catch (Error e) { } catch (Error e) {
print(e.message + "\n"); print(e.message + "\n");

View file

@ -50,11 +50,11 @@ namespace Webpin {
url_entry.show_all(); url_entry.show_all();
share_button = new Gtk.Button.from_icon_name ("application-menu-symbolic", Gtk.IconSize.SMALL_TOOLBAR); share_button = new Gtk.Button.from_icon_name ("application-menu-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
share_button.margin_left = 15; share_button.margin_start = 15;
share_button.show_all (); share_button.show_all ();
back_button = new Gtk.Button.from_icon_name ("go-next-symbolic-rtl", Gtk.IconSize.SMALL_TOOLBAR); back_button = new Gtk.Button.from_icon_name ("go-next-symbolic-rtl", Gtk.IconSize.SMALL_TOOLBAR);
back_button.margin_right = 15; back_button.margin_end = 15;
back_button.show_all (); back_button.show_all ();
pack_start (back_button); pack_start (back_button);

View file

@ -31,9 +31,7 @@ namespace Webpin {
Gtk.Image image; Gtk.Image image;
Gtk.Label label; Gtk.Label label;
Gtk.MenuButton conf_btn;
Gtk.Box box; Gtk.Box box;
Gtk.ActionGroup action_group;
internal DesktopFile desktop_file { get; private set; } internal DesktopFile desktop_file { get; private set; }
@ -93,8 +91,12 @@ namespace Webpin {
private void set_icon (string icon) { private void set_icon (string icon) {
if (File.new_for_path (icon).query_exists ()) { if (File.new_for_path (icon).query_exists ()) {
var pix = new Gdk.Pixbuf.from_file (icon); Gdk.Pixbuf pix = null;
try {
pix = new Gdk.Pixbuf.from_file (icon);
} catch (Error e) {
warning (e.message);
}
int new_height = 64; int new_height = 64;
int new_width = 64; int new_width = 64;
int margin_vertical = 0; int margin_vertical = 0;