|
Packit |
98cdb6 |
/* GTK - The GIMP Toolkit
|
|
Packit |
98cdb6 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
98cdb6 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
98cdb6 |
* License as published by the Free Software Foundation; either
|
|
Packit |
98cdb6 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
98cdb6 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
98cdb6 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
98cdb6 |
* Lesser General Public License for more details.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
98cdb6 |
* License along with this library; if not, write to the
|
|
Packit |
98cdb6 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit |
98cdb6 |
* Boston, MA 02111-1307, USA.
|
|
Packit |
98cdb6 |
*/
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
/*
|
|
Packit |
98cdb6 |
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
Packit |
98cdb6 |
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
Packit |
98cdb6 |
* files for a list of changes. These files are distributed with
|
|
Packit |
98cdb6 |
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
Packit |
98cdb6 |
*/
|
|
Packit |
98cdb6 |
#include "config.h"
|
|
Packit |
98cdb6 |
#include <string.h>
|
|
Packit |
98cdb6 |
#include <glib.h>
|
|
Packit |
98cdb6 |
#include "gtkcolorseldialog.h"
|
|
Packit |
98cdb6 |
#include "gtkframe.h"
|
|
Packit |
98cdb6 |
#include "gtkhbbox.h"
|
|
Packit |
98cdb6 |
#include "gtkbutton.h"
|
|
Packit |
98cdb6 |
#include "gtkstock.h"
|
|
Packit |
98cdb6 |
#include "gtkintl.h"
|
|
Packit |
98cdb6 |
#include "gtkbuildable.h"
|
|
Packit |
98cdb6 |
#include "gtkalias.h"
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
enum {
|
|
Packit |
98cdb6 |
PROP_0,
|
|
Packit |
98cdb6 |
PROP_COLOR_SELECTION,
|
|
Packit |
98cdb6 |
PROP_OK_BUTTON,
|
|
Packit |
98cdb6 |
PROP_CANCEL_BUTTON,
|
|
Packit |
98cdb6 |
PROP_HELP_BUTTON
|
|
Packit |
98cdb6 |
};
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
/***************************/
|
|
Packit |
98cdb6 |
/* GtkColorSelectionDialog */
|
|
Packit |
98cdb6 |
/***************************/
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void gtk_color_selection_dialog_buildable_interface_init (GtkBuildableIface *iface);
|
|
Packit |
98cdb6 |
static GObject * gtk_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
|
Packit |
98cdb6 |
GtkBuilder *builder,
|
|
Packit |
98cdb6 |
const gchar *childname);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
G_DEFINE_TYPE_WITH_CODE (GtkColorSelectionDialog, gtk_color_selection_dialog,
|
|
Packit |
98cdb6 |
GTK_TYPE_DIALOG,
|
|
Packit |
98cdb6 |
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_buildable_interface_init))
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static GtkBuildableIface *parent_buildable_iface;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_get_property (GObject *object,
|
|
Packit |
98cdb6 |
guint prop_id,
|
|
Packit |
98cdb6 |
GValue *value,
|
|
Packit |
98cdb6 |
GParamSpec *pspec)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkColorSelectionDialog *colorsel;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorsel = GTK_COLOR_SELECTION_DIALOG (object);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
switch (prop_id)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
case PROP_COLOR_SELECTION:
|
|
Packit |
98cdb6 |
g_value_set_object (value, colorsel->colorsel);
|
|
Packit |
98cdb6 |
break;
|
|
Packit |
98cdb6 |
case PROP_OK_BUTTON:
|
|
Packit |
98cdb6 |
g_value_set_object (value, colorsel->ok_button);
|
|
Packit |
98cdb6 |
break;
|
|
Packit |
98cdb6 |
case PROP_CANCEL_BUTTON:
|
|
Packit |
98cdb6 |
g_value_set_object (value, colorsel->cancel_button);
|
|
Packit |
98cdb6 |
break;
|
|
Packit |
98cdb6 |
case PROP_HELP_BUTTON:
|
|
Packit |
98cdb6 |
g_value_set_object (value, colorsel->help_button);
|
|
Packit |
98cdb6 |
break;
|
|
Packit |
98cdb6 |
default:
|
|
Packit |
98cdb6 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
Packit |
98cdb6 |
break;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit |
98cdb6 |
gobject_class->get_property = gtk_color_selection_dialog_get_property;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
g_object_class_install_property (gobject_class,
|
|
Packit |
98cdb6 |
PROP_COLOR_SELECTION,
|
|
Packit |
98cdb6 |
g_param_spec_object ("color-selection",
|
|
Packit |
98cdb6 |
P_("Color Selection"),
|
|
Packit |
98cdb6 |
P_("The color selection embedded in the dialog."),
|
|
Packit |
98cdb6 |
GTK_TYPE_WIDGET,
|
|
Packit |
98cdb6 |
G_PARAM_READABLE));
|
|
Packit |
98cdb6 |
g_object_class_install_property (gobject_class,
|
|
Packit |
98cdb6 |
PROP_OK_BUTTON,
|
|
Packit |
98cdb6 |
g_param_spec_object ("ok-button",
|
|
Packit |
98cdb6 |
P_("OK Button"),
|
|
Packit |
98cdb6 |
P_("The OK button of the dialog."),
|
|
Packit |
98cdb6 |
GTK_TYPE_WIDGET,
|
|
Packit |
98cdb6 |
G_PARAM_READABLE));
|
|
Packit |
98cdb6 |
g_object_class_install_property (gobject_class,
|
|
Packit |
98cdb6 |
PROP_CANCEL_BUTTON,
|
|
Packit |
98cdb6 |
g_param_spec_object ("cancel-button",
|
|
Packit |
98cdb6 |
P_("Cancel Button"),
|
|
Packit |
98cdb6 |
P_("The cancel button of the dialog."),
|
|
Packit |
98cdb6 |
GTK_TYPE_WIDGET,
|
|
Packit |
98cdb6 |
G_PARAM_READABLE));
|
|
Packit |
98cdb6 |
g_object_class_install_property (gobject_class,
|
|
Packit |
98cdb6 |
PROP_HELP_BUTTON,
|
|
Packit |
98cdb6 |
g_param_spec_object ("help-button",
|
|
Packit |
98cdb6 |
P_("Help Button"),
|
|
Packit |
98cdb6 |
P_("The help button of the dialog."),
|
|
Packit |
98cdb6 |
GTK_TYPE_WIDGET,
|
|
Packit |
98cdb6 |
G_PARAM_READABLE));
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkDialog *dialog = GTK_DIALOG (colorseldiag);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_dialog_set_has_separator (dialog, FALSE);
|
|
Packit |
98cdb6 |
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
Packit |
98cdb6 |
gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
|
|
Packit |
98cdb6 |
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
|
|
Packit |
98cdb6 |
gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorseldiag->colorsel = gtk_color_selection_new ();
|
|
Packit |
98cdb6 |
gtk_container_set_border_width (GTK_CONTAINER (colorseldiag->colorsel), 5);
|
|
Packit |
98cdb6 |
gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
|
|
Packit |
98cdb6 |
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
|
|
Packit |
98cdb6 |
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (colorseldiag)->vbox), colorseldiag->colorsel);
|
|
Packit |
98cdb6 |
gtk_widget_show (colorseldiag->colorsel);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorseldiag->cancel_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
|
|
Packit |
98cdb6 |
GTK_STOCK_CANCEL,
|
|
Packit |
98cdb6 |
GTK_RESPONSE_CANCEL);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorseldiag->ok_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
|
|
Packit |
98cdb6 |
GTK_STOCK_OK,
|
|
Packit |
98cdb6 |
GTK_RESPONSE_OK);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_widget_grab_default (colorseldiag->ok_button);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorseldiag->help_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
|
|
Packit |
98cdb6 |
GTK_STOCK_HELP,
|
|
Packit |
98cdb6 |
GTK_RESPONSE_HELP);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_widget_hide (colorseldiag->help_button);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_dialog_set_alternative_button_order (GTK_DIALOG (colorseldiag),
|
|
Packit |
98cdb6 |
GTK_RESPONSE_OK,
|
|
Packit |
98cdb6 |
GTK_RESPONSE_CANCEL,
|
|
Packit |
98cdb6 |
GTK_RESPONSE_HELP,
|
|
Packit |
98cdb6 |
-1);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_window_set_title (GTK_WINDOW (colorseldiag),
|
|
Packit |
98cdb6 |
_("Color Selection"));
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
_gtk_dialog_set_ignore_separator (dialog, TRUE);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
GtkWidget*
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_new (const gchar *title)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkColorSelectionDialog *colorseldiag;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
colorseldiag = g_object_new (GTK_TYPE_COLOR_SELECTION_DIALOG, NULL);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
if (title)
|
|
Packit |
98cdb6 |
gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
gtk_window_set_resizable (GTK_WINDOW (colorseldiag), FALSE);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
return GTK_WIDGET (colorseldiag);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
/**
|
|
Packit |
98cdb6 |
* gtk_color_selection_dialog_get_color_selection:
|
|
Packit |
98cdb6 |
* @colorsel: a #GtkColorSelectionDialog
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* Retrieves the #GtkColorSelection widget embedded in the dialog.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* Returns: (transfer none): the embedded #GtkColorSelection
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* Since: 2.14
|
|
Packit |
98cdb6 |
**/
|
|
Packit |
98cdb6 |
GtkWidget*
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_get_color_selection (GtkColorSelectionDialog *colorsel)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
g_return_val_if_fail (GTK_IS_COLOR_SELECTION_DIALOG (colorsel), NULL);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
return colorsel->colorsel;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_buildable_interface_init (GtkBuildableIface *iface)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
Packit |
98cdb6 |
iface->get_internal_child = gtk_color_selection_dialog_buildable_get_internal_child;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static GObject *
|
|
Packit |
98cdb6 |
gtk_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
|
Packit |
98cdb6 |
GtkBuilder *builder,
|
|
Packit |
98cdb6 |
const gchar *childname)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
if (strcmp(childname, "ok_button") == 0)
|
|
Packit |
98cdb6 |
return G_OBJECT (GTK_COLOR_SELECTION_DIALOG (buildable)->ok_button);
|
|
Packit |
98cdb6 |
else if (strcmp(childname, "cancel_button") == 0)
|
|
Packit |
98cdb6 |
return G_OBJECT (GTK_COLOR_SELECTION_DIALOG (buildable)->cancel_button);
|
|
Packit |
98cdb6 |
else if (strcmp(childname, "help_button") == 0)
|
|
Packit |
98cdb6 |
return G_OBJECT (GTK_COLOR_SELECTION_DIALOG(buildable)->help_button);
|
|
Packit |
98cdb6 |
else if (strcmp(childname, "color_selection") == 0)
|
|
Packit |
98cdb6 |
return G_OBJECT (GTK_COLOR_SELECTION_DIALOG(buildable)->colorsel);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
#define __GTK_COLOR_SELECTION_DIALOG_C__
|
|
Packit |
98cdb6 |
#include "gtkaliasdef.c"
|