32 #include <gtkmm/stylecontext.h> 33 #include <boost/filesystem.hpp> 36 using Gtk::IconFactory;
43 namespace fsys = boost::filesystem;
63 , styleAdviceTrackBody_{
"style(trackBody)"}
64 , styleAdviceTrackRuler_{
"style(trackRuler)"}
66 Glib::set_application_name (
Config::get (KEY_TITLE));
68 registerAppIconSizes();
79 auto screen = Gdk::Screen::get_default();
80 auto css_provider = Gtk::CssProvider::create();
87 catch(Glib::Error
const& failure)
89 WARN (
stage,
"Failure while loading stylesheet '%s': %s",
cStr(stylesheetName),
cStr(failure.what()));
92 Gtk::StyleContext::add_provider_for_screen (screen, css_provider,
93 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
120 if (styleAdviceTrackBody_.isGiven())
return;
122 Gtk::WidgetPath path = timeline.getBodyWidgetPath();
123 GType scopeNode = Gtk::Box::get_type();
124 int pos = path.path_append_type (scopeNode);
126 gtk_widget_path_iter_set_object_name (path.gobj(), pos, NODE_fork);
127 path.iter_add_class(pos, CLASS_timeline_fork);
129 for (
int i=0; i<pos; ++i)
130 gtk_widget_path_iter_set_state(path.gobj(), i, GTK_STATE_FLAG_NORMAL);
131 PStyleContext style = Gtk::StyleContext::create();
132 style->set_screen(Gdk::Screen::get_default());
133 style->set_path (path);
134 styleAdviceTrackBody_.setAdvice (style);
136 pos = path.path_append_type (scopeNode);
137 gtk_widget_path_iter_set_object_name (path.gobj(), pos, NODE_frame);
139 path.iter_add_class(pos, CLASS_timeline_ruler);
140 style = Gtk::StyleContext::create();
141 style->set_path (path);
142 styleAdviceTrackRuler_.setAdvice (style);
148 Cairo::RefPtr<Cairo::SolidPattern>
150 ,
const gchar * property_name
151 ,guint16 red, guint16 green, guint16 blue)
153 REQUIRE (property_name);
158 gtk_widget_style_get(widget.gobj(), property_name, &color, NULL);
160 Cairo::RefPtr<Cairo::SolidPattern> pattern;
164 pattern = Cairo::SolidPattern::create_rgb ( (
double)color->red / 0xFFFF,
165 (
double)color->green / 0xFFFF,
166 (
double)color->blue / 0xFFFF);
170 WARN (
stage,
"%s style value failed to load", property_name);
172 pattern = Cairo::SolidPattern::create_rgb ( red, green, blue );
180 UiStyle::registerAppIconSizes()
196 Glib::RefPtr<IconFactory> factory = Gtk::IconFactory::create();
198 addStockIconSet(factory,
"panel-assets",
"panel_assets", _(
"_Assets"));
199 addStockIconSet(factory,
"panel-viewer",
"panel_viewer", _(
"_Viewer"));
200 addStockIconSet(factory,
"panel-infobox",
"panel_infobox", _(
"_InfoBox"));
201 addStockIconSet(factory,
"panel-timeline",
"panel_timeline",_(
"_Timeline"));
202 addStockIconSet(factory,
"panel-timeline",
"panel_timeline_obsolete",_(
"_ZombieTimeline"));
204 addStockIconSet(factory,
"window-new" ,
"new_window" ,_(
"New _Window"));
206 addStockIconSet(factory,
"placement" ,ICON_placement ,_(
"_Placement"));
207 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_menu ,_(
"_Menu"));
208 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_down ,_(
"_Expand"));
209 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_up ,_(
"_Collapse"));
214 addStockIconSet(factory,
"track-disabled",
"track_disabled",_(
"Track Disabled"));
215 addStockIconSet(factory,
"track-enabled",
"track_enabled", _(
"Track Enabled"));
216 addStockIconSet(factory,
"track-locked",
"track_locked", _(
"Track Locked"));
217 addStockIconSet(factory,
"track-unlocked",
"track_unlocked",_(
"Track Unlocked"));
219 factory->add_default();
229 Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
230 cuString uIconName{iconName}, uLabel{label};
236 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_BUTTON, not found);
237 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_MENU, not found);
238 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_LARGE_TOOLBAR, not found);
244 ERROR (
stage,
"Unable to load icon '%s'", iconName);
249 const Gtk::StockID stock_id(
id);
250 factory->add(stock_id, icon_set);
251 Gtk::Stock::add(Gtk::StockItem(stock_id, uLabel));
268 while (iconLocations)
270 ,iconLocations.next()
287 int width = 0, height = 0;
288 if(!IconSize::lookup(size, width, height))
293 Glib::RefPtr<Gtk::IconTheme> theme = Gtk::IconTheme::get_default();
297 Gtk::IconInfo info = theme->lookup_icon(icon_name, width, (Gtk::IconLookupFlags)0);
299 if (!info)
return false;
301 cuString path(info.get_filename());
314 int width = 0, height = 0;
315 if(!IconSize::lookup(size, width, height))
320 cuString path(Glib::ustring::compose(
"%1/%2x%3/%4.png",
321 base_dir, width, height, icon_name));
328 ,Glib::RefPtr<Gtk::IconSet>
const& icon_set
332 if (!fsys::exists (path))
return false;
335 Gtk::IconSource source;
336 source.set_pixbuf(Gdk::Pixbuf::create_from_file(path));
337 source.set_size_wildcarded(wildcard);
338 source.set_size(size);
340 icon_set->add_source(source);
345 catch(Glib::Exception
const& ex)
347 WARN (
stage,
"Failure when accessing icon '%s'. Problem: %s",
cStr(path),
cStr(ex.what()));
Definition of access keys for global UI configuration.
Service for global theming and style related concerns.
Helpers to handle directory search paths.
bool addStockIcon(Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &icon_name, Gtk::IconSize size, bool wildcard)
Loads an icon, searching standard icon locations, and adds it to an icon set.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
bool addStockIconFromPath(string path, Glib::RefPtr< Gtk::IconSet > const &icon_set, Gtk::IconSize size, bool wildcard)
Loads an icon from a specific path and adds it to an icon set.
inline string literal This is a marker type to indicate that
UiStyle()
Set up a coherent theming and styling for the application.
void prepareStyleContext(timeline::TimelineWidget const &)
Use the existing TimelineWidget's GTK-WidgetPath to establish a systematic CSS styling context...
bool addStockIconSet(Glib::RefPtr< Gtk::IconFactory > const &factory, Literal iconName, Literal id, Literal label)
Adds an icon (in different sizes) to the icon factory.
static Gtk::IconSize GiantIconSize
The registered icon size for giant 48x48 px icons.
static string get(lib::Literal key)
bool addNonThemeIconSource(Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &base_dir, cuString &icon_name, Gtk::IconSize size, bool wildcard)
Loads an icon from a non theme set.
void registerStockItems()
Registers application stock items: icons and labels associated with IDs.
static Gtk::IconSize MenuIconSize
The registered icon size for giant 16x16 px icons.
Lumiera GTK UI implementation root.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
bool addThemeIconSource(Glib::RefPtr< Gtk::IconSet > const &icon_set, cuString &icon_name, Gtk::IconSize size, bool wildcard)
Loads an icon from a the icon theme.
void setTheme(string const &stylesheetName)
Sets the theme to use for the Lumiera GUI.
static Cairo::RefPtr< Cairo::SolidPattern > readStyleColourProperty(Gtk::Widget &widget, const gchar *property_name, guint16 red, guint16 green, guint16 blue)
A utility function which reads a colour style from the GTK Style.
Helper: Access a path Specification as a sequence of filesystem Paths.
Definition of access keys for uniform UI styling.
string resolveModulePath(fsys::path moduleName, string searchPath)
helper to establish the location to search for loadable modules, configuration files, icons and further resources.