void PhotoPrintOperation::CalcLayout(Glib::RefPtr<Gtk::PageSetup> PageSetup) {
	PaperArea.X=0;
	PaperArea.Y=0;
	PaperArea.Width=PageSetup->get_paper_width(Gtk::UNIT_POINTS)*CairoScale;
	PaperArea.Height=PageSetup->get_paper_height(Gtk::UNIT_POINTS)*CairoScale;

	PrintArea.X=std::max(
			PageSetup->get_left_margin(Gtk::UNIT_POINTS)*CairoScale,
			PageSetup->get_right_margin(Gtk::UNIT_POINTS)*CairoScale);
	PrintArea.Width=PaperArea.Width-2*PrintArea.X;

	PrintArea.Y=std::max(
		PageSetup->get_top_margin(Gtk::UNIT_POINTS)*CairoScale,
		PageSetup->get_bottom_margin(Gtk::UNIT_POINTS)*CairoScale);
	PrintArea.Height=PaperArea.Height-2*PrintArea.Y;

	LabelArea.X=LabelArea.Y=LabelArea.Width=LabelArea.Height=0;
	if (Label) {
		LabelArea.Width=Label->get_width();
		LabelArea.Height=Label->get_height();
		LabelArea.X=PaperArea.Width-PrintArea.X-LabelArea.Width;
		LabelArea.Y=PrintArea.Y;
	}

	float Padding=PhotoPadding*std::max(PrintArea.Width,PrintArea.Height);

	PhotosArea.X=PrintArea.X;
	PhotosArea.Y=PrintArea.Y;
	PhotosArea.Width=PrintArea.Width-LabelArea.Width;
	if (Label)
		PhotosArea.Width-=Padding;
	PhotosArea.Height=PrintArea.Height;

	float Width=(PhotosArea.Width-Padding)/2.0;
	float Height=(PhotosArea.Height-Padding)/2.0;
	for (int Row=0; Row<2; Row++) {
		for (int Col=0; Col<2; Col++) {
			PhotoArea[Col+Row*2].X=PhotosArea.X+Col*(Width+Padding);
			PhotoArea[Col+Row*2].Y=PhotosArea.Y+Row*(Height+Padding);
			PhotoArea[Col+Row*2].Width=Width;
			PhotoArea[Col+Row*2].Height=Height;
		}
	}
}
示例#2
0
void window_main::file_drag_data_received(
	const Glib::RefPtr<Gdk::DragContext> & context, //info about drag (available on source and dest)
	const int x,                                    //x-coord of drop
	const int y,                                    //y-coord of drop
	const Gtk::SelectionData & selection_data,      //data dropped
	const guint info,                               //type of info dropped
	const guint time)                               //time stamp of when drop happened
{
//DEBUG, dragging file on to window does not work on windows, not sure why

	if(selection_data.get_length() >= 0 && selection_data.get_format() == 8){
		//this will look like file:///home/foo/bar.txt
		std::string URI = selection_data.get_data_as_string();
		if(URI.size() > 7){
			std::string path = URI.substr(7);
			//get rid of newline on the end
			boost::trim(path);
			p2p::load_file(path);
		}
	}

	//tell other end we're done with drag and drop so it can free resources
	context->drag_finish(true, true, time);
}
示例#3
0
bool ModuleModel::onItemButtonPressEvent(const Glib::RefPtr<Goocanvas::Item>& item, 
                    GdkEventButton* event)
{
    if(bNested)
        return true;

    if(item && Glib::RefPtr<InternalPortModel>::cast_dynamic(item->get_model()))
        return Glib::RefPtr<InternalPortModel>::cast_dynamic(item->get_model())->onItemButtonPressEvent(item, event);
    
    if(event->type == GDK_2BUTTON_PRESS)
    {
       parentWindow->onUpdateModuleProperty(module);
       return true;
    }
    
    if(event->button == 1)
    {
        _dragging = item ;
        _drag_x = (int) event->x ;
        _drag_y = (int) event->y ;
        return false;
    }
    else
    if(event->button == 3)
    {
        MainWindow* wnd = parentWindow->getMainWindow();
        wnd->m_refActionGroup->get_action("EditDelete")->set_sensitive(selected);
        wnd->m_refActionGroup->get_action("EditCopy")->set_sensitive(selected);
        Gtk::Menu* pMenu = dynamic_cast<Gtk::Menu*>(
        wnd->m_refUIManager->get_widget("/PopupModuleModel"));
        if(pMenu)
            pMenu->popup(event->button, event->time);
    }

    return true;
}
示例#4
0
  void BugzillaNoteAddin::drop_uri_list(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, 
                                        const Gtk::SelectionData & selection_data, guint time)
  {
    std::string uriString = selection_data.get_text();
    if(uriString.empty()) {
      return;
    }

    const char * regexString = "\\bhttps?://.*/show_bug\\.cgi\\?(\\S+\\&){0,1}id=(\\d{1,})";

    pcrecpp::RE re(regexString, pcrecpp::RE_Options(PCRE_CASELESS|PCRE_UTF8));
    int m;

    if(re.FullMatch(uriString, (void*)NULL, &m)) {

      int bugId = m;

      if (insert_bug (x, y, uriString, bugId)) {
        context->drag_finish(true, false, time);
        g_signal_stop_emission_by_name(get_window()->editor()->gobj(),
                                       "drag_data_received");
      }
    }
  }
  ImageEditorFE(grt::Module *m, bec::GRTManager *grtm, const grt::BaseListRef &args)
    : PluginEditorBase(m, grtm, args)
    , _be(grtm, workbench_model_ImageFigureRef::cast_from(args[0]))
    , _xml(0)
    , _image(0)
  {
    set_border_width(8);
    
    _xml= Gtk::Builder::create_from_file(grtm->get_data_file_path("modules/data/editor_image.glade"));

    Gtk::Widget *widget;
    _xml->get_widget("editor_image_hbox", widget);

    Gtk::Button *button(0);
    _xml->get_widget("browse_button", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ImageEditorFE::browse_file));

    _xml->get_widget("reset_size_button", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ImageEditorFE::reset_aspect));

    Gtk::CheckButton *check;
    _xml->get_widget("aspect_check", check);
    check->signal_toggled().connect(sigc::mem_fun(this, &ImageEditorFE::aspect_toggled));
    
    Gtk::Entry *entry;
    _xml->get_widget("width_entry", entry);
    entry->signal_activate().connect(sigc::mem_fun(this, &ImageEditorFE::width_changed));
    _xml->get_widget("height_entry", entry);
    entry->signal_activate().connect(sigc::mem_fun(this, &ImageEditorFE::height_changed));

    _xml->get_widget("image", _image);
    
    widget->reparent(*this);

    show_all();
    
    refresh_form_data();
  }
