Example #1
0
static GtkWidget *
create_toolbar (void)
{
  GtkWidget *toolbar;
  GtkToolItem *item;

  toolbar = gtk_toolbar_new ();

  item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-new", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
  gtk_tool_item_set_tooltip_markup (item, "Open another one of these windows");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.new");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
  gtk_tool_item_set_tooltip_markup (item, "This is a demo button that locks up the demo");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.lock");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
  gtk_tool_item_set_tooltip_markup (item, "This is a demo button that toggles window decorations");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.decorations");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_tool_button_new (gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
  gtk_tool_item_set_tooltip_markup (item, "This is a demo button that locks the aspect ratio using a hint");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.ratio");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_tool_button_new (gtk_image_new_from_icon_name ("gtk-quit", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL);
  gtk_tool_item_set_tooltip_markup (item, "This is a demo button with a 'quit' icon");
  gtk_actionable_set_action_name (GTK_ACTIONABLE (item), "demo.quit");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  return toolbar;
}
Example #2
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkToolItem_gtk_1tool_1item_1set_1tooltip_1markup
(
    JNIEnv* env,
    jclass cls,
    jlong _self,
    jstring _markup
)
{
    GtkToolItem* self;
    const gchar* markup;

    // convert parameter self
    self = (GtkToolItem*) _self;

    // convert parameter markup
    markup = (const gchar*) bindings_java_getString(env, _markup);
    if (markup == NULL) {
        return; // Java Exception already thrown
    }

    // call function
    gtk_tool_item_set_tooltip_markup(self, markup);

    // cleanup parameter self

    // cleanup parameter markup
    bindings_java_releaseString(markup);
}
static VALUE
rg_set_tooltip(VALUE self, VALUE tooltip)
{
    if (TYPE(tooltip) == T_HASH) {
        VALUE text, markup;
        rbg_scan_options(tooltip,
                         "text", &text,
                         "markup", &markup,
                         NULL);
        if (!NIL_P(text))
            gtk_tool_item_set_tooltip_text(_SELF(self), RVAL2CSTR(text));
        else if (!NIL_P(markup))
            gtk_tool_item_set_tooltip_markup(_SELF(self), RVAL2CSTR(markup));
        else
            rb_raise(rb_eArgError, "Invalid arguments.");
    } else {
        rb_raise(rb_eArgError, "Invalid arguments.");
    }

    return self;
}