summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/KeyValueMap.vala2
-rw-r--r--src/util/Util.vala2
-rw-r--r--src/util/file.vala2
-rw-r--r--src/util/image.vala128
-rw-r--r--src/util/misc.vala2
-rw-r--r--src/util/string.vala2
-rw-r--r--src/util/system.vala26
-rw-r--r--src/util/ui.vala2
8 files changed, 141 insertions, 25 deletions
diff --git a/src/util/KeyValueMap.vala b/src/util/KeyValueMap.vala
index cf52719..dfc1fd2 100644
--- a/src/util/KeyValueMap.vala
+++ b/src/util/KeyValueMap.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
diff --git a/src/util/Util.vala b/src/util/Util.vala
index 701ca04..b87ea3a 100644
--- a/src/util/Util.vala
+++ b/src/util/Util.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
diff --git a/src/util/file.vala b/src/util/file.vala
index 8af5ca1..32b7762 100644
--- a/src/util/file.vala
+++ b/src/util/file.vala
@@ -1,4 +1,4 @@
-/* Copyright 2009-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
diff --git a/src/util/image.vala b/src/util/image.vala
index 4485fc7..92e276a 100644
--- a/src/util/image.vala
+++ b/src/util/image.vala
@@ -1,9 +1,119 @@
-/* Copyright 2009-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
+
+/* XPM */
+private const string fallback_image_missing[] = {
+/* columns rows colors chars-per-pixel */
+"48 48 54 1 ",
+" c #6A6D67",
+". c #6C6E69",
+"X c #72746F",
+"o c #747672",
+"O c #777974",
+"+ c #797B77",
+"@ c #7C7E7A",
+"# c #7F817C",
+"$ c #81837F",
+"% c #848682",
+"& c #878984",
+"* c #888A86",
+"= c #8C8D8A",
+"- c #8F908C",
+"; c #90928E",
+": c #949591",
+"> c #969894",
+", c #999B96",
+"< c #9C9E9A",
+"1 c #9FA09C",
+"2 c #A1A39E",
+"3 c #A4A6A2",
+"4 c #A6A9A4",
+"5 c #A9ABA6",
+"6 c #ACADA9",
+"7 c #AEB1AB",
+"8 c #B1B2AF",
+"9 c #B3B4B1",
+"0 c #B6B9B3",
+"q c #B9BCB6",
+"w c #BDBEBA",
+"e c #BEC2BB",
+"r c #C1C4BE",
+"t c #C5C5C2",
+"y c #C6C9C3",
+"u c #C9CCC6",
+"i c #CCCDCB",
+"p c #CED2CA",
+"a c #D2D6CE",
+"s c #D5D5D3",
+"d c #D7D8D5",
+"f c #D9D9D6",
+"g c #DCDCDA",
+"h c #DFE0DD",
+"j c #E0E0DE",
+"k c #E4E4E2",
+"l c #E7E8E5",
+"z c #E9E9E7",
+"x c #EDEDEC",
+"c c #EFF0EE",
+"v c #F1F1EF",
+"b c #F2F2F1",
+"n c #FFFFFF",
+"m c None",
+/* pixels */
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmaaaaaaaaaasaisaaaaaaaaaaaaaaaaaaapppiipuuuuumm",
+"mannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnym",
+"manbbbbbbbbbvbbvvvvxvvvbvvvvvvvvccccccxxvxvxxnym",
+"manbt89898888988888888888999999999999999999txnrm",
+"manb6======================-;;=;;;;;;;;;;=:7znrm",
+"manv6&%%**%*%%%%*%%****=======;==;;;;=;=;==7znem",
+"manv4%%%%$%%%%%%%%%%%=****=======;==-======6znwm",
+"manx3%%#$$$$##%#$%%%*%**==========-=--=====6znqm",
+"manx1$@%#$@$###%%%%=****=*===--;;----====*=5lnqm",
+"manx<@@@@@@@@##%$%%%%****========-==-======5kn0m",
+"manz<@@@+@+@@@#$%%%%%=%=%===;=:=--------=-*4kn8m",
+"manz>O+O+O+@@@#$$%%%%========;;=--------=*=3kn9m",
+"mpnl:OOOOO+@@$##%%%%%=%=====;=;;--;-----===3kn8m",
+"munl;OooOOO@@@#$%%%%%======;;;;;:;;;;;---==1hn7m",
+"munl;oXoOO+@###$%%=%=======;::;::::;;---&#+-gn7m",
+"mynk*XXooOO+$$#$%%%%=%===;;:;:::::;:-$#XooX-fn5m",
+"mynk*XXOOO@@$$$$%%=%====;::::>::;*#OXXXXXXX*dn5m",
+"mrnk*oOO@@@#$$$$%=====::::>>>=%@OXOooXXXooo&dn3m",
+"mrnj*++@$$$$**$===-;;::>>:=@Ooo@XOOoo#o#OOO=fn3m",
+"menj*@#$$$$$**===;;:::=%@@@@@@O@#O#Oo#o#++@;gn2m",
+"menj*$$$$&**===;:;=*#@@@@@@@@@@@#######o##%>gn2m",
+"menh*$$%**===;=*%###########%@@@###$####$%=,gn1m",
+"m0nj=%***=**&$$$%$$$%$$%$$$$%$$$$$$$$$$%*;:2hn<m",
+"m0nj****&&&$$&&$%%%%%%%%%%%%%%%%$$*$%%%*;>13gn,m",
+"m0ng****&&&&&&&&&&&&*%*%*%%*%******%**-:,136kz;m",
+"m0nh***$&&&&&&&&&&&&%**********%*$***;:,1358r7*m",
+"m8ng*&&&&&&&&&*$&*&&&&$=$=$=&&&&&&**=:,<11>$65mm",
+"m7ng*&&&&&&&&&**&&&&&&**=$-$&&&&&&*-:,1..&1wi:mm",
+"m7ng&&&&&&&&=$*$&&&&&***$$$$&&&***=>,1<onxsi6*mm",
+"m6nf*&&&&&*&$***&&&&*$*$--$-&&&%*=;,13,:ztw9%mmm",
+"m5nf*%&&&&&&=$=$%*&&**%*$$&&&&**=>,225;5srw%mmmm",
+"m4nf3*&&**&&$-$-*******%$;&&*&*->,2365+ui7$mmmmm",
+"m3nsfffdddsddaffssssdassgaaaassddfgjg4wu;ommmmmm",
+"m3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnvq3<$.mmmmmmm",
+"mm2211111,<,,,,,,>>>>:::;::;----=====@mmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm",
+"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"
+};
+
bool is_color_parsable(string spec) {
Gdk.Color color;
return Gdk.Color.parse(spec, out color);
@@ -29,6 +139,22 @@ void set_source_color_from_string(Cairo.Context ctx, string spec) {
private const int MIN_SCALED_WIDTH = 10;
private const int MIN_SCALED_HEIGHT = 10;
+Gdk.Pixbuf get_placeholder_pixbuf () {
+ // Create empty pixbuf.
+ Gdk.Pixbuf? pixbuf = null;
+
+ try {
+ var icon_theme = Gtk.IconTheme.get_default ();
+ pixbuf = icon_theme.load_icon("image-missing",
+ Gtk.IconSize.DIALOG, 0);
+ } catch (Error error) {
+ pixbuf = new Gdk.Pixbuf.from_xpm_data(fallback_image_missing);
+ warning("Could not load icon from theme: %s", error.message);
+ }
+
+ return pixbuf;
+}
+
Gdk.Pixbuf scale_pixbuf(Gdk.Pixbuf pixbuf, int scale, Gdk.InterpType interp, bool scale_up) {
Dimensions original = Dimensions.for_pixbuf(pixbuf);
Dimensions scaled = original.get_scaled(scale, scale_up);
diff --git a/src/util/misc.vala b/src/util/misc.vala
index 1507e02..cc6a278 100644
--- a/src/util/misc.vala
+++ b/src/util/misc.vala
@@ -1,4 +1,4 @@
-/* Copyright 2009-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
diff --git a/src/util/string.vala b/src/util/string.vala
index 3574249..7331780 100644
--- a/src/util/string.vala
+++ b/src/util/string.vala
@@ -1,4 +1,4 @@
-/* Copyright 2010-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
diff --git a/src/util/system.vala b/src/util/system.vala
index 8e5a07f..f2436e4 100644
--- a/src/util/system.vala
+++ b/src/util/system.vala
@@ -1,26 +1,19 @@
-/* Copyright 2009-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
-int number_of_processors() {
- int n = (int) ExtendedPosix.sysconf(ExtendedPosix.ConfName._SC_NPROCESSORS_ONLN);
- return n <= 0 ? 1 : n;
-}
-
// Return the directory in which Shotwell is installed, or null if uninstalled.
File? get_sys_install_dir(File exec_dir) {
- // guard against exec_dir being a symlink
- File exec_dir1 = exec_dir;
- try {
- exec_dir1 = File.new_for_path(
- FileUtils.read_link("/" + FileUtils.read_link(exec_dir.get_path())));
- } catch (FileError e) {
- // exec_dir is not a symlink
+ // Assume that if the ui folder lives next to the binary, we runn in-tree
+ File child = exec_dir.get_child("ui");
+
+ if (!FileUtils.test(child.get_path(), FileTest.IS_DIR | FileTest.EXISTS)) {
+ return File.new_for_path(Resources.PREFIX);
}
- File prefix_dir = File.new_for_path(Resources.PREFIX);
- return exec_dir1.has_prefix(prefix_dir) ? prefix_dir : null;
+
+ return null;
}
string get_nautilus_install_location() {
@@ -35,6 +28,3 @@ void show_file_in_nautilus(string filename) throws Error {
GLib.Process.spawn_command_line_async(get_nautilus_install_location() + " " + filename);
}
-int posix_wexitstatus(int status) {
- return (((status) & 0xff00) >> 8);
-}
diff --git a/src/util/ui.vala b/src/util/ui.vala
index b846f22..a161ebd 100644
--- a/src/util/ui.vala
+++ b/src/util/ui.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2015 Yorba Foundation
+/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.