示例#6
0
//TODO: klasse soll window extenden (schoener so)
EwAccountsWin::EwAccountsWin() {
	EWLOG("In EwAccountsWin::EwAccountsWin()", 8);
	Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("data/EwAccountsWin.glade");
	Gtk::Button *add, *del, *close;
	Gtk::ScrolledWindow *scrolledwindow;
	builder->get_widget("EwAccounts", window);
	builder->get_widget("add", add);
	builder->get_widget("delete", del);
	builder->get_widget("close", close);
	builder->get_widget("scrolledwindow", scrolledwindow);
	scrolledwindow->add(treeView);
	add->signal_clicked().connect(sigc::mem_fun(this, &EwAccountsWin::onAddBtnClicked));
	del->signal_clicked().connect(sigc::mem_fun(this, &EwAccountsWin::onDelBtnClicked));
	close->signal_clicked().connect(sigc::mem_fun(this, &EwAccountsWin::onCloseBtnClicked));

	liststore = Gtk::ListStore::create(m_Columns);
	treeView.set_model(liststore);
	treeView.append_column("Enabled", m_Columns.m_col_enab);
	treeView.append_column_editable("Identifier", m_Columns.m_col_identifier);
	treeView.append_column("Use Https", m_Columns.m_col_https);
	Gtk::CellRendererText *crtu;
	Gtk::CellRendererToggle *crtenab, *crthttps;
	crtenab = dynamic_cast<Gtk::CellRendererToggle*>(treeView.get_column_cell_renderer(0));
	crtenab->set_activatable();
	crtenab->signal_toggled().connect(sigc::mem_fun(this, &EwAccountsWin::onColumnEnabledToggled));
	crtu = dynamic_cast<Gtk::CellRendererText*>(treeView.get_column_cell_renderer(1));
	crtu->signal_edited().connect(sigc::mem_fun(this, &EwAccountsWin::onColumnIdentifierChanged));
	crthttps = dynamic_cast<Gtk::CellRendererToggle*>(treeView.get_column_cell_renderer(2));
	crthttps->set_activatable();
	crthttps->signal_toggled().connect(sigc::mem_fun(this, &EwAccountsWin::onColumnHttpsToggled));

	std::list<EwAccountList::EwAccount> accounts = EwAccountList::Instance()->getAccounts();
	for (std::list<EwAccountList::EwAccount>::iterator iter = accounts.begin(); iter != accounts.end(); iter++) {
		Gtk::TreeModel::Row row = *(liststore->append());
		row[m_Columns.m_col_id] = (*iter).id;
		row[m_Columns.m_col_identifier] = (*iter).identifier;
		row[m_Columns.m_col_enab] = (*iter).enabled;
		row[m_Columns.m_col_https] = (*iter).https;
	}
	
	window->show_all_children();
	Gtk::Main::run(*window);
}
示例#7
0
void PropertiesDialog::update(const Glib::RefPtr<Gio::File>& file,
                              const Glib::RefPtr<Gio::FileInfo>& info,
                              const Size& dimensions,
                              unsigned int image_count) {
  name->set_label(info->get_display_name());
  width->set_label(Glib::ustring::compose(
      ngettext("%1 pixel", "%1 pixels", dimensions.width), dimensions.width));
  height->set_label(Glib::ustring::compose(
      ngettext("%1 pixel", "%1 pixels", dimensions.height), dimensions.height));
  type->set_label(Gio::content_type_get_description(info->get_content_type()));
  size->set_label(format_size(info->get_size(), G_FORMAT_SIZE_LONG_FORMAT));
  modified->set_label(Glib::DateTime::create_now_local(
      info->modification_time()).format("%c"));
  location_button->set_uri(file->get_uri());
  location->set_label(Glib::filename_display_name(
      file->get_parent()->get_path()));
  contents->set_label(Glib::ustring::compose(
      ngettext("%1 image", "%1 images", image_count), image_count));
}
示例#8
0
void YarpScope::MainWindow::Private::on_action_actions_stop_start()
{
    Glib::RefPtr<Gtk::Action> stopStartAction = refActionGroup->get_action("StopStart");
    if(!stopStartAction) {
        fatal() << "Action \"StopStart\" is missing.";
    }

    if (running) {
        debug() << "Stop clicked";
        stopStartAction->set_icon_name("media-playback-start");
        stopStartAction->set_label(_("Start"));
        stopStartAction->set_tooltip(_("Start plotting"));
    } else {
        debug() << "Start clicked";
        stopStartAction->set_icon_name("media-playback-pause");
        stopStartAction->set_label(_("Stop"));
        stopStartAction->set_tooltip(_("Stop plotting"));
    }

    running = !running;

    PortReader::instance().toggleAcquire(running);
}
示例#9
0
文件: VRGuiNet.cpp 项目: uagmw/polyvr
void VRGuiNet_updateList() {
    auto scene = VRSceneManager::getCurrent();
    if (scene == 0) return;

    // update script list
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("Sockets"));
    store->clear();

    map<string, VRSocket*> sockets = scene->getSockets();
    map<string, VRSocket*>::iterator itr;
    for (itr = sockets.begin(); itr != sockets.end(); itr++) {
        Gtk::ListStore::Row row = *store->append();
        VRSocket* socket = itr->second;
        gtk_list_store_set(store->gobj(), row.gobj(), 0, socket->getType().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 1, socket->getPort(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 2, socket->getIP().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 3, socket->getCallback().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 4, socket->getSignal()->getName().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 5, socket->getName().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 6, socket, -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 7, socket->isClient(), -1);
    }
}
示例#10
0
// printing system not complete yet	
 void AppWindow::print(Gtk::PrintOperationAction print_action)
	{

	
	Glib::RefPtr<CPrintOperation> refprint = CPrintOperation::create( 
		ImageManager.get_current_file(),
		ImageManager.get_file_list(),
		refPageSetup,
		refPrintSettings );
	
	refprint->set_track_print_status();

#ifdef DEBUG
std::cout << "APPWINDOW::PRINT: refPageSetup " << refPageSetup << std::endl;
std::cout << "APPWINDOW::PRINT: refPrintSettings " << refPrintSettings << std::endl;
#endif // DEBUG	
	
	refprint->set_default_page_setup( refPageSetup );
	refprint->set_print_settings( refPrintSettings );
	
#ifdef DEBUG
std::cout << "APPWINDOW::PRINT: refPageSetup " << refPageSetup << std::endl;
std::cout << "APPWINDOW::PRINT: refPrintSettings " << refPrintSettings << std::endl;
#endif // DEBUG		
			
	//connect to print done
	refprint->signal_done().connect(sigc::bind(sigc::mem_fun(*this, &AppWindow::on_print_done), &refprint));
	
	try
		{
		refprint->run(print_action, *this);
// TEST
		std::cout << refPageSetup->get_paper_size().get_name() << std::endl;
		std::cout << refPageSetup->get_page_width(Gtk::UNIT_MM) << std::endl;
		std::cout << refPrintSettings->get_printer() << std::endl;
// TEST
		}
	catch(const Gtk::PrintError& error)
		{
		std::cerr << "An error occured while trying to run print(): " << error.what() << std::endl; 
		}
	}
