app: move GimpControllerCategory to its own files
This commit is contained in:
parent
e39650d47c
commit
905ccf2ea9
7 changed files with 140 additions and 88 deletions
|
|
@ -213,5 +213,7 @@ void gimp_viewable_set_expanded (GimpViewable *viewable,
|
|||
gboolean gimp_viewable_is_ancestor (GimpViewable *ancestor,
|
||||
GimpViewable *descendant);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GimpViewable, g_object_unref);
|
||||
|
||||
|
||||
#endif /* __GIMP_VIEWABLE_H__ */
|
||||
|
|
|
|||
89
app/widgets/gimpcontrollercategory.c
Normal file
89
app/widgets/gimpcontrollercategory.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
|
||||
#include "libgimpwidgets/gimpcontroller.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpcontrollercategory.h"
|
||||
|
||||
|
||||
/**
|
||||
* GimpControllerCategory:
|
||||
*
|
||||
* A helper object to list types/categories of controllers
|
||||
*/
|
||||
|
||||
struct _GimpControllerCategory {
|
||||
GObject parent_instance;
|
||||
|
||||
const gchar *name;
|
||||
const gchar *icon_name;
|
||||
GType gtype;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GimpControllerCategory, gimp_controller_category,
|
||||
GIMP_TYPE_VIEWABLE)
|
||||
|
||||
|
||||
static void
|
||||
gimp_controller_category_init (GimpControllerCategory *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_controller_category_class_init (GimpControllerCategoryClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
GimpControllerCategory *
|
||||
gimp_controller_category_new (GType gtype)
|
||||
{
|
||||
GimpControllerClass *controller_class;
|
||||
GimpControllerCategory *category;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (gtype, GIMP_TYPE_CONTROLLER), NULL);
|
||||
|
||||
controller_class = g_type_class_ref (gtype);
|
||||
|
||||
category = g_object_new (GIMP_TYPE_CONTROLLER_CATEGORY,
|
||||
"name", controller_class->name,
|
||||
"icon-name", controller_class->icon_name,
|
||||
NULL);
|
||||
|
||||
category->gtype = gtype;
|
||||
|
||||
g_type_class_unref (controller_class);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_controller_category_get_gtype (GimpControllerCategory *self)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTROLLER_CATEGORY (self), G_TYPE_INVALID);
|
||||
|
||||
return self->gtype;
|
||||
}
|
||||
37
app/widgets/gimpcontrollercategory.h
Normal file
37
app/widgets/gimpcontrollercategory.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_CONTROLLER_CATEGORY_H__
|
||||
#define __GIMP_CONTROLLER_CATEGORY_H__
|
||||
|
||||
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_CONTROLLER_CATEGORY (gimp_controller_category_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GimpControllerCategory,
|
||||
gimp_controller_category,
|
||||
GIMP, CONTROLLER_CATEGORY,
|
||||
GimpViewable)
|
||||
|
||||
|
||||
GimpControllerCategory * gimp_controller_category_new (GType gtype);
|
||||
|
||||
GType gimp_controller_category_get_gtype (GimpControllerCategory *self);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTROLLER_CATEGORY_H__ */
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "gimpcontainertreeview.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpcontrollercategory.h"
|
||||
#include "gimpcontrollereditor.h"
|
||||
#include "gimpcontrollerlist.h"
|
||||
#include "gimpcontrollerinfo.h"
|
||||
|
|
@ -142,7 +143,7 @@ gimp_controller_list_class_init (GimpControllerListClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_controller_list_init (GimpControllerList *list)
|
||||
gimp_controller_list_init (GimpControllerList *list)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *sw;
|
||||
|
|
@ -373,21 +374,21 @@ gimp_controller_create_row_for_category (gpointer item,
|
|||
GtkWidget *row, *box, *icon, *label;
|
||||
|
||||
row = gtk_list_box_row_new ();
|
||||
gtk_widget_set_visible (row, TRUE);
|
||||
g_object_set_data (G_OBJECT (row), "category", category);
|
||||
gtk_widget_set_visible (row, TRUE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_widget_set_visible (box, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (row), box);
|
||||
gtk_widget_set_visible (box, TRUE);
|
||||
|
||||
icon_name = gimp_controller_category_get_icon_name (category);
|
||||
icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (category));
|
||||
icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_set_visible (icon, TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0);
|
||||
gtk_widget_set_visible (icon, TRUE);
|
||||
|
||||
label = gtk_label_new (gimp_controller_category_get_name (category));
|
||||
gtk_widget_set_visible (label, TRUE);
|
||||
label = gtk_label_new (gimp_object_get_name (category));
|
||||
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_widget_set_visible (label, TRUE);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
|
@ -439,7 +440,7 @@ gimp_controller_list_category_row_selected (GtkListBox *self,
|
|||
{
|
||||
tip =
|
||||
g_strdup_printf (_("Add '%s' to the list of active controllers"),
|
||||
gimp_controller_category_get_name (category));
|
||||
gimp_object_get_name (category));
|
||||
gtk_widget_set_sensitive (list->add_button, TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "gimpaction.h"
|
||||
#include "gimpactiongroup.h"
|
||||
#include "gimpcontrollercategory.h"
|
||||
#include "gimpcontrollerinfo.h"
|
||||
#include "gimpcontrollers.h"
|
||||
#include "gimpcontrollerkeyboard.h"
|
||||
|
|
@ -70,8 +71,7 @@ static gboolean gimp_controller_manager_event_mapped (GimpControllerInfo
|
|||
const GimpControllerEvent *event,
|
||||
const gchar *action_name,
|
||||
GimpControllerManager *manager);
|
||||
static GimpControllerCategory *
|
||||
gimp_controller_category_new (GType gtype);
|
||||
|
||||
static void g_list_model_iface_init (GListModelInterface *iface);
|
||||
|
||||
|
||||
|
|
@ -481,70 +481,3 @@ g_list_model_iface_init (GListModelInterface *iface)
|
|||
iface->get_n_items = gimp_controller_manager_get_n_items;
|
||||
iface->get_item = gimp_controller_manager_get_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* GimpControllerCategory:
|
||||
*
|
||||
* A helper object to list types/categories of controllers
|
||||
*/
|
||||
|
||||
struct _GimpControllerCategory {
|
||||
GObject parent_instance;
|
||||
|
||||
const gchar *name;
|
||||
const gchar *icon_name;
|
||||
GType gtype;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GimpControllerCategory, gimp_controller_category, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gimp_controller_category_init (GimpControllerCategory *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_controller_category_class_init (GimpControllerCategoryClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static GimpControllerCategory *
|
||||
gimp_controller_category_new (GType gtype)
|
||||
{
|
||||
GimpControllerClass *controller_class;
|
||||
GimpControllerCategory *category;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (gtype, GIMP_TYPE_CONTROLLER), NULL);
|
||||
|
||||
controller_class = g_type_class_ref (gtype);
|
||||
|
||||
category = g_object_new (GIMP_TYPE_CONTROLLER_CATEGORY, NULL);
|
||||
category->name = controller_class->name;
|
||||
category->icon_name = controller_class->icon_name;
|
||||
category->gtype = gtype;
|
||||
|
||||
g_type_class_unref (controller_class);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_controller_category_get_name (GimpControllerCategory *self)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTROLLER_CATEGORY (self), NULL);
|
||||
return self->name;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_controller_category_get_icon_name (GimpControllerCategory *self)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTROLLER_CATEGORY (self), NULL);
|
||||
return self->icon_name;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_controller_category_get_gtype (GimpControllerCategory *self)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTROLLER_CATEGORY (self), G_TYPE_INVALID);
|
||||
return self->gtype;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,6 @@ G_DECLARE_FINAL_TYPE (GimpControllerManager,
|
|||
GIMP, CONTROLLER_MANAGER,
|
||||
GObject)
|
||||
|
||||
#define GIMP_TYPE_CONTROLLER_CATEGORY (gimp_controller_category_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GimpControllerCategory,
|
||||
gimp_controller_category,
|
||||
GIMP, CONTROLLER_CATEGORY,
|
||||
GObject)
|
||||
|
||||
|
||||
GimpControllerManager * gimp_get_controller_manager (Gimp *gimp);
|
||||
|
||||
|
|
@ -63,9 +57,4 @@ GimpController * gimp_controller_manager_get_keyboard (GimpControllerMa
|
|||
GListModel * gimp_controller_manager_get_categories (GimpControllerManager *self);
|
||||
|
||||
|
||||
const gchar * gimp_controller_category_get_name (GimpControllerCategory *self);
|
||||
const gchar * gimp_controller_category_get_icon_name (GimpControllerCategory *self);
|
||||
GType gimp_controller_category_get_gtype (GimpControllerCategory *self);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTROLLERS_H__ */
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ libappwidgets_sources = [
|
|||
'gimpcontainerview-utils.c',
|
||||
'gimpcontainerview.c',
|
||||
'gimpcontrollereditor.c',
|
||||
'gimpcontrollercategory.c',
|
||||
'gimpcontrollerinfo.c',
|
||||
'gimpcontrollerkeyboard.c',
|
||||
'gimpcontrollerlist.c',
|
||||
|
|
|
|||
Loading…
Reference in a new issue