// A wrapper around set_tooltip_*() for portability across different gtkmm versions.
void app_gtkmm_set_widget_tooltip(Gtk::Widget& widget,
		const Glib::ustring& tooltip_text, bool use_markup)
{
	// set_tooltip_* is available since 2.12
#ifndef APP_GTKMM_OLD_TOOLTIPS
	if (use_markup) {
		widget.set_tooltip_markup(tooltip_text);
	} else {
		widget.set_tooltip_text(tooltip_text);
	}

#else  // use the old tooltips api
	Gtk::Widget* toplevel = widget.get_toplevel();
	if (toplevel && toplevel->is_toplevel()) {  // orphan widgets return themselves, so check toplevelness.
		GtkTooltips* tooltips = static_cast<GtkTooltips*>(toplevel->get_data("window_tooltips"));
		if (tooltips) {
			if (use_markup) {
				// strip markup
				Glib::ustring stripped;
				if (app_pango_strip_markup(tooltip_text, stripped)) {
					gtk_tooltips_set_tip(tooltips, widget.gobj(), stripped.c_str(), "");
				}

			} else {
				gtk_tooltips_set_tip(tooltips, widget.gobj(), tooltip_text.c_str(), "");
			}
		}
	}
#endif
}
Exemplo n.º 2
0
void SPAttributeTable::clear(void)
{
    Gtk::Widget *w;
    
    if (table)
    {
        std::vector<Gtk::Widget*> ch = table->get_children();
        for (int i = (ch.size())-1; i >=0 ; i--)
        {
            w = ch[i];
            ch.pop_back();
            if (w != NULL)
            {
                try
                {
                    sp_signal_disconnect_by_data (w->gobj(), this);
                    delete w;
                }
                catch(...)
                {
                }
            }
        }
        ch.clear();
        _attributes.clear();
        _entries.clear();
        
        delete table;
        table = NULL;
    }

    if (_object)
    {
        modified_connection.disconnect();
        release_connection.disconnect();
        _object = NULL;
    }
}
Exemplo n.º 3
0
void child_set_property(Gtk::Container& container, Gtk::Widget& child, const char *property_name, bool value) {
    GValue v = {0};
    g_value_init(&v, G_TYPE_BOOLEAN);
    g_value_set_boolean(&v, value);
    gtk_container_child_set_property(container.gobj(), child.gobj(), property_name, &v);
}
Exemplo n.º 4
0
int dnd___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) {
	if((*p)[0]==name__()){
		if(siz==-1)return 1;
		if(p->size()<3){
			d_(sh_,err_show_buzu_,p);
			return 1;
		}
		Gtk::Widget* w;
		sh_->builder_->get_widget((*p)[2], w);
		if(!w){
			d_(sh_,err_show_wufa_,2,p,2);
			return 1;
		}
		GtkWidget* w1=w->gobj();
		if((*p)[1]=="移除"){
			del__(w1);
			return 1;
		}
		if((*p)[1]=="目标"){
			if(p->size()<6){
				d_(sh_,err_show_buzu_,p);
				return 1;
			}
			int gdd=0,gda=0;

			dnd_cb___* cb=new dnd_cb___('d',w1,sh_,d_);
			for(size_t i=3;i<p->size();i++){
				const Glib::ustring& p1=(*p)[i];
				if(p1=="代码"){
					if(++i>=p->size()){
						d_(sh_,err_show_buzu_,p);
						delete cb;
						return 1;
					}
					cb->code_=(*p)[i];
					continue;
				}
				if(p1=="复制"){
					gda|=GDK_ACTION_COPY;
					continue;
				}
				if(p1=="移动"){
					gda|=GDK_ACTION_MOVE;
					continue;
				}
				if(p1=="链接"){
					gda|=GDK_ACTION_LINK;
					continue;
				}
				if(p1=="高亮"){
					gdd|=GTK_DEST_DEFAULT_HIGHLIGHT|GTK_DEST_DEFAULT_MOTION;
					continue;
				}
				if(p1=="按钮"){
					gdd|=GTK_DEST_DEFAULT_DROP|GTK_DEST_DEFAULT_MOTION;
					continue;
				}
				delete cb;
				d_(sh_,err_show_buzhichi_,2,p,i);
				return 1;
			}

			gtk_drag_dest_set (w1, (GtkDestDefaults)gdd, 0, 0, (GdkDragAction)gda);
			gtk_drag_dest_add_uri_targets(w1);
			cb->sid_=g_signal_connect (w1, "drag-data-received",G_CALLBACK(drag_data_received__), cb);

			cb_.push_back(cb);
			return 1;
		}
		d_(sh_,err_show_buzhichi_,2,p,1);
		return 1;
	}
	return 0;
}