static void
gtk_source_mark_attributes_set_property (GObject      *object,
					 guint         prop_id,
					 const GValue *value,
					 GParamSpec   *pspec)
{
	GtkSourceMarkAttributes *self = GTK_SOURCE_MARK_ATTRIBUTES (object);

	switch (prop_id)
	{
		case PROP_BACKGROUND:
			set_background (self, g_value_get_boxed (value));
			break;
		case PROP_STOCK_ID:
			set_stock_id (self, g_value_get_string (value));
			break;
		case PROP_PIXBUF:
			set_pixbuf (self, g_value_get_object (value));
			break;
		case PROP_ICON_NAME:
			set_icon_name (self, g_value_get_string (value));
			break;
		case PROP_GICON:
			set_gicon (self, g_value_get_object (value));
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}
/**
 * gtk_source_mark_attributes_set_icon_name:
 * @attributes: a #GtkSourceMarkAttributes.
 * @icon_name: name of an icon to be used.
 *
 * Sets a name of an icon to be used as a base for rendered icon.
 */
void
gtk_source_mark_attributes_set_icon_name (GtkSourceMarkAttributes *attributes,
					  const gchar             *icon_name)
{
	g_return_if_fail (GTK_SOURCE_IS_MARK_ATTRIBUTES (attributes));

	set_icon_name (attributes, icon_name);
}
Esempio n. 3
0
void ttoggle_button::set_members(const string_map& data)
{
	// Inherit
	tcontrol::set_members(data);

	string_map::const_iterator itor = data.find("icon");
	if(itor != data.end()) {
		set_icon_name(itor->second);
	}
}
GtkWidget *
cc_wacom_page_new (CcWacomPanel   *panel,
		   CsdWacomDevice *stylus,
		   CsdWacomDevice *eraser,
		   CsdWacomDevice *pad)
{
	CcWacomPage *page;
	CcWacomPagePrivate *priv;

	g_return_val_if_fail (CSD_IS_WACOM_DEVICE (stylus), NULL);
	g_return_val_if_fail (csd_wacom_device_get_device_type (stylus) == WACOM_TYPE_STYLUS, NULL);

	g_return_val_if_fail (CSD_IS_WACOM_DEVICE (eraser), NULL);
	g_return_val_if_fail (csd_wacom_device_get_device_type (eraser) == WACOM_TYPE_ERASER, NULL);

	if (pad != NULL)
		g_return_val_if_fail (csd_wacom_device_get_device_type (pad) == WACOM_TYPE_PAD, NULL);

	page = g_object_new (CC_TYPE_WACOM_PAGE, NULL);

	priv = page->priv;
	priv->panel = panel;

	cc_wacom_page_update_tools (page, stylus, eraser, pad);

	/* FIXME move this to construct */
	priv->wacom_settings  = csd_wacom_device_get_settings (stylus);
	set_mode_from_gsettings (GTK_COMBO_BOX (WID ("combo-tabletmode")), page);

	/* Tablet name */
	gtk_label_set_text (GTK_LABEL (WID ("label-tabletmodel")), csd_wacom_device_get_name (stylus));

	/* Left-handedness */
	if (csd_wacom_device_reversible (stylus))
		set_left_handed_from_gsettings (page);

	/* Tablet icon */
	set_icon_name (page, "image-tablet", csd_wacom_device_get_icon_name (stylus));

	/* Add styli */
	add_styli (page);

	/* Get the current stylus and switch to its page */
	stylus_changed (priv->stylus, NULL, page);
	g_signal_connect (G_OBJECT (priv->stylus), "notify::last-stylus",
			  G_CALLBACK (stylus_changed), page);

	return GTK_WIDGET (page);
}
Esempio n. 5
0
bool XPlatformWindow::open( const char* display_name,
                            int x, int y, int w, int h,
                            int min_w, int max_w, int min_h, int max_h, // -1 for don't care
                            const char* window_name,  const char* icon_name,
                            const char* font_name,    int   /*font_size unimp X*/ ) {

  // (adapted from Spy open routine, needs font info for sizing)
  // XOpenDisplay fails silently if a signal is received during the call.
  // All signals except user interrupts are therefore blocked. 
  SignalBlocker sb(SignalBlocker::allow_user_int);
  
  if (!open_xdisplay(display_name)) { close();  return false; }
  
  bool debugMe = false;              // set to true when debugging X
  XSynchronize(_display, debugMe);  
  XSetErrorHandler(XErrorHandlers::handle_X_error);

  _screen_num     = DefaultScreen(_display);
  _display_width  = DisplayWidth (_display, _screen_num);
  _display_height = DisplayHeight(_display, _screen_num);
  
  _window_x = x;  _window_y = y;  _width = w;  _height = h;

  // create the window; will be resized and repositioned when reparented
  Window root = RootWindow(_display, _screen_num);
  
  _xwindow = XCreateSimpleWindow(  _display, root,
                                   _window_x, _window_y,
                                   width(), height(), 0,
                                   BlackPixel(_display, _screen_num),
                                   WhitePixel(_display, _screen_num));
  
  if (!set_font_info(font_name))                       {  close();  return false; }
  if (!change_size_hints(min_w, max_w, min_h, max_h))  {  close();  return false; }
  
  if (!set_name(     window_name))  {  close(); return false; }
  if (!set_icon_name(  icon_name))  {  close(); return false; }
  
  setup_events();  
  XMapWindow(_display, _xwindow);
  
 if (!setup_gcs())      {  close(); return false; }
 
  return true;
}
Esempio n. 6
0
void DocumentView::build_widgets() {
    scrolled_window_.add(view_);
    view_.set_buffer(buffer_);

    view_.signal_populate_popup().connect(sigc::mem_fun(this, &DocumentView::populate_popup));

    auto manager = Gsv::StyleSchemeManager::get_default();
    view_.get_source_buffer()->set_style_scheme(manager->get_scheme("delimit"));

    auto provider = Gsv::CompletionWords::create("", Glib::RefPtr<Gdk::Pixbuf>());
    provider->register_provider(buffer_);
    provider->property_priority().set_value(1);
    view_.get_completion()->add_provider(provider);
    view_.get_completion()->signal_show().connect([&]() { completion_visible_ = true; });
    view_.get_completion()->signal_hide().connect([&]() { completion_visible_ = false; });

    auto coverage_attrs = Gsv::MarkAttributes::create();
    Gdk::RGBA coverage_colour;
    coverage_colour.set_rgba(1.0, 0.5, 0, 0.12);
    coverage_attrs->set_background(coverage_colour);
    view_.set_mark_attributes("coverage", coverage_attrs, 0);

    auto linter_attrs = Gsv::MarkAttributes::create();
    linter_attrs->set_icon_name("dialog-error");
    g_signal_connect(linter_attrs->gobj(), "query-tooltip-markup", G_CALLBACK(get_tooltip), view_.gobj());
    view_.set_mark_attributes("linter", linter_attrs, 10);

    auto breakpoint = Gsv::MarkAttributes::create();
    breakpoint->set_icon_name("stop");
    view_.set_mark_attributes("breakpoint", breakpoint, 11);
    view_.add_events(Gdk::BUTTON_PRESS_MASK);
    view_.signal_button_press_event().connect([&](GdkEventButton* evt) -> bool {

        if(!buffer_->get_language() || buffer_->get_language()->get_name() != "Python") {
            return false;
        }

        if(evt->type == GDK_2BUTTON_PRESS && evt->window == view_.get_window(Gtk::TEXT_WINDOW_LEFT)->gobj()) {
            //The user clicked within the left gutter
            if(evt->button == 1) {
                //Left click
                int x_buf, y_buf;

                view_.window_to_buffer_coords(
                    Gtk::TEXT_WINDOW_LEFT,
                    int(evt->x), int(evt->y),
                    x_buf, y_buf
                );

                //Line bounds
                Gtk::TextBuffer::iterator iter;
                int line_top;
                view_.get_line_at_y(iter, y_buf, line_top);
                auto mark_list = buffer_->get_source_marks_at_iter(iter, "breakpoint");
                if(!mark_list.empty()) {
                    for(auto& mark: mark_list) {
                        buffer_->delete_mark(mark);
                    }

                    auto end_iter = iter;
                    end_iter.forward_line();

                    unicode line = buffer_->get_slice(iter, end_iter).c_str();
                    if(line.contains("import ipdb; ipdb.set_trace()")) {
                        buffer_->erase(iter, end_iter);
                    }
                } else {
                    buffer_->create_source_mark("breakpoint", iter);

                    auto end_iter = iter;
                    end_iter.forward_line();

                    unicode line_text = buffer_->get_slice(iter, end_iter).c_str();

                    uint32_t i = 0;
                    for(; i < line_text.length(); ++i) {
                        if(line_text[i] != ' ' && line_text[i] != '\t') {
                            break;
                        }
                    }

                    auto indentation = line_text.slice(nullptr, i);
                    auto replacement_text = _u("{0}import ipdb; ipdb.set_trace();\n").format(indentation);
                    buffer_->insert(iter, replacement_text.encode());
                }
            }
        }
        return false;
    });

    apply_settings("text/plain");

    scrolled_window_.show_all();
}
Esempio n. 7
0
YarpScope::MainWindow::MainWindow() :
    mPriv(new Private(this))
{
    set_border_width(3);
    set_default_size(640, 480);
    set_icon_name("yarpscope"); // FIXME

    add(mPriv->windowBox);

    // Setup actions
    mPriv->refActionGroup = Gtk::ActionGroup::create();

    mPriv->refActionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
    mPriv->refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_file_quit));
    mPriv->refActionGroup->add(Gtk::Action::create("MenuActions", _("_Actions")));
    mPriv->refActionGroup->add(Gtk::ToggleAction::create_with_icon_name("StopStart", "media-playback-pause", _("Stop"), _("Stop plotting")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_stop_start));
    mPriv->refActionGroup->add(Gtk::Action::create_with_icon_name("Clear", "edit-clear", _("Clear"), _("Clear plots")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_clear));
    mPriv->refActionGroup->add(Gtk::Action::create_with_icon_name("AutoRescale", "transform-scale", _("Auto Rescale"), _("Automatically rescale plots")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_autorescale));
    mPriv->refActionGroup->add(Gtk::Action::create("MenuHelp", _("Help")));
    mPriv->refActionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_help_about));

    mPriv->refUIManager->insert_action_group(mPriv->refActionGroup);
    add_accel_group(mPriv->refUIManager->get_accel_group());

    Glib::ustring ui_info =
        "<ui>"
        "  <menubar name='MenuBar'>"
        "    <menu action='MenuFile'>"
        "      <separator />"
        "      <menuitem action='Quit'/>"
        "    </menu>"
        "    <menu action='MenuActions'>"
        "      <menuitem action='StopStart'/>"
        "      <menuitem action='Clear'/>"
        "      <menuitem action='AutoRescale'/>"
        "    </menu>"
        "    <menu action='MenuHelp'>"
        "      <menuitem action='About'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='StopStart'/>"
        "    <toolitem action='Clear'/>"
        "    <toolitem action='AutoRescale'/>"
        "  </toolbar>"
        "</ui>";

    try {
        mPriv->refUIManager->add_ui_from_string(ui_info);
    }
    catch(const Glib::Error& ex) {
        fatal() << "building menus failed: " <<  ex.what();
    }

    // Setup menu bar
    Gtk::MenuBar* menubar = dynamic_cast<Gtk::MenuBar*>(mPriv->refUIManager->get_widget("/MenuBar"));
    if(menubar) {
        mPriv->windowBox.pack_start(*menubar, Gtk::PACK_SHRINK);
    } else {
        fatal() << "building menus failed: \"/MenuBar\" is missing";
    }

    // Setup toolbar
    Gtk::Toolbar* toolbar = dynamic_cast<Gtk::Toolbar*>(mPriv->refUIManager->get_widget("/ToolBar"));
    if(toolbar) {
        mPriv->windowBox.pack_start(*toolbar, Gtk::PACK_SHRINK);
        toolbar->set_toolbar_style(Gtk::TOOLBAR_BOTH);
    } else {
        fatal() << "building menus failed: \"/ToolBar\" is missing";
    }

    mPriv->intervalSpinButton.set_value(PortReader::instance().interval());
    mPriv->intervalSpinButton.signal_value_changed().connect(sigc::mem_fun(*mPriv, &YarpScope::MainWindow::Private::on_action_interval_value_changed));
    mPriv->intervalVBox.pack_start(mPriv->intervalSpinButton);
    mPriv->intervalVBox.pack_start(mPriv->intervalLabel);
    mPriv->intervalToolItem.add(mPriv->intervalVBox);
    toolbar->prepend(mPriv->intervalToolItem);

    mPriv->windowBox.pack_start(*PlotManager::instance().getPlotWidget());

    show_all_children();
}