Skip to content

Commit

Permalink
Tooltip support for options page in GTK+ ui (thanks, Nemo!)
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jan 11, 2008
1 parent 7c2fead commit d4e6fac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions gui.h
Expand Up @@ -45,6 +45,7 @@ typedef struct MojoGuiSetupOptions MojoGuiSetupOptions;
struct MojoGuiSetupOptions
{
const char *description;
const char *tooltip;
boolean value;
boolean is_group_parent;
uint64 size;
Expand Down
8 changes: 8 additions & 0 deletions gui_gtkplus2.c
Expand Up @@ -611,6 +611,7 @@ static void build_options(MojoGuiSetupOptions *opts, GtkWidget *box,
if (opts != NULL)
{
GtkWidget *widget;

if (opts->is_group_parent)
{
MojoGuiSetupOptions *kids = opts->child;
Expand Down Expand Up @@ -661,6 +662,13 @@ static void build_options(MojoGuiSetupOptions *opts, GtkWidget *box,
gtk_box_pack_start(GTK_BOX(box), widget, FALSE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(widget), "toggled",
GTK_SIGNAL_FUNC(signal_option_toggled), opts);

if (opts->tooltip != NULL)
{
GtkTooltips *tip = gtk_tooltips_new();
gtk_tooltips_set_tip(tip, widget, opts->tooltip, NULL);
} // if

if (opts->child != NULL)
{
build_options(opts->child, new_option_level(box),
Expand Down
7 changes: 7 additions & 0 deletions lua_glue.c
Expand Up @@ -1115,6 +1115,11 @@ static GuiOptions *build_one_gui_option(lua_State *L, GuiOptions *opts,
lua_getfield(L, -1, "description");
newopt->description = xstrdup(lua_tostring(L, -1));
lua_pop(L, 1);

lua_getfield(L, -1, "tooltip");
if (!lua_isnil(L, -1))
newopt->tooltip = xstrdup(lua_tostring(L, -1));
lua_pop(L, 1);

if (!is_option_group)
{
Expand All @@ -1134,6 +1139,7 @@ static GuiOptions *build_one_gui_option(lua_State *L, GuiOptions *opts,
if ((is_option_group) && (!newopt->child)) // skip empty groups.
{
free((void *) newopt->description);
free((void *) newopt->tooltip);
free(newopt);
newopt = NULL;
} // if
Expand Down Expand Up @@ -1249,6 +1255,7 @@ static void done_gui_options(lua_State *L, GuiOptions *opts)
} // if

free((void *) opts->description);
free((void *) opts->tooltip);
free(opts);
} // if
} // done_gui_options
Expand Down
1 change: 1 addition & 0 deletions scripts/mojosetup_init.lua
Expand Up @@ -431,6 +431,7 @@ function Setup.Option(tab)
{ "disabled", false, mustBeBool },
{ "bytes", nil, mustExist, mustBeNumber },
{ "description", nil, mustExist, mustBeString, cantBeEmpty },
{ "tooltip", nil, mustBeString, cantBeEmpty },
})
end

Expand Down

0 comments on commit d4e6fac

Please sign in to comment.