summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
Diffstat (limited to 'endless')
-rw-r--r--endless/Makefile.am23
-rw-r--r--endless/eosactionbutton.c70
-rw-r--r--endless/eosapplication.c25
3 files changed, 69 insertions, 49 deletions
diff --git a/endless/Makefile.am b/endless/Makefile.am
index db6022c..1a7f56f 100644
--- a/endless/Makefile.am
+++ b/endless/Makefile.am
@@ -1,5 +1,27 @@
# Copyright 2013 Endless Mobile, Inc.
+# Generate dependencies for make rule from XML resource file description
+resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/data \
+ --generate-dependencies $(srcdir)/data/eos-sdk.gresource.xml)
+
+# Generated sources for GResource file
+endless/eosresource-private.h: data/eos-sdk.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(MKDIR_P) $(builddir)/data && \
+ $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data \
+ --generate-header --internal $<
+endless/eosresource.c: data/eos-sdk.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(MKDIR_P) $(builddir)/data && \
+ $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data \
+ --generate-source --internal $<
+
+BUILT_SOURCES = \
+ endless/eosresource-private.h \
+ endless/eosresource.c \
+ $(NULL)
+EXTRA_DIST += \
+ $(resource_files) \
+ data/eos-sdk.gresource.xml
+
endless_public_installed_headers = endless/endless.h
endless_private_installed_headers = \
@@ -20,6 +42,7 @@ endless_library_sources = \
endless/eosinit.c endless/eosinit-private.h \
endless/eospagemanager.c endless/eospagemanager-private.h \
endless/eosmainarea.c endless/eosmainarea-private.h \
+ endless/eosresource.c endless/eosresource-private.h \
endless/eossplashpagemanager.c \
endless/eostopbar.c endless/eostopbar-private.h \
endless/eosactionbutton.c \
diff --git a/endless/eosactionbutton.c b/endless/eosactionbutton.c
index 148cd2b..23c931c 100644
--- a/endless/eosactionbutton.c
+++ b/endless/eosactionbutton.c
@@ -49,7 +49,6 @@ struct _EosActionButtonPrivate
/* internal */
GtkWidget *grid;
GtkWidget *icon_image;
- GdkPixbuf *icon_pixbuf;
GtkWidget *label_widget;
};
@@ -279,56 +278,24 @@ static void
eos_action_button_load_icon (EosActionButton *button)
{
EosActionButtonPrivate *priv;
- GtkIconInfo *icon_info;
- GdkPixbuf *new_icon = NULL;
- gboolean was_symbolic = TRUE;
- GError *error = NULL;
g_return_if_fail (EOS_IS_ACTION_BUTTON (button));
priv = button->priv;
- // TODO maybe use gtk_image_set_from_icon_set
-
if (priv->icon_id != NULL)
{
- icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
- priv->icon_id,
- icon_sizes[priv->size].icon_size,
- GTK_ICON_LOOKUP_FORCE_SIZE
- | GTK_ICON_LOOKUP_GENERIC_FALLBACK
- | GTK_ICON_LOOKUP_USE_BUILTIN );
-
- new_icon = gtk_icon_info_load_symbolic_for_context (icon_info,
- gtk_widget_get_style_context (GTK_WIDGET(button)),
- &was_symbolic,
- &error);
-
- if (!was_symbolic)
- {
- g_warning ("Icon for %s is not symbolic\n", priv->icon_id);
- }
- if (error != NULL)
- {
- g_warning ("Unable to load icon for %s : %s\n", priv->icon_id, error->message);
- g_error_free (error);
- }
- g_object_ref (new_icon);
- g_object_unref (icon_info);
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon_image),
+ priv->icon_id,
+ GTK_ICON_SIZE_BUTTON);
+
+ gtk_image_set_pixel_size (GTK_IMAGE (priv->icon_image),
+ icon_sizes[priv->size].icon_size);
}
else
{
- new_icon = NULL;
+ gtk_image_clear (GTK_IMAGE (priv->icon_image));
}
-
- if (priv->icon_pixbuf != NULL)
- {
- g_object_unref (priv->icon_pixbuf);
- }
-
- priv->icon_pixbuf = new_icon;
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon_image), priv->icon_pixbuf);
}
/**
@@ -595,7 +562,7 @@ eos_action_button_draw (GtkWidget *widget,
GtkAllocation allocation;
GtkStyleContext *context;
GtkStateFlags state;
- gint width, height, border_width, border_height;
+ gint width, border_width, border_height, border_thickness;
GtkBorder margin;
context = gtk_widget_get_style_context (widget);
@@ -615,28 +582,33 @@ eos_action_button_draw (GtkWidget *widget,
x = 0;
y = 0;
width = allocation.width;
- height = allocation.height;
border_width = icon_sizes[priv->size].width;
border_height = icon_sizes[priv->size].height;
+ border_thickness = icon_sizes[priv->size].border_width;
cairo_save (cr);
gtk_render_frame (context, cr,
x + (width - border_width)/2,
- margin.top,
+ y + margin.top,
border_width, border_height);
- if (gtk_widget_has_visible_focus (widget))
- {
- gtk_render_focus (context, cr,
- x, y, width, height);
- }
-
// TODO is it really needed to restore and save the cairo_t here?
cairo_restore (cr);
cairo_save (cr);
+ // GTK+ tries to paint the background inside the border, we work around this
+ //because we want to draw the inset shadow over the border itself
+ gtk_render_background (context, cr,
+ x + (width - border_width)/2 - border_thickness,
+ y + margin.top - border_thickness,
+ border_width + 2*border_thickness,
+ border_height + 2*border_thickness);
+
+ cairo_restore (cr);
+ cairo_save (cr);
+
// *** image
gtk_widget_get_allocation (priv->icon_image, &allocation);
diff --git a/endless/eosapplication.c b/endless/eosapplication.c
index df7a15e..71ce190 100644
--- a/endless/eosapplication.c
+++ b/endless/eosapplication.c
@@ -7,6 +7,8 @@
#include "eoswindow.h"
+#define CSS_THEME_URI "resource:///com/endlessm/sdk/css/endless-widgets.css"
+
/**
* SECTION:application
* @short_description: Start here with your application
@@ -75,6 +77,28 @@ eos_application_activate (GApplication *application)
}
static void
+eos_application_startup (GApplication *application)
+{
+ G_APPLICATION_CLASS (eos_application_parent_class)->startup (application);
+
+ GtkCssProvider *provider = gtk_css_provider_new ();
+
+ /* Reset CSS for SDK applications and apply our own theme on top of it. This
+ is so that we do not interfere with existing, complicated Adwaita theming.
+ */
+ GFile *css_file = g_file_new_for_uri (CSS_THEME_URI);
+ gtk_css_provider_load_from_file (provider, css_file, NULL);
+ g_object_unref (css_file);
+
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
+ g_debug ("Initialized theme\n");
+
+ g_object_unref (provider);
+}
+
+static void
eos_application_window_added (GtkApplication *application,
GtkWindow *window)
{
@@ -130,6 +154,7 @@ eos_application_class_init (EosApplicationClass *klass)
g_type_class_add_private (klass, sizeof (EosApplicationPrivate));
g_application_class->activate = eos_application_activate;
+ g_application_class->startup = eos_application_startup;
gtk_application_class->window_added = eos_application_window_added;
gtk_application_class->window_removed = eos_application_window_removed;
}