示例#11
0
void display_template_info(const Glib::RefPtr<Gst::PadTemplate> &tpl,
                           const Glib::RefPtr<Gtk::TreeStore> &model, const Gtk::TreeModelColumn<Glib::ustring> &col_name,
                           const Gtk::TreeModelColumn<Glib::ustring> &col_value, boost::optional<const Gtk::TreeModel::Row&> parent_row)
{
    Gtk::TreeRow row;
    if (parent_row)
    {
        row = APPEND_SUB_ROW(_("Template"), tpl->get_name_template(), parent_row.get());
    }
    else
    {
        row = *(model->append());
        row[col_name] = _("Template");
        row[col_value] = tpl->get_name_template();
    }
    APPEND_SUB_ROW(_("Presence"), get_presence_str(tpl->get_presence()), row);
    APPEND_SUB_ROW(_("Direction"), get_direction_str(tpl->get_direction()), row);
    row = APPEND_SUB_ROW("Caps", "", row);
    display_caps(tpl->get_caps(), model, col_name, col_value, row);
}
示例#12
0
bool
StateBrush_Context::scan_directory(const String &path, int scan_sub_levels, std::set<String> &out_files)
{
	if (scan_sub_levels < 0) return false;
	Glib::RefPtr<Gio::File> directory = Gio::File::create_for_path(path);
	Glib::RefPtr<Gio::FileEnumerator> e;

	try
	{
		e = directory->enumerate_children();
	}
	catch(Gio::Error&) { return false; }
	catch(Glib::FileError&) { return false; }

	Glib::RefPtr<Gio::FileInfo> info;
	while((bool)(info = e->next_file()))
	{
		String filepath = FileSystem::fix_slashes(directory->get_child(info->get_name())->get_path());
		if (!scan_directory(filepath, scan_sub_levels-1, out_files))
			out_files.insert(filepath);
	}

	return true;
}
示例#13
0
bool PreviewHolder::on_scroll_event(GdkEventScroll *event)
{
    // Scroll horizontally by page on mouse wheel
#if WITH_GTKMM_3_0
    Glib::RefPtr<Gtk::Adjustment> adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
#else
    Gtk::Adjustment *adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
#endif

    if (!adj) {
        return FALSE;
    }

    int move = (event->direction == GDK_SCROLL_DOWN) ? adj->get_page_size() : -adj->get_page_size();

    double value = std::min(adj->get_upper() - move, adj->get_value() + move );

    adj->set_value(value);

    return FALSE;
}
示例#14
0
ClassificationCell::ClassificationCell()
{
  Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
  
  white = Gdk::Color("white");
  green = Gdk::Color("green");
  lightgreen = Gdk::Color("light green");
  lightred= Gdk::Color("indian red");
  red = Gdk::Color("red");
  black = Gdk::Color("black");

  colormap->alloc_color(lightgreen);
  colormap->alloc_color(white);
  colormap->alloc_color(green);
  colormap->alloc_color(lightred);
  colormap->alloc_color(red);
  colormap->alloc_color(black);
  set_size_request(40, 30);

  value = 0.0;
}
示例#15
0
  NoteEditor::NoteEditor(const Glib::RefPtr<Gtk::TextBuffer> & buffer)
    : Gtk::TextView(buffer)
  {
    set_wrap_mode(Gtk::WRAP_WORD);
    set_left_margin(default_margin());
    set_right_margin(default_margin());
    property_can_default().set_value(true);

    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
    //Set up the schema to watch the default document font
    Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj()
      .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
    if(desktop_settings) {
      desktop_settings->signal_changed().connect(
        sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed));
    }

    // Set Font from preference
    if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
      std::string font_string = settings->get_string(Preferences::CUSTOM_FONT_FACE);
      override_font (Pango::FontDescription(font_string));
    }
    else {
      override_font (get_gnome_document_font_description ());
    }

    settings->signal_changed().connect(sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed));

    // Set extra editor drag targets supported (in addition
    // to the default TextView's various text formats)...
    Glib::RefPtr<Gtk::TargetList> list = drag_dest_get_target_list();

    
    list->add ("text/uri-list", (Gtk::TargetFlags)0, 1);
    list->add ("_NETSCAPE_URL", (Gtk::TargetFlags)0, 1);

    signal_key_press_event().connect(sigc::mem_fun(*this, &NoteEditor::key_pressed), false);
    signal_button_press_event().connect(sigc::mem_fun(*this, &NoteEditor::button_pressed), false);
  }
