41 #include <gtkmm/stylecontext.h> 42 #include <boost/filesystem.hpp> 45 using Gtk::IconFactory;
52 namespace fsys = boost::filesystem;
72 , styleAdviceTrackBody_{
"style(trackBody)"}
73 , styleAdviceTrackRuler_{
"style(trackRuler)"}
75 Glib::set_application_name (
Config::get (KEY_TITLE));
77 registerAppIconSizes();
88 auto screen = Gdk::Screen::get_default();
89 auto css_provider = Gtk::CssProvider::create();
96 catch(Glib::Error
const& failure)
98 WARN (
stage,
"Failure while loading stylesheet '%s': %s",
cStr(stylesheetName),
cStr(failure.what()));
101 Gtk::StyleContext::add_provider_for_screen (screen, css_provider,
102 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
129 if (styleAdviceTrackBody_.isGiven())
return;
131 Gtk::WidgetPath path = timeline.getBodyWidgetPath();
132 GType scopeNode = Gtk::Box::get_type();
133 int pos = path.path_append_type (scopeNode);
135 gtk_widget_path_iter_set_object_name (path.gobj(), pos, NODE_fork);
136 path.iter_add_class(pos, CLASS_timeline_fork);
138 for (
int i=0; i<pos; ++i)
139 gtk_widget_path_iter_set_state(path.gobj(), i, GTK_STATE_FLAG_NORMAL);
140 PStyleContext style = Gtk::StyleContext::create();
141 style->set_screen(Gdk::Screen::get_default());
142 style->set_path (path);
143 styleAdviceTrackBody_.setAdvice (style);
145 pos = path.path_append_type (scopeNode);
146 gtk_widget_path_iter_set_object_name (path.gobj(), pos, NODE_frame);
148 path.iter_add_class(pos, CLASS_timeline_ruler);
149 style = Gtk::StyleContext::create();
150 style->set_path (path);
151 styleAdviceTrackRuler_.setAdvice (style);
157 Cairo::RefPtr<Cairo::SolidPattern>
159 ,
const gchar * property_name
160 ,guint16 red, guint16 green, guint16 blue)
162 REQUIRE (property_name);
167 gtk_widget_style_get(widget.gobj(), property_name, &color, NULL);
169 Cairo::RefPtr<Cairo::SolidPattern> pattern;
173 pattern = Cairo::SolidPattern::create_rgb ( (
double)color->red / 0xFFFF,
174 (
double)color->green / 0xFFFF,
175 (
double)color->blue / 0xFFFF);
179 WARN (
stage,
"%s style value failed to load", property_name);
181 pattern = Cairo::SolidPattern::create_rgb ( red, green, blue );
189 UiStyle::registerAppIconSizes()
205 Glib::RefPtr<IconFactory> factory = Gtk::IconFactory::create();
207 addStockIconSet(factory,
"panel-assets",
"panel_assets", _(
"_Assets"));
208 addStockIconSet(factory,
"panel-viewer",
"panel_viewer", _(
"_Viewer"));
209 addStockIconSet(factory,
"panel-infobox",
"panel_infobox", _(
"_InfoBox"));
210 addStockIconSet(factory,
"panel-timeline",
"panel_timeline",_(
"_Timeline"));
211 addStockIconSet(factory,
"panel-timeline",
"panel_timeline_obsolete",_(
"_ZombieTimeline"));
213 addStockIconSet(factory,
"window-new" ,
"new_window" ,_(
"New _Window"));
215 addStockIconSet(factory,
"placement" ,ICON_placement ,_(
"_Placement"));
216 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_menu ,_(
"_Menu"));
217 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_down ,_(
"_Expand"));
218 addStockIconSet(factory,
"arrow-hand" ,ICON_arrow_hand_up ,_(
"_Collapse"));
223 addStockIconSet(factory,
"track-disabled",
"track_disabled",_(
"Track Disabled"));
224 addStockIconSet(factory,
"track-enabled",
"track_enabled", _(
"Track Enabled"));
225 addStockIconSet(factory,
"track-locked",
"track_locked", _(
"Track Locked"));
226 addStockIconSet(factory,
"track-unlocked",
"track_unlocked",_(
"Track Unlocked"));
228 factory->add_default();
238 Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
239 cuString uIconName{iconName}, uLabel{label};
245 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_BUTTON, not found);
246 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_MENU, not found);
247 found |=
addStockIcon (icon_set, uIconName, Gtk::ICON_SIZE_LARGE_TOOLBAR, not found);
253 ERROR (
stage,
"Unable to load icon '%s'", iconName);
258 const Gtk::StockID stock_id(
id);
259 factory->add(stock_id, icon_set);
260 Gtk::Stock::add(Gtk::StockItem(stock_id, uLabel));
277 while (iconLocations)
279 ,iconLocations.next()
296 int width = 0, height = 0;
297 if(!IconSize::lookup(size, width, height))
302 Glib::RefPtr<Gtk::IconTheme> theme = Gtk::IconTheme::get_default();
306 Gtk::IconInfo info = theme->lookup_icon(icon_name, width, (Gtk::IconLookupFlags)0);
308 if (!info)
return false;
310 cuString path(info.get_filename());
323 int width = 0, height = 0;
324 if(!IconSize::lookup(size, width, height))
329 cuString path(Glib::ustring::compose(
"%1/%2x%3/%4.png",
330 base_dir, width, height, icon_name));
337 ,Glib::RefPtr<Gtk::IconSet>
const& icon_set
341 if (!fsys::exists (path))
return false;
344 Gtk::IconSource source;
345 source.set_pixbuf(Gdk::Pixbuf::create_from_file(path));
346 source.set_size_wildcarded(wildcard);
347 source.set_size(size);
349 icon_set->add_source(source);
354 catch(Glib::Exception
const& ex)
356 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.