mirror of https://github.com/GNOME/gimp.git
app/widgets/gimplanguagestore.[ch] code cleanup.
2008-03-24 Sven Neumann <sven@gimp.org> * app/widgets/gimplanguagestore.[ch] * app/widgets/gimplanguageentry.[ch]: code cleanup. svn path=/trunk/; revision=25211
This commit is contained in:
parent
d94bce20aa
commit
244b50a357
|
@ -1,3 +1,8 @@
|
|||
2008-03-24 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimplanguagestore.[ch]
|
||||
* app/widgets/gimplanguageentry.[ch]: code cleanup.
|
||||
|
||||
2008-03-24 Mukund Sivaraman <muks@mukund.org>
|
||||
|
||||
* plug-ins/common/mng.c: Code cleanups.
|
||||
|
|
|
@ -29,45 +29,95 @@
|
|||
#include "gimplanguageentry.h"
|
||||
|
||||
|
||||
static void gimp_language_entry_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_language_entry_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_MODEL
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_language_entry_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
|
||||
static void gimp_language_entry_finalize (GObject *object);
|
||||
static void gimp_language_entry_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_language_entry_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpLanguageEntry, gimp_language_entry, GTK_TYPE_ENTRY)
|
||||
|
||||
#define parent_class gimp_language_entry_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_language_entry_class_init (GimpLanguageEntryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_language_entry_constructor;
|
||||
object_class->finalize = gimp_language_entry_finalize;
|
||||
object_class->set_property = gimp_language_entry_set_property;
|
||||
object_class->get_property = gimp_language_entry_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_MODEL,
|
||||
g_param_spec_object ("model", NULL, NULL,
|
||||
GIMP_TYPE_LANGUAGE_STORE,
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
GIMP_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_language_entry_init (GimpLanguageEntry *entry)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkEntryCompletion *completion;
|
||||
}
|
||||
|
||||
store = gimp_language_store_new (FALSE);
|
||||
static GObject *
|
||||
gimp_language_entry_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GimpLanguageEntry *entry;
|
||||
GObject *object;
|
||||
|
||||
completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION,
|
||||
"model", store,
|
||||
"text-column", GIMP_LANGUAGE_STORE_LANGUAGE,
|
||||
"inline-completion", TRUE,
|
||||
NULL);
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
entry = GIMP_LANGUAGE_ENTRY (object);
|
||||
|
||||
gtk_entry_set_completion (GTK_ENTRY (entry), completion);
|
||||
if (entry->store)
|
||||
{
|
||||
GtkEntryCompletion *completion;
|
||||
|
||||
g_object_unref (completion);
|
||||
g_object_unref (store);
|
||||
completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION,
|
||||
"model", entry->store,
|
||||
"text-column", GIMP_LANGUAGE_STORE_LANGUAGE,
|
||||
"inline-selection", TRUE,
|
||||
NULL);
|
||||
|
||||
gtk_entry_set_completion (GTK_ENTRY (entry), completion);
|
||||
g_object_unref (completion);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_language_entry_finalize (GObject *object)
|
||||
{
|
||||
GimpLanguageEntry *entry = GIMP_LANGUAGE_ENTRY (object);
|
||||
|
||||
if (entry->store)
|
||||
{
|
||||
g_object_unref (entry->store);
|
||||
entry->store = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -80,6 +130,12 @@ gimp_language_entry_set_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODEL:
|
||||
if (entry->store)
|
||||
g_object_unref (entry->store);
|
||||
entry->store = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -88,14 +144,18 @@ gimp_language_entry_set_property (GObject *object,
|
|||
|
||||
static void
|
||||
gimp_language_entry_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLanguageEntry *entry = GIMP_LANGUAGE_ENTRY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODEL:
|
||||
g_value_set_object (value, entry->store);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -105,5 +165,16 @@ gimp_language_entry_get_property (GObject *object,
|
|||
GtkWidget *
|
||||
gimp_language_entry_new (void)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_LANGUAGE_ENTRY, NULL);
|
||||
GtkWidget *entry;
|
||||
GtkListStore *store;
|
||||
|
||||
store = gimp_language_store_new ();
|
||||
|
||||
entry = g_object_new (GIMP_TYPE_LANGUAGE_ENTRY,
|
||||
"model", store,
|
||||
NULL);
|
||||
|
||||
g_object_unref (store);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ struct _GimpLanguageEntryClass
|
|||
struct _GimpLanguageEntry
|
||||
{
|
||||
GtkEntry parent_instance;
|
||||
|
||||
GtkListStore *store;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,38 +29,11 @@
|
|||
#include "gimplanguagestore-parser.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TRANSLATIONS
|
||||
};
|
||||
|
||||
|
||||
static void gimp_language_store_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_language_store_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
G_DEFINE_TYPE (GimpLanguageStore, gimp_language_store, GTK_TYPE_LIST_STORE)
|
||||
|
||||
static void
|
||||
gimp_language_store_class_init (GimpLanguageStoreClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_language_store_set_property;
|
||||
object_class->get_property = gimp_language_store_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TRANSLATIONS,
|
||||
g_param_spec_boolean ("translations",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -74,52 +47,10 @@ gimp_language_store_init (GimpLanguageStore *store)
|
|||
gimp_language_store_populate (store, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_language_store_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLanguageStore *store = GIMP_LANGUAGE_STORE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSLATIONS:
|
||||
store->translations = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_language_store_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpLanguageStore *store = GIMP_LANGUAGE_STORE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSLATIONS:
|
||||
g_value_set_boolean (value, store->translations);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GtkListStore *
|
||||
gimp_language_store_new (gboolean translations)
|
||||
gimp_language_store_new (void)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_LANGUAGE_STORE,
|
||||
"translations", translations,
|
||||
NULL);
|
||||
return g_object_new (GIMP_TYPE_LANGUAGE_STORE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -133,6 +64,7 @@ gimp_language_store_add (GimpLanguageStore *store,
|
|||
g_return_if_fail (lang != NULL && code != NULL);
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (store), &iter);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
|
||||
GIMP_LANGUAGE_STORE_LANGUAGE, lang,
|
||||
GIMP_LANGUAGE_STORE_ISO_639_1, code,
|
||||
|
|
|
@ -48,14 +48,12 @@ struct _GimpLanguageStoreClass
|
|||
struct _GimpLanguageStore
|
||||
{
|
||||
GtkListStore parent_instance;
|
||||
|
||||
gboolean translations;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_language_store_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkListStore * gimp_language_store_new (gboolean translations);
|
||||
GtkListStore * gimp_language_store_new (void);
|
||||
void gimp_language_store_add (GimpLanguageStore *store,
|
||||
const gchar *lang,
|
||||
const gchar *code);
|
||||
|
|
Loading…
Reference in New Issue