示例#16
0
文件: avatar.cpp 项目: crynale/gTox
bool avatar::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    Glib::RefPtr<Gtk::StyleContext> style = get_style_context();

    int w = get_allocated_width();
    int h = get_allocated_height();

    auto surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, w * get_scale_factor(), h * get_scale_factor());
    auto tmp_cr = Cairo::Context::create(surface);
    tmp_cr->scale(get_scale_factor(), get_scale_factor());

    // Render image
    Glib::RefPtr<Gdk::Pixbuf> pix = property_pixbuf();
    if (pix) {
        tmp_cr->save();
        double pw = pix->get_width();
        double ph = pix->get_height();
        tmp_cr->scale(w/pw, h/ph);
        Gdk::Cairo::set_source_pixbuf(tmp_cr, pix);
        tmp_cr->paint();
        tmp_cr->restore();
    }

    // Render the background
    tmp_cr->set_operator(Cairo::OPERATOR_DEST_ATOP);
    style->render_background(tmp_cr, 0, 0, w, h);

    // Change to default operator
    tmp_cr->set_operator(Cairo::OPERATOR_OVER);

    // Render frame
    style->render_frame(tmp_cr, 0, 0, w, h);

    // Render to the right surface
    cr->scale(1.0/get_scale_factor(), 1.0/get_scale_factor());
    cr->set_source(surface, 0, 0);
    cr->paint();

    return false;
}
示例#17
0
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
    : Gtk::Dialog(_pstDialog)
{
    refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
    refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
    refBuilder->get_widget("CheatAddButton", m_poCheatAddButton);
    refBuilder->get_widget("CheatRemoveButton", m_poCheatRemoveButton);
    refBuilder->get_widget("CheatRemoveAllButton", m_poCheatRemoveAllButton);
    refBuilder->get_widget("CheatMarkAllButton", m_poCheatMarkAllButton);
    refBuilder->get_widget("CheatTreeView", m_poCheatTreeView);

    // Tree View model
    m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);

    m_poCheatTreeView->set_model(m_poCheatListStore);

    Gtk::CellRendererToggle* pRenderer = Gtk::manage(new Gtk::CellRendererToggle());

    int cols_count = m_poCheatTreeView->append_column("", *pRenderer);

    pRenderer->signal_toggled().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatToggled));

    Gtk::TreeViewColumn* pColumn = m_poCheatTreeView->get_column(cols_count - 1);

    if (pColumn)
        pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);

    m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);

    m_poCheatOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListOpen));
    m_poCheatSaveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListSave));
    m_poCheatAddButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatAdd));
    m_poCheatRemoveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemove));
    m_poCheatRemoveAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemoveAll));
    m_poCheatMarkAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatMarkAll));

    bMark = false;
}
示例#18
0
E3StateWidget::E3StateWidget(const E3Config* _config, const E3State* _state){
	if(_config)
		this->config = new E3Config(*_config);
	else
		this->config = new E3Config();

	if(_state)
		this->state = new E3State(*_state);
	else
		// TODO: may be state should remember its config?!
		this->state = new E3State(this->config);

	this->d_state = new E3State();

	Glib::RefPtr<Gtk::Builder> b = Gtk::Builder::create_from_file(UI_FILE_STATE);

	Gtk::Widget* root;
	b->get_widget("root", root);

	b->get_widget("entry_e", entry_e);
	b->get_widget("entry_phi", entry_phi);
	b->get_widget("entry_a", entry_a);

	b->get_widget("button_apply", button_apply);

	this->add(*root);

	state_to_widget();
	if(!this->state->simulated())
		generateState();

	// signals
	entry_e->signal_changed().connect(sigc::mem_fun(*this, &E3StateWidget::edit_anything_cb));
	entry_phi->signal_changed().connect(sigc::mem_fun(*this, &E3StateWidget::edit_anything_cb));
	entry_a->signal_changed().connect(sigc::mem_fun(*this, &E3StateWidget::edit_anything_cb));

	button_apply->signal_clicked().connect(sigc::mem_fun(*this, &E3StateWidget::on_apply_cb));
}
示例#19
0
void ukwd_wiring_dialog::on_delete_clicked()
{
    Glib::RefPtr<Gtk::ListStore> m;
    Gtk::TreeView *t = NULL;
    ref_xml->get_widget("stecker_treeview" + name_post_fix, t);
    Glib::RefPtr<Gtk::TreeSelection> selection = t->get_selection();
    
    if (selection->count_selected_rows() != 0)
    {
        // A connection is selected
        m = m.cast_dynamic(t->get_model());
        Gtk::TreeModel::iterator iter = selection->get_selected();
  
        // Test is fixed connection is selected for removal  
        if ( (((*iter)[plugboard_cols.first]) != "J") and  (((*iter)[plugboard_cols.second]) != "Y") )
        {
            // No! -> delete the selected connection
            remove_plug((*iter)[plugboard_cols.first], (*iter)[plugboard_cols.second]);
            num_plugs--;
            update_plug_counter();
            m->erase(iter);
        }
        else
        {
            // Yes! -> error message
            Gtk::MessageDialog msg(*dialog, "The connection J, Y is fixed and cannot be removed.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
            msg.set_title("Enigma");
            msg.run();                
        }
    }
    else
    {
        // No connection is selected    
        Gtk::MessageDialog msg(*dialog, "Nothing selected to delete.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        msg.set_title("Enigma");
        msg.run();        
    }
}
示例#20
0
DynamicBox::DynamicBox(const Glib::RefPtr < Gtk::Builder >& xml,
                       GVLE* gvle,
                       vpz::AtomicModel& atom,
                       vpz::Dynamic& dynamic,
                       vpz::Conditions& conditions,
                       vpz::Observables& observables)
    : mXml(xml), mGVLE(gvle), mAtom(atom), mDynamic(dynamic),
    mConditions(conditions), mObservables(observables)
{
    xml->get_widget("DialogDynamic", mDialog);

    {
        xml->get_widget("HBoxDynamicLibrary", mBoxDynamicLibrary);
        mComboLibrary = Gtk::manage(new Gtk::ComboBoxText());
        mComboLibrary->show();

        Glib::RefPtr < Gtk::ListStore > toSortList =
            Glib::RefPtr < Gtk::ListStore >::cast_dynamic(mComboLibrary->get_model());
        toSortList->set_sort_column(0, Gtk::SORT_ASCENDING);

        mBoxDynamicLibrary->pack_start(*mComboLibrary);
    }

    {
        xml->get_widget("HBoxDynamicPackage", mBoxDynamicPackage);
        mComboPackage = Gtk::manage(new Gtk::ComboBoxText());
        mComboPackage->show();
        mBoxDynamicPackage->pack_start(*mComboPackage);
    }

    xml->get_widget("buttonNewDynamicLibrary", mButtonNew);

    mList.push_back(mButtonNew->signal_clicked().connect(
            sigc::mem_fun(*this, &DynamicBox::onNewLibrary)));
    mList.push_back(mComboPackage->signal_changed().connect(
            sigc::mem_fun(*this, &DynamicBox::onComboPackageChange)));
}
示例#21
0
    PredicateDialog::PredicateDialog(Glib::RefPtr < Gtk::Builder >& xml,
        std::vector < std::string > pPredicateName,
    std::map < std::string, std::string > pPredicateFunction,
    hierarchicalPred pPred) :
        mXml(xml),
        mTreePredicateList(0),
        mPredicateName(pPredicateName),
        mPredicateFunction(pPredicateFunction),
        mPred(pPred)
{
    xml->get_widget("PredicateDialog", mDialog);
    xml->get_widget("treeViewPredicate", mTreePredicateList);
    xml->get_widget("PredicateName", mPredicateNameEntry);
    mPredicateNameEntry->set_sensitive(true);
    mPredicateNameEntry->set_editable(false);
    xml->get_widget("PredicateFunction", mTextViewFunction);
    xml->get_widget("FooterPred", mHeaderPred);
    mHeaderPred->set_justify(Gtk::JUSTIFY_LEFT);
    xml->get_widget("HeaderPred", mHeaderPred);

    mPredicateNameEntry->set_text("");
    mHeaderPred->set_text("");
    mTextViewFunction->get_buffer()->set_text("");

    initTreePredicateList();
    fillTreePredicateList();
    initMenuPopupTreePredicateList();

    m_cntTreePredicateListButtonRelease = mTreePredicateList->
            signal_button_release_event().connect(
    sigc::mem_fun( *this, &PredicateDialog::onButtonRealeaseTreePredicateList));
    m_cntTreePredicateCursorChanged = mTreePredicateList->
            signal_cursor_changed().connect(
    sigc::mem_fun( *this, &PredicateDialog::onCursorChangeTreePredicateList));

    setSensitivePredicate(false);
}
示例#22
0
void
StateBrush_Context::BrushConfig::load(const String &filename)
{
	clear();

	char *buffer = NULL;
	{
		Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(filename);
		goffset s = file->query_info()->get_size();
		if (s < 0) return;
		size_t size = s > INT_MAX-1 ? INT_MAX-1 : (size_t)s;
		buffer = new char[size+1];
		memset(buffer, 0, size+1);

		Glib::RefPtr<Gio::FileInputStream> stream = file->read();
		stream->read(buffer, size);
		stream->close();
	}

	const char *pos = buffer;
	if (pos != NULL) while(read_row(&pos)) { }
	free(buffer);
	this->filename = filename;
}
示例#23
0
    void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){
        Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to();


        if(detail){
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);

                const std::string& path = (res_map.getFileFromIdx(i)->get_path());
                const std::string& comment = res_map.getCommentAt(i);

                if(!res_map.getIsNAAt(i)){
                    for (unsigned int j=0; j<res_ref.size();++j){
                        std::stringstream ss;
                        const OneObjectRow& oor = res_ref.getRow(j);
                        ss <<"\""<<path<<"\", "<< oor.print()<<", \""<<comment<<"\""<<std::endl;
                        fout->write(ss.str());
                    }
                }
            }
        }
        else{
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);
                Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i);
                const std::vector<int> roi_keys = res_ref.getROIs();
                const std::string& comment = res_map.getCommentAt(i);

                std::map < unsigned int,std::pair<unsigned int,unsigned int> > table;
                table[0].first = res_ref.getNValid();
                table[0].second =  res_ref.size() - res_ref.getNValid();
                for(unsigned int i=0; i != (unsigned int)res_ref.size(); ++i){
                    OneObjectRow object = res_ref.getRow(i);
                    int roi = object.getROI();
                    if (roi > 0){
                        if(object.getGUIValid() && object.isValid()) //otherwise colour filters etc. don't work
                            ++(table[roi].first);
                        else
                            ++(table[roi].second);
                    }
                }


                for (auto &it : table){
                    int roi = it.first;
                    if ((table.size() == 1) || (roi >= 1)){

                        std::stringstream ss;
                        ss  <<i<<","
                            <<"\""<<tmp_file->get_basename()<<"\""<<","
                            <<roi<<",";

                        if(!res_map.getIsNAAt(i)){
                            ss<<it.second.first<<","
                            <<it.second.second<<",";
                        }
                        else{
                            ss<<"NA,NA,";
                        }
                            ss<<res_ref.getROIClusterData(roi).clusterPop(1)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(2)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(3)<<","
                            <<"\""<<comment<<"\""<<","
                            <<"\""<<tmp_file->get_path()<<"\","
                            <<"\""<<res_ref.getROIClusterData(roi).str()<<"\""<<std::endl;

                        fout->write(ss.str());
                    }
                }
            }
        }
        fout->flush ();
        fout->close();

    }
