Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
gradio 4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
haecker-felix committed Jul 28, 2016
1 parent a490f3b commit 366b15d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 37 deletions.
5 changes: 3 additions & 2 deletions data/ui/settings-dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
</child>
<child>
<object class="GtkSwitch" id="UseDarkDesignSwitch">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="no_show_all">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
Expand All @@ -84,7 +85,7 @@
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="visible">false</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Use dark design:</property>
Expand Down
2 changes: 1 addition & 1 deletion po/gradio.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-28 13:00+0200\n"
"POT-Creation-Date: 2016-07-28 13:59+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
72 changes: 38 additions & 34 deletions src/Util.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,53 @@ public class Util{
}

public static async Gdk.Pixbuf get_image_from_url (string url, int height, int width){
SourceFunc callback = get_image_from_url.callback;
Gdk.Pixbuf output = null;

ThreadFunc<void*> run = () => {
if(url != ""){
var session = new Soup.Session ();
var message = new Soup.Message ("GET", url);
var loader = new Gdk.PixbufLoader();
if(Gradio.App.settings.get_boolean ("load-pictures")){
SourceFunc callback = get_image_from_url.callback;
Gdk.Pixbuf output = null;

ThreadFunc<void*> run = () => {
if(url != ""){
var session = new Soup.Session ();
var message = new Soup.Message ("GET", url);
var loader = new Gdk.PixbufLoader();

session.user_agent = "gradio/"+Constants.VERSION;
if(message == null){
try{
loader.close();
}catch(GLib.Error e){
warning(e.message);
}

return null;
}
session.send_message (message);

session.user_agent = "gradio/"+Constants.VERSION;
if(message == null){
try{
if(message.response_body.data != null)
loader.write(message.response_body.data);

loader.close();
}catch(GLib.Error e){
warning(e.message);
var pixbuf = loader.get_pixbuf();
output = pixbuf.scale_simple(width, height, Gdk.InterpType.BILINEAR);
}catch (Error e){
debug("Pixbufloader: " + e.message);
}

return null;
session.abort();
}
session.send_message (message);

try{
if(message.response_body.data != null)
loader.write(message.response_body.data);
Idle.add((owned) callback);
Thread.exit (1.to_pointer ());
return null;
};

loader.close();
var pixbuf = loader.get_pixbuf();
output = pixbuf.scale_simple(width, height, Gdk.InterpType.BILINEAR);
}catch (Error e){
debug("Pixbufloader: " + e.message);
}

session.abort();
}

Idle.add((owned) callback);
Thread.exit (1.to_pointer ());
new Thread<void*> ("image_thread", run);
yield;
return output;
}else{
return null;
};

new Thread<void*> ("image_thread", run);
yield;
return output;
}
}

public static void remove_all_items_from_list_box (Gtk.ListBox container) {
Expand Down
3 changes: 3 additions & 0 deletions src/Widgets/SettingsDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ namespace Gradio{
private GLib.Settings settings;

public SettingsDialog () {
var gtk_settings = Gtk.Settings.get_default ();
settings = new GLib.Settings ("de.haecker-felix.gradio");
load_settings(settings);

OnlyShowWorkingStationsSwitch.notify["active"].connect (() => {
if (OnlyShowWorkingStationsSwitch.active) {
settings.set_boolean ("only-show-working-stations", true);
gtk_settings.gtk_application_prefer_dark_theme = true;
} else {
settings.set_boolean ("only-show-working-stations", false);
gtk_settings.gtk_application_prefer_dark_theme = false;
}

});
Expand Down

0 comments on commit 366b15d

Please sign in to comment.