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_url_entry;
private Gtk.Entry icon_name_entry;
private Gtk.ComboBox app_category_combo;
private Gtk.CheckButton save_cookies_check;
private Gtk.CheckButton save_password_check;
private Gtk.Popover icon_selector_popover;
@ -72,7 +71,7 @@ namespace Webpin {
//welcome message
message = new Gtk.Label (_("Create a new web app with webby"));
message.get_style_context ().add_class ("h2");
//app information
icon_button = new Gtk.Button ();
icon_button.set_image (new Gtk.Image.from_icon_name (default_app_icon, Gtk.IconSize.DIALOG) );
@ -262,7 +261,7 @@ namespace Webpin {
file_chooser.set_preview_widget_active (true);
file_chooser.set_preview_widget (preview);
} 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;
file = new GLib.KeyFile();
try {
file.load_from_data (template, -1, GLib.KeyFileFlags.NONE);
} catch (Error e) {
warning (e.message);
}
//TODO: Category
file.set_string ("Desktop Entry", "Name", name);
file.set_string ("Desktop Entry", "GenericName", name);
@ -68,31 +72,53 @@ namespace Webpin {
public DesktopFile.from_desktopappinfo(GLib.DesktopAppInfo info) {
file = new GLib.KeyFile();
try {
file.load_from_file (info.filename, KeyFileFlags.NONE);
} catch (Error e) {
warning (e.message);
}
this.name = info.get_display_name ();
this.icon = info.get_icon ().to_string ();
try {
this.url = file.get_string ("Desktop Entry", "Exec").substring (31);
} catch (Error e) {
warning (e.message);
}
}
public bool edit_propertie (string propertie, string val) {
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.load_from_file (filename, KeyFileFlags.NONE);
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 () {
GLib.DesktopAppInfo return_value = null;
try {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop";
print("Desktop file created: " + 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 () {
try {
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webpin.desktop";
File file = File.new_for_path (filename);
try {
file.delete ();
} catch (Error e) {
print(e.message + "\n");

View file

@ -50,11 +50,11 @@ namespace Webpin {
url_entry.show_all();
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 ();
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 ();
pack_start (back_button);

View file

@ -31,9 +31,7 @@ namespace Webpin {
Gtk.Image image;
Gtk.Label label;
Gtk.MenuButton conf_btn;
Gtk.Box box;
Gtk.ActionGroup action_group;
internal DesktopFile desktop_file { get; private set; }
@ -93,8 +91,12 @@ namespace Webpin {
private void set_icon (string icon) {
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_width = 64;
int margin_vertical = 0;