Added an icon to the viewer panel

This commit is contained in:
Joel Holdsworth 2008-05-15 00:04:10 +01:00
parent 1d89341fa4
commit 41d5ff9610
6 changed files with 78 additions and 7 deletions

View file

@ -70,7 +70,13 @@ lumigui_SOURCES = \
lumigui_LDFLAGS =
lumigui_LDADD = $(GTK_LUMIERA_LIBS)
lumigui_DEPENDENCIES = $(top_builddir)/lumiera_ui.rc
lumigui_DEPENDENCIES = \
$(top_builddir)/lumiera_ui.rc \
$(top_builddir)/viewer-panel.png
$(top_builddir)/lumiera_ui.rc:
cp $(lumigui_srcdir)/lumiera_ui.rc $(top_builddir)
$(top_builddir)/viewer-panel.png:
cp $(top_srcdir)/icons/viewer-panel.png $(top_builddir)

View file

@ -29,8 +29,14 @@ namespace panels {
Panel::Panel(const gchar *name, const gchar *long_name, GdlDockItemBehavior behavior)
{
dock_item = (GdlDockItem*)gdl_dock_item_new (name, long_name, behavior);
gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj());
gtk_widget_show ((GtkWidget*)dock_item);
internal_setup();
}
Panel::Panel(const gchar *name, const gchar *long_name, const gchar *stock_id,
GdlDockItemBehavior behavior)
{
dock_item = (GdlDockItem*)gdl_dock_item_new_with_stock (name, long_name, stock_id, behavior);
internal_setup();
}
Panel::~Panel()
@ -43,6 +49,12 @@ GdlDockItem* Panel::get_dock_item() const
return dock_item;
}
void Panel::internal_setup()
{
gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj());
gtk_widget_show ((GtkWidget*)dock_item);
}
} // namespace panels
} // namespace gui
} // namespace lumiera

View file

@ -40,13 +40,22 @@ namespace panels {
class Panel : public Gtk::VBox
{
protected:
Panel(const gchar *name, const gchar *long_name,
GdlDockItemBehavior behavior = GDL_DOCK_ITEM_BEH_NORMAL);
Panel(const gchar *name, const gchar *long_name, const gchar *stock_id,
GdlDockItemBehavior behavior = GDL_DOCK_ITEM_BEH_NORMAL);
~Panel();
public:
GdlDockItem* get_dock_item() const;
private:
/**
* The internal constructor for this class, whose purpose
* is to set up the internal container widgets.
*/
void internal_setup();
protected:
GdlDockItem* dock_item;

View file

@ -30,7 +30,7 @@ namespace gui {
namespace panels {
ViewerPanel::ViewerPanel() :
Panel("viewer", "Viewer"),
Panel("viewer", "Viewer", "viewer_panel"),
previousButton(Stock::MEDIA_PREVIOUS),
rewindButton(Stock::MEDIA_REWIND),
playPauseButton(Stock::MEDIA_PLAY),

View file

@ -38,6 +38,8 @@ namespace workspace {
Actions::Actions(WorkspaceWindow &workspace_window) :
workspaceWindow(workspace_window)
{
register_stock_items();
actionGroup = ActionGroup::create();
// File menu
@ -63,7 +65,7 @@ namespace workspace {
// View Menu
actionGroup->add(Action::create("ViewMenu", _("_View")));
actionGroup->add(Action::create("ViewViewer", _("_Viewer")),
actionGroup->add(Action::create("ViewViewer", Gtk::StockID("viewer_panel")),
sigc::mem_fun(*this, &Actions::on_menu_view_viewer));
actionGroup->add(Action::create("ViewTimeline", _("_Timeline")),
sigc::mem_fun(*this, &Actions::on_menu_view_timeline));
@ -74,6 +76,41 @@ namespace workspace {
sigc::mem_fun(*this, &Actions::on_menu_help_about) );
}
void
Actions::register_stock_items()
{
RefPtr<IconFactory> factory = IconFactory::create();
add_stock_item(factory, "viewer-panel.png", "viewer_panel", _("_Viewer"));
factory->add_default(); //Add factory to list of factories.
}
void
Actions::add_stock_item(const Glib::RefPtr<IconFactory>& factory,
const Glib::ustring& filepath,
const Glib::ustring& id, const Glib::ustring& label)
{
Gtk::IconSource source;
try
{
//This throws an exception if the file is not found:
source.set_pixbuf( Gdk::Pixbuf::create_from_file(filepath) );
}
catch(const Glib::Exception& ex)
{
g_message(ex.what().c_str());
}
source.set_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
source.set_size_wildcarded(); //Icon may be scaled.
Gtk::IconSet icon_set;
icon_set.add_source(source); //More than one source per set is allowed.
const Gtk::StockID stock_id(id);
factory->add(stock_id, icon_set);
Gtk::Stock::add(Gtk::StockItem(stock_id, label));
}
/* ===== File Menu Event Handlers ===== */
void

View file

@ -46,12 +46,19 @@ class WorkspaceWindow;
private:
Actions(WorkspaceWindow &workspace_window);
void register_stock_items();
void add_stock_item(const Glib::RefPtr<Gtk::IconFactory>& factory,
const Glib::ustring& filepath,
const Glib::ustring& id, const Glib::ustring& label);
/**
* A reference to the MainWindow which owns
* this helper */
* A reference to the MainWindow which owns
* this helper */
WorkspaceWindow &workspaceWindow;
/* ===== Event Handlers ===== */
private:
void on_menu_file_new_project();
void on_menu_file_open_project();
void on_menu_file_render();