示例#24
0
ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
: m_Box(Gtk::ORIENTATION_VERTICAL)
{
	set_title("main_menu example");
	set_default_size(200,200);

	add(m_Box); //We can put a MenuBar at the top of the box and other stuff below it.

	// Define the actions:
	m_refActionGroup = Gio::SimpleActionGroup::create();

	m_refActionGroup->add_action("new",
		sigc::mem_fun(*this, &ExampleWindow::on_action_file_new) );
	m_refActionGroup->add_action("open",
		sigc::mem_fun(*this, &ExampleWindow::on_action_others) );


	m_refActionRain = m_refActionGroup->add_action_bool("rain",
		sigc::mem_fun(*this, &ExampleWindow::on_action_toggle),
		false);

	m_refActionGroup->add_action("quit",
		sigc::mem_fun(*this, &ExampleWindow::on_action_file_quit) );

	m_refActionGroup->add_action("cut",
		sigc::mem_fun(*this, &ExampleWindow::on_action_others) );
	m_refActionGroup->add_action("copy",
		sigc::mem_fun(*this, &ExampleWindow::on_action_others) );
	m_refActionGroup->add_action("paste",
		sigc::mem_fun(*this, &ExampleWindow::on_action_others) );

	insert_action_group("example", m_refActionGroup);

	// Define how the actions are presented in the menus and toolbars:
	m_refBuilder = Gtk::Builder::create();

	// Layout the actions in a menubar and toolbar:
	const char* ui_info =
		"<interface>"
		"  <menu id='menubar'>"
		"    <submenu>"
		"      <attribute name='label' translatable='yes'>_File</attribute>"
		"      <section>"
		"        <item>"
		"          <attribute name='label' tranlatable='yes'>_New</attribute>"
		"          <attribute name='action'>example.new</attribute>"
		"          <attribute name='accel'>&lt;Primary&gt;n</attribute>"
		"        </item>"
		"        <item>"
		"          <attribute name='label' translatable='yes'>_Open</attribute>"
		"          <attribute name='action'>example.open</attribute>"
		"          <attribute name='accel'>&lt;Primary&gt;o</attribute>"
		"        </item>"
		"      </section>"
		"      <section>"
		"        <item>"
		"          <attribute name='label' translatable='yes'>Rain</attribute>"
		"          <attribute name='action'>example.rain</attribute>"
		"        </item>"
		"      </section>"
		"      <section>"
		"        <item>"
		"          <attribute name='label' translatable='yes'>_Quit</attribute>"
		"          <attribute name='action'>example.quit</attribute>"
		"          <attribute name='accel'>&lt;Primary&gt;q</attribute>"
		"        </item>"
		"      </section>"
		"    </submenu>"
		"    <submenu>"
		"      <attribute name='lable' translatable='yes'>_Edit</attribute>"
		"      <item>"
		"        <attribute name='label' tlanslatable='yes'>_Cut</attribute>"
		"        <attribute name='action'>example.cut</attribute>"
		"        <attribute name='accel'>&lt;Primary&gt;x</attribute>"
		"      </item>"
		"      <item>"
		"        <attribute name='label' translatable='yes'>_Copy</attribute>"
		"        <attribute name='action'>example.copy</attribute>"
		"        <attribute name='accel'>&lt;Primary&gt;c</attribute>"
		"      </item>"
		"      <item>"
		"        <attribute name='label' translatable='yes'>_Paste</attribute>"
		"        <attribute name='action'>example.paste</attribute>"
		"        <attribute name='accel'>&lt;Primary&gt;v</attribute>"
		"      </item>"
		"    </submenu>"
		"  </menu>"
		"</interface>";

	// When the manubar is a child of a Gtk::Window, keyboard accelerators are not
	// automatically fetched from the Gio::Menu.
	// See the examples/book/menus/main_menu example for an alternative way of
	// adding the menubar when using Gtk::ApplicationWindow.
	// Gtk::Application::set_accel_for_action() is new in gtkmm 3.11.9.
	app->set_accel_for_action("example.new", "<Primary>n");
	app->set_accel_for_action("example.open", "<Primary>o");
	app->set_accel_for_action("example.quit", "<Primary>q");
	app->set_accel_for_action("example.cut", "<Primary>x");
	app->set_accel_for_action("example.copy", "<Primary>c");
	app->set_accel_for_action("example.paste", "<Primary>v");
	
	try
	{
		m_refBuilder->add_from_string(ui_info);
		m_refBuilder->add_from_resource("/toolbar/toolbar.glade");
	}
	catch(const Glib::Error& ex)
	{
		std::cerr << "Building menus and toolbar failed: " << ex.what();
	}
	
	// Get the menubat:
	auto object = m_refBuilder->get_object("menubar");
	auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
	if (!gmenu)
		g_warning("GMenu not found");
	else
	{
		auto pMenuBar = Gtk::manage(new Gtk::MenuBar(gmenu));
		
		// Add the MenuBar to the window:
		m_Box.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
	}
	
	// Get the toolbar and add it to a container widget:
	Gtk::Toolbar* toolbar = nullptr;
	m_refBuilder->get_widget("toolbar", toolbar);
	if (!toolbar)
		g_warning("GtkToolbar not found");
	else
		m_Box.pack_start(*toolbar, Gtk::PACK_SHRINK);

	show_all_children();
}
示例#25
0
void
seqdata::draw_events_on (Glib::RefPtr<Gdk::Drawable> drawable)
{
    midipulse tick;
    midibyte d0, d1;
    bool selected;
    int starttick = m_scroll_offset_ticks;
    int endtick = (m_window_x * m_zoom) + m_scroll_offset_ticks;
    draw_rectangle(drawable, white_paint(), 0, 0, m_window_x, m_window_y);
    m_gc->set_foreground(black_paint());

#ifdef USE_STAZED_SEQDATA_EXTENSIONS
    int numselected = EVENTS_ALL;                   // -1
    int seltype = numselected;
    if (m_status == EVENT_NOTE_ON)                  // ??????? iffy.
    {
        numselected = m_seq.get_num_selected_events(m_status, m_cc);
        if (numselected > 0)
            seltype = EVENTS_UNSELECTED;
    }
    do
    {
#endif

        m_seq.reset_draw_marker();
#ifdef USE_STAZED_SEQDATA_EXTENSIONS
        while
        (
            m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected, seltype)
        )
#else
        while (m_seq.get_next_event(m_status, m_cc, &tick, &d0, &d1, &selected))
#endif
        {
            if (tick >= starttick && tick <= endtick)
            {
                int event_x = tick / m_zoom;            /* screen coordinate    */
                int event_height = event::is_one_byte_msg(m_status) ? d0 : d1 ;
                int x = event_x - m_scroll_offset_x + 1;
                set_line(Gdk::LINE_SOLID, 2);           /* vertical event line  */
                draw_line
                (
                    drawable, selected ? dark_orange() : black_paint(),
                    x, c_dataarea_y - event_height, x, c_dataarea_y
                );

#ifdef USE_STAZED_SEQDATA_EXTENSIONS
                draw_rectangle                          /* draw handle          */
                (
                    drawable, selected ? dark_orange() : black_paint(), // true,
                    event_x - m_scroll_offset_x - 3,
                    c_dataarea_y - event_height,
                    c_data_handle_x,
                    c_data_handle_y
                );
#endif

                drawable->draw_drawable
                (
                    m_gc, m_numbers[event_height], 0, 0,
                    x + 2, c_dataarea_y - m_number_h + 3,
                    m_number_w, m_number_h
                );
            }
        }
#ifdef USE_STAZED_SEQDATA_EXTENSIONS
        if (seltype == EVENTS_UNSELECTED)
            seltype = numselected;
        else
            break;

    } while (seltype == EVENTS_UNSELECTED);
