Browse Source

Use gresources and add new camera icon

whitebalance
Martijn Braam 1 year ago
parent
commit
efb26135bd
  1. 2
      camera.glade
  2. 14
      main.c
  3. 6
      meson.build
  4. 8
      org.postmarketos.Megapixels.gresource.xml
  5. 51
      switch-camera.svg

2
camera.glade

@ -103,7 +103,7 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-refresh</property>
<property name="resource">/org/postmarketos/Megapixels/switch-camera.svg</property>
</object>
</child>
</object>

14
main.c

@ -851,19 +851,9 @@ main(int argc, char *argv[])
return 1;
}
GError *error = NULL;
gtk_init(&argc, &argv);
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", TRUE, NULL);
GtkBuilder *builder = gtk_builder_new();
char *glade_file = "/usr/share/megapixels/ui/camera.glade";
if (access("camera.glade", F_OK) != -1) {
glade_file = "camera.glade";
}
if (gtk_builder_add_from_file(builder, glade_file, &error) == 0) {
g_printerr("Error loading file: %s\n", error->message);
g_clear_error(&error);
return 1;
}
GtkBuilder *builder = gtk_builder_new_from_resource("/org/postmarketos/Megapixels/camera.glade");
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
GtkWidget *preview_box = GTK_WIDGET(gtk_builder_get_object(builder, "preview_box"));
@ -885,7 +875,7 @@ main(int argc, char *argv[])
if (access("camera.css", F_OK) != -1) {
gtk_css_provider_load_from_path(provider, "camera.css", NULL);
} else {
gtk_css_provider_load_from_path(provider, "/usr/share/megapixels/ui/camera.css", NULL);
gtk_css_provider_load_from_resource(provider, "/org/postmarketos/Megapixels/camera.css");
}
GtkStyleContext *context = gtk_widget_get_style_context(preview_box);
gtk_style_context_add_provider(context,

6
meson.build

@ -1,13 +1,13 @@
project('megapixels', 'c')
gnome = import('gnome')
gtkdep = dependency('gtk+-3.0')
cc = meson.get_compiler('c')
libm = cc.find_library('m', required: false)
executable('megapixels', 'main.c', 'ini.c', 'bayer.c', 'quickdebayer.c', dependencies : [gtkdep, libm], install : true)
resources = gnome.compile_resources('megapixels-resources', 'org.postmarketos.Megapixels.gresource.xml')
install_data(['camera.glade', 'camera.css'],
install_dir : get_option('datadir') / 'megapixels/ui')
executable('megapixels', 'main.c', 'ini.c', 'bayer.c', 'quickdebayer.c', resources, dependencies : [gtkdep, libm], install : true)
install_data(['org.postmarketos.Megapixels.desktop'],
install_dir : get_option('datadir') / 'applications')

8
org.postmarketos.Megapixels.gresource.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/postmarketos/Megapixels">
<file>camera.glade</file>
<file>camera.css</file>
<file>switch-camera.svg</file>
</gresource>
</gresources>

51
switch-camera.svg

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 6.3499999 6.3500002"
version="1.1"
id="svg8">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
id="rect10"
style="fill:#bebebe;fill-rule:evenodd;stroke-width:0.981721;fill-opacity:1"
d="M 6.2675781 7 C 5.642948 7 5.0792263 7.250453 4.6699219 7.65625 L 5.0527344 8.1835938 L 6.7832031 7 L 6.2675781 7 z M 7.7753906 7 L 6.6464844 12.794922 L 4 12.832031 L 4 14.732422 C 4 15.988737 5.0112635 17 6.2675781 17 L 15.414062 17 L 18.443359 12.070312 L 20 12.646484 L 20 9.2675781 C 20 8.0112632 18.988737 7 17.732422 7 L 7.7753906 7 z M 11.984375 8.4414062 A 3.4999999 3.4999999 0 0 1 15.484375 11.941406 A 3.4999999 3.4999999 0 0 1 11.984375 15.441406 A 3.4999999 3.4999999 0 0 1 8.484375 11.941406 A 3.4999999 3.4999999 0 0 1 11.984375 8.4414062 z "
transform="scale(0.26458333)" />
<rect
style="fill:#bebebe;stroke-width:0.430371;fill-opacity:1"
id="rect32"
width="2.1166666"
x="2.1166666"
y="1.3229167"
rx="2.7755576e-17"
height="0.79374999" />
<path
style="fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 2.9104166,0.79374999 C 1.0262128,0.90909341 0.00928708,1.445563 0.8274781,2.7119284 0.70723812,2.8613287 0.26458333,3.175 0.26458333,3.175 H 1.5875 L 1.8521525,2.0440428 c 0,0 -0.035266,0.029416 -0.5759985,0.4042251 C 0.2287544,1.4462035 1.9079139,1.1486032 2.9104166,0.79374999 Z"
id="path864" />
<path
style="fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 2.9647831,5.3081179 C 4.7938353,5.7751257 5.9261679,5.5757251 5.5349326,4.119685 5.6951359,4.0142668 6.2125632,3.8511655 6.2125632,3.8511655 L 4.9531606,3.4461794 4.3549929,4.4418202 c 0,0 0.042578,-0.017208 0.6720904,-0.2084869 0.69035,1.2745964 -0.9992967,1.0438655 -2.0623002,1.0747846 z"
id="path864-0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Loading…
Cancel
Save