mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am app/widgets/gimptoggleaction.[ch] added new action
2008-05-20 Sven Neumann <sven@gimp.org> * app/widgets/Makefile.am * app/widgets/gimptoggleaction.[ch] * app/widgets/gimpradioaction.[ch]: added new action types derived from GtkToggleAction and GtkRadioAction. These types override the "connect_proxy" method to enable tooltips in menus. * app/widgets/gimpactiongroup.c: use the new action types. * app/actions/dockable-actions.c: added a tooltip for the "dockable-lock-tab" action. svn path=/trunk/; revision=25717
This commit is contained in:
parent
115bf7cedd
commit
9a63a43566
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-05-20 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/gimptoggleaction.[ch]
|
||||
* app/widgets/gimpradioaction.[ch]: added new action types derived
|
||||
from GtkToggleAction and GtkRadioAction. These types override the
|
||||
"connect_proxy" method to enable tooltips in menus.
|
||||
|
||||
* app/widgets/gimpactiongroup.c: use the new action types.
|
||||
|
||||
* app/actions/dockable-actions.c: added a tooltip for the
|
||||
"dockable-lock-tab" action.
|
||||
|
||||
2008-05-20 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimpbrightnesscontrasttool.c
|
||||
|
|
|
@ -105,7 +105,8 @@ static const GimpRadioActionEntry dockable_tab_style_actions[] =
|
|||
static const GimpToggleActionEntry dockable_toggle_actions[] =
|
||||
{
|
||||
{ "dockable-lock-tab", NULL,
|
||||
N_("Loc_k Tab to Dock"), NULL, NULL,
|
||||
N_("Loc_k Tab to Dock"), NULL,
|
||||
N_("Protect this tab from being dragged with the mouse pointer"),
|
||||
G_CALLBACK (dockable_lock_tab_cmd_callback),
|
||||
FALSE,
|
||||
GIMP_HELP_DOCK_TAB_LOCK },
|
||||
|
|
|
@ -233,6 +233,8 @@ libappwidgets_a_sources = \
|
|||
gimpprogressdialog.h \
|
||||
gimppropwidgets.c \
|
||||
gimppropwidgets.h \
|
||||
gimpradioaction.c \
|
||||
gimpradioaction.h \
|
||||
gimprender.c \
|
||||
gimprender.h \
|
||||
gimpsamplepointeditor.c \
|
||||
|
@ -265,6 +267,8 @@ libappwidgets_a_sources = \
|
|||
gimptexteditor.h \
|
||||
gimpthumbbox.c \
|
||||
gimpthumbbox.h \
|
||||
gimptoggleaction.c \
|
||||
gimptoggleaction.h \
|
||||
gimptoolbox.c \
|
||||
gimptoolbox.h \
|
||||
gimptoolbox-color-area.c \
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
#include "gimpaction.h"
|
||||
#include "gimpenumaction.h"
|
||||
#include "gimppluginaction.h"
|
||||
#include "gimpradioaction.h"
|
||||
#include "gimpstringaction.h"
|
||||
#include "gimptoggleaction.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -400,8 +402,8 @@ gimp_action_group_add_toggle_actions (GimpActionGroup *group,
|
|||
if (! group->mnemonics)
|
||||
label = gimp_strip_uline (label);
|
||||
|
||||
action = gtk_toggle_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id);
|
||||
action = gimp_toggle_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id);
|
||||
|
||||
if (! group->mnemonics)
|
||||
g_free (label);
|
||||
|
@ -452,9 +454,9 @@ gimp_action_group_add_radio_actions (GimpActionGroup *group,
|
|||
if (! group->mnemonics)
|
||||
label = gimp_strip_uline (label);
|
||||
|
||||
action = gtk_radio_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id,
|
||||
entries[i].value);
|
||||
action = gimp_radio_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id,
|
||||
entries[i].value);
|
||||
|
||||
if (! group->mnemonics)
|
||||
g_free (label);
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpradioaction.c
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpradioaction.h"
|
||||
|
||||
|
||||
static void gimp_radio_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_radio_action_set_proxy_tooltip (GimpRadioAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_radio_action_tooltip_notify (GimpRadioAction *action,
|
||||
const GParamSpec *pspec,
|
||||
gpointer data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpRadioAction, gimp_radio_action, GTK_TYPE_RADIO_ACTION)
|
||||
|
||||
#define parent_class gimp_radio_action_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_radio_action_class_init (GimpRadioActionClass *klass)
|
||||
{
|
||||
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||
|
||||
action_class->connect_proxy = gimp_radio_action_connect_proxy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_radio_action_init (GimpRadioAction *action)
|
||||
{
|
||||
g_signal_connect (action, "notify::tooltip",
|
||||
G_CALLBACK (gimp_radio_action_tooltip_notify),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_radio_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
|
||||
|
||||
gimp_radio_action_set_proxy_tooltip (GIMP_RADIO_ACTION (action), proxy);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkRadioAction *
|
||||
gimp_radio_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id,
|
||||
gint value)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_RADIO_ACTION,
|
||||
"name", name,
|
||||
"label", label,
|
||||
"tooltip", tooltip,
|
||||
"stock-id", stock_id,
|
||||
"value", value,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
||||
static void
|
||||
gimp_radio_action_set_proxy_tooltip (GimpRadioAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
gchar *tooltip;
|
||||
|
||||
g_object_get (action, "tooltip", &tooltip, NULL);
|
||||
|
||||
if (tooltip)
|
||||
{
|
||||
gimp_help_set_help_data (proxy, tooltip,
|
||||
g_object_get_qdata (G_OBJECT (proxy),
|
||||
GIMP_HELP_ID));
|
||||
g_free (tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_radio_action_tooltip_notify (GimpRadioAction *action,
|
||||
const GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
gimp_radio_action_set_proxy_tooltip (action, list->data);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpradioaction.h
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_RADIO_ACTION_H__
|
||||
#define __GIMP_RADIO_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtkradioaction.h>
|
||||
|
||||
|
||||
#define GIMP_TYPE_RADIO_ACTION (gimp_radio_action_get_type ())
|
||||
#define GIMP_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RADIO_ACTION, GimpRadioAction))
|
||||
#define GIMP_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RADIO_ACTION, GimpRadioActionClass))
|
||||
#define GIMP_IS_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RADIO_ACTION))
|
||||
#define GIMP_IS_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_ACTION))
|
||||
#define GIMP_RADIO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_RADIO_ACTION, GimpRadioActionClass))
|
||||
|
||||
|
||||
typedef GtkRadioAction GimpRadioAction;
|
||||
typedef GtkRadioActionClass GimpRadioActionClass;
|
||||
|
||||
|
||||
GType gimp_radio_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRadioAction * gimp_radio_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id,
|
||||
gint value);
|
||||
|
||||
|
||||
#endif /* __GIMP_RADIO_ACTION_H__ */
|
|
@ -0,0 +1,124 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimptoggleaction.c
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimptoggleaction.h"
|
||||
|
||||
|
||||
static void gimp_toggle_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_toggle_action_set_proxy_tooltip (GimpToggleAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_toggle_action_tooltip_notify (GimpToggleAction *action,
|
||||
const GParamSpec *pspec,
|
||||
gpointer data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpToggleAction, gimp_toggle_action, GTK_TYPE_TOGGLE_ACTION)
|
||||
|
||||
#define parent_class gimp_toggle_action_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_toggle_action_class_init (GimpToggleActionClass *klass)
|
||||
{
|
||||
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||
|
||||
action_class->connect_proxy = gimp_toggle_action_connect_proxy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_toggle_action_init (GimpToggleAction *action)
|
||||
{
|
||||
g_signal_connect (action, "notify::tooltip",
|
||||
G_CALLBACK (gimp_toggle_action_tooltip_notify),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_toggle_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
|
||||
|
||||
gimp_toggle_action_set_proxy_tooltip (GIMP_TOGGLE_ACTION (action), proxy);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkToggleAction *
|
||||
gimp_toggle_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_TOGGLE_ACTION,
|
||||
"name", name,
|
||||
"label", label,
|
||||
"tooltip", tooltip,
|
||||
"stock-id", stock_id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
||||
static void
|
||||
gimp_toggle_action_set_proxy_tooltip (GimpToggleAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
gchar *tooltip;
|
||||
|
||||
g_object_get (action, "tooltip", &tooltip, NULL);
|
||||
|
||||
if (tooltip)
|
||||
{
|
||||
gimp_help_set_help_data (proxy, tooltip,
|
||||
g_object_get_qdata (G_OBJECT (proxy),
|
||||
GIMP_HELP_ID));
|
||||
g_free (tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_toggle_action_tooltip_notify (GimpToggleAction *action,
|
||||
const GParamSpec *pspec,
|
||||
gpointer data)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
gimp_toggle_action_set_proxy_tooltip (action, list->data);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimptoggleaction.h
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TOGGLE_ACTION_H__
|
||||
#define __GIMP_TOGGLE_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtktoggleaction.h>
|
||||
|
||||
|
||||
#define GIMP_TYPE_TOGGLE_ACTION (gimp_toggle_action_get_type ())
|
||||
#define GIMP_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOGGLE_ACTION, GimpToggleAction))
|
||||
#define GIMP_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOGGLE_ACTION, GimpToggleActionClass))
|
||||
#define GIMP_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOGGLE_ACTION))
|
||||
#define GIMP_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_ACTION))
|
||||
#define GIMP_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_TOGGLE_ACTION, GimpToggleActionClass))
|
||||
|
||||
|
||||
typedef GtkToggleAction GimpToggleAction;
|
||||
typedef GtkToggleActionClass GimpToggleActionClass;
|
||||
|
||||
|
||||
GType gimp_toggle_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkToggleAction * gimp_toggle_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id);
|
||||
|
||||
|
||||
#endif /* __GIMP_TOGGLE_ACTION_H__ */
|
Loading…
Reference in New Issue