#endif
}
示例#26
0
/*
==================================
 FileSaver::load_xml
==================================
*/
void FileSaver::load_xml(const Glib::RefPtr<Gtk::Builder>& builder)
{
	builder->get_widget("filesaverdialog",filesaverdialog);
	builder->get_widget("flightlinelistlabel",flightlinelistlabel);
	builder->get_widget("flightlinesaveselect",flightlinesaveselect);
	builder->get_widget("parsestringentry", parsestringentry);
	builder->get_widget("scaleFactorEntryX1", scaleFactorEntryX);
	builder->get_widget("scaleFactorEntryY1", scaleFactorEntryY);
	builder->get_widget("scaleFactorEntryZ1", scaleFactorEntryZ);
	builder->get_widget("btnUseDefault1", btnUseDefault);
	builder->get_widget("utmselect", utmselect);
	builder->get_widget("latlongselect", latlongselect);
	builder->get_widget("savedialog", savedialog);
	builder->get_widget("saveprogressbar", saveprogressbar);
	builder->get_widget("savecancelbutton", savecancelbutton);
	builder->get_widget("waveformdialog", waveformdialog);
	builder->get_widget("waveformprogressbar", waveformprogressbar);
	builder->get_widget("waveformcancelbutton", waveformcancelbutton);
}
示例#27
0
 static void deserialize(const Glib::RefPtr<Gtk::TextBuffer> &buffer,
                         const std::string & content)
   {
     deserialize(buffer, buffer->begin(), content);
   }
