2008-05-20 17:51:04 +08:00
|
|
|
/* 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>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-05-20 17:51:04 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-05-20 17:51:04 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-05-20 17:51:04 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-02 05:28:18 +08:00
|
|
|
#include <gegl.h>
|
2008-05-20 17:51:04 +08:00
|
|
|
#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,
|
2014-05-07 05:47:38 +08:00
|
|
|
const gchar *icon_name)
|
2008-05-20 17:51:04 +08:00
|
|
|
{
|
2008-08-22 16:57:11 +08:00
|
|
|
GtkToggleAction *action;
|
|
|
|
|
|
|
|
action = g_object_new (GIMP_TYPE_TOGGLE_ACTION,
|
2014-05-07 05:47:38 +08:00
|
|
|
"name", name,
|
|
|
|
"label", label,
|
|
|
|
"tooltip", tooltip,
|
|
|
|
"icon-name", icon_name,
|
2008-08-22 16:57:11 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return action;
|
2008-05-20 17:51:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toggle_action_set_proxy_tooltip (GimpToggleAction *action,
|
|
|
|
GtkWidget *proxy)
|
|
|
|
{
|
2009-05-25 04:29:18 +08:00
|
|
|
const gchar *tooltip = gtk_action_get_tooltip (GTK_ACTION (action));
|
2008-05-20 17:51:04 +08:00
|
|
|
|
|
|
|
if (tooltip)
|
2009-05-25 04:29:18 +08:00
|
|
|
gimp_help_set_help_data (proxy, tooltip,
|
|
|
|
g_object_get_qdata (G_OBJECT (proxy),
|
|
|
|
GIMP_HELP_ID));
|
2008-05-20 17:51:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|