Ejemplo n.º 1
0
void Toggle::connectWidget(Gtk::Widget* widget)
{
	if (dynamic_cast<Gtk::ToggleToolButton*>(widget) != NULL)
	{
		Gtk::ToggleToolButton* toolButton = static_cast<Gtk::ToggleToolButton*>(widget);

		toolButton->set_active(_toggled);

		// Connect the toggleToolbutton to the callback of this class
		_toggleWidgets[widget] = toolButton->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onToggleToolButtonClicked));
	}
	else if (dynamic_cast<Gtk::ToggleButton*>(widget) != NULL)
	{
		Gtk::ToggleButton* toggleButton = static_cast<Gtk::ToggleButton*>(widget);

		toggleButton->set_active(_toggled);

		// Connect the togglebutton to the callback of this class
		_toggleWidgets[widget] = toggleButton->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onToggleButtonClicked));
	}
	else if (dynamic_cast<Gtk::CheckMenuItem*>(widget) != NULL)
	{
		Gtk::CheckMenuItem* menuItem = static_cast<Gtk::CheckMenuItem*>(widget);

		menuItem->set_active(_toggled);

		// Connect the togglebutton to the callback of this class
		_toggleWidgets[widget] = menuItem->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onCheckMenuItemClicked));
	}
}
Ejemplo n.º 2
0
void startup(Glib::RefPtr<Gtk::Application> app) {
	///To be run at startup
	
	GtkSettings *settings;
	settings = gtk_settings_get_default();
	g_object_set (G_OBJECT (settings), "gtk-application-prefer-dark-theme", FALSE, NULL);
	
	Gtk::Main kit;
	
	builder = Gtk::Builder::create_from_file(DATADIR "/main.glade");
	Gtk::Window *window = 0;
	builder->get_widget("window1", window);
	window->set_wmclass("org.gtkmm.examples.application", name);
	window->maximize();
	
	Gtk::TreeView *listview = 0;
	builder->get_widget("treeview1", listview);
	
	Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
	m_refTreeModel = Gtk::ListStore::create(m_columns);
	listview->set_model(m_refTreeModel);
	listview->set_search_column(1);
	
	Glib::RefPtr<Gtk::TreeSelection> list_selection = listview->get_selection();
	listview->signal_row_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeModel> >(sigc::ptr_fun(&on_button_clicked), listview->get_model()));
	
	Json::Value json = readFile(getRemoteFile("https://api.4chan.org/boards.json"));
	Json::Value boards = json["boards"];
	for(int i=0;i<boards.size();++i) {
		Gtk::TreeModel::Row row = *(m_refTreeModel->append());
		row[m_columns.name] = "/"+boards[i]["board"].asString()+"/";
		row[m_columns.longname] = boards[i]["title"].asString();
	}
	listview->set_rules_hint(true);
	
	Gtk::Menu *mainmenu = 0;
	builder->get_widget("menu1", mainmenu);
	Gtk::MenuToolButton *toolbut = 0;
	builder->get_widget("toolbutton2", toolbut);
	toolbut->set_menu(*mainmenu);
	
	Gtk::MenuItem *item1 = 0;
	builder->get_widget("menuitem1", item1);
	item1->signal_activate().connect(sigc::ptr_fun(&nameSettingsDialog));
	
	Gtk::CheckMenuItem *hideimages = 0;
	builder->get_widget("menuitem2", hideimages);
	hideimages->signal_toggled().connect(sigc::ptr_fun(&on_hide_toggled));
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->signal_activate().connect(sigc::ptr_fun(&open_thread_in_browser));
	
	Gtk::MenuItem *d_image = 0;
	builder->get_widget("menuitem5", d_image);
	d_image->signal_activate().connect(sigc::ptr_fun(&saveImageAs));
	
	Gtk::ToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->signal_clicked().connect(sigc::ptr_fun(&on_post_button_toggled));
	
	Gtk::Button *post_but2 = 0;
	builder->get_widget("button4", post_but2);
	post_but2->signal_clicked().connect(sigc::ptr_fun(&on_post_clicked));
	
	kit.run(*window);
}