PrecedenceConstraintDialog::PrecedenceConstraintDialog(
        const Glib::RefPtr < Gtk::Builder >& xml,
        PrecedenceConstraintModel precedenceConstraint) :
    mXml(xml)
{
    mPrecedenceConstraint = precedenceConstraint;

    xml->get_widget("PrecedenceConstraintDialog", mDialog);
    mDialog->set_title(mPrecedenceConstraint.source() + " to " +
            mPrecedenceConstraint.destination());
    xml->get_widget("ActTlMin", mActTlMin);
    xml->get_widget("ActTlMax", mActTlMax);
    xml->get_widget("PreConsCombobox", mComboPCType);
    xml->get_widget("PreConsLabel0", mPreConsLabel0);
    xml->get_widget("PreConsLabel1", mPreConsLabel1);
    xml->get_widget("PreConsLabel2", mPreConsLabel2);
    xml->get_widget("PreConsLabel3", mPreConsLabel3);
    xml->get_widget("PreConsLabel4", mPreConsLabel4);

// Fill the ComboBox with the informations (FS, SS, FF)
    xml->get_widget("TreeViewPredicates", mTreeViewPred);
    mRefTreePred = Gtk::ListStore::create(mColumnsPredType);
    mRefTreePred->clear();
    mComboPCType->unset_model();
    mComboPCType->clear();
    mComboPCType->set_model(mRefTreePred);

    Gtk::TreeModel::Row row1 = *(mRefTreePred->append());
    row1[mColumnsPredType.m_col_id] = 1;
    row1[mColumnsPredType.m_col_name] = "FS";
    Gtk::TreeModel::Row row2 = *(mRefTreePred->append());
    row2[mColumnsPredType.m_col_id] = 2;
    row2[mColumnsPredType.m_col_name] = "SS";
    Gtk::TreeModel::Row row3 = *(mRefTreePred->append());
    row3[mColumnsPredType.m_col_id] = 3;
    row3[mColumnsPredType.m_col_name] = "FF";

    mComboPCType->pack_start(mColumnsPredType.m_col_id);
    mComboPCType->pack_start(mColumnsPredType.m_col_name);

// Select the good constraint type
    std::string constraintType = mPrecedenceConstraint.cType();
    if (constraintType == "FS") {
        mComboPCType->set_active(0);
        mPreConsLabel0->set_text("FS precedence constraint");
        mPreConsLabel1->set_text(mPrecedenceConstraint.destination()
                + " start between ");
        mPreConsLabel2->set_text(" and ");
        mPreConsLabel3->set_text("");
        mPreConsLabel4->set_text(" after " + mPrecedenceConstraint.source() +
                " end");
    }
    else if (constraintType == "SS") {
        mComboPCType->set_active(1);
        mPreConsLabel0->set_text("SS precedence constraint");
        mPreConsLabel1->set_text(mPrecedenceConstraint.destination()
                + " start between ");
        mPreConsLabel2->set_text(" and ");
        mPreConsLabel3->set_text("");
        mPreConsLabel4->set_text(" after " + mPrecedenceConstraint.source() +
                " start");
    }
    else if (constraintType == "FF") {
        mComboPCType->set_active(2);
        mPreConsLabel0->set_text("FF precedence constraint");
        mPreConsLabel1->set_text(mPrecedenceConstraint.destination()
                + " end between ");
        mPreConsLabel2->set_text(" and ");
        mPreConsLabel3->set_text("");
        mPreConsLabel4->set_text(" after " + mPrecedenceConstraint.source() +
                " end");
    }

    mComboPCType->signal_changed().connect(sigc::mem_fun(*this,
            &PrecedenceConstraintDialog::on_combo_changed));

    mActTlMin->set_text(mPrecedenceConstraint.actTlMin());
    mActTlMax->set_text(mPrecedenceConstraint.actTlMax());
}
示例#29
0
int Ganash::Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>&command_line)
{
  g_print("on_command_line\n");

  // @see example http://git.gnome.org/browse/glibmm/tree/examples/options/main.cc?h=glibmm-2-24
  // @see console|graphic http://stackoverflow.com/questions/13852421/gtkmm-3-parse-command-line-with-gtkapplication

  bool          entry_version = FALSE;
  bool          entry_license = FALSE;
  bool          entry_mode    = FALSE;


  Glib::OptionContext context("[FICHIER|URI...]");

  Glib::OptionEntry option_version;
  option_version.set_short_name('v');
  option_version.set_long_name("version");
  option_version.set_description("Affiche l'information de version et quitte");

  Glib::OptionEntry option_license;
  option_license.set_short_name('l');
  option_license.set_long_name("license");
  option_license.set_description("Affiche l'information de licence et quitte");

  Glib::OptionEntry option_mode;
  option_mode.set_short_name('c');
  option_mode.set_long_name("console");
  option_mode.set_description("Lance l'application en mode console interactif");

  Glib::OptionGroup group_application("options", "Options de l'application :", "Affiche les options de l'application");
  group_application.add_entry(option_version, entry_version);
  group_application.add_entry(option_license, entry_license);
  group_application.add_entry(option_mode,    entry_mode);
  context.add_group(group_application);

  int argc;
  char **argv = command_line->get_arguments(argc);
  loc_argc = argc;
  loc_argv = argv;

  try
  {
    context.parse(argc, argv);
    if(entry_version)
      {
        print_version();
        // Ganash::ApplicationCommand::print_version();
      }
    else if(entry_license)
      {
        print_license();
        // Ganash::ApplicationCommand::print_license();
      }
    if(entry_mode)
      {
        g_print("console activate\n");
      }
    else
      {
        activate();
      }
  }
  catch(const Glib::Error& ex)
  {
    g_print("%s\n", ex.what().c_str() );
  }


  return 0;
}
示例#30
0
bool Viewer::on_expose_event(GdkEventExpose* event)
{
	Glib::RefPtr<Gdk::GL::Drawable> gldrawable = get_gl_drawable();
	
	if (!gldrawable) return false;
	
	if (!gldrawable->gl_begin(get_gl_context()))
		return false;
		
	if (zBufferCull)
	{
		glEnable(GL_DEPTH_TEST);
		glDepthMask(GL_TRUE);
	}
	
	if (backFaceCull)
	{
		glEnable(GL_CULL_FACE);
		glCullFace(GL_BACK);
	}
	
	if (frontFaceCull)
	{
		glEnable(GL_CULL_FACE);
		glCullFace(GL_FRONT);
	}
	
	// Set up for perspective drawing 
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glViewport(0, 0, get_width(), get_height());
	gluPerspective(40.0, (GLfloat)get_width()/(GLfloat)get_height(), 0.1, 1000.0);
	
	// change to model view for drawing
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	// Clear framebuffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glEnable(GL_NORMALIZE);
	// Set up lighting	
	// Initialize lighting settings
	glShadeModel(GL_SMOOTH);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glEnable(GL_LIGHTING);
	
	// Create one light source
	glEnable(GL_LIGHT0);
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	// Define properties of light 
	float ambientLight0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
	float diffuseLight0[] = { 0.8f, 0.8f, 0.8f, 1.0f };
	//float specularLight0[] = { 0.6f, 0.6f, 0.6f, 1.0f };
	float position0[] = { 0.0f, 0.0f, 0.0f, 1.0f };	
	glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight0);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight0);
	//glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight0);
	glLightfv(GL_LIGHT0, GL_POSITION, position0);

	// Draw stuff
	draw_puppet();
	
	if(drawTrackballCircle)
		draw_trackball_circle();
	
	// Swap the contents of the front and back buffers so we see what we
	// just drew. This should only be done if double buffering is enabled.
	gldrawable->swap_buffers();
	
	gldrawable->gl_end();
	
	return true;
}