[recipes] Set nick name from preferences
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Set nick name from preferences
- Date: Wed, 14 Dec 2016 11:16:02 +0000 (UTC)
commit 6a4af8ceff45f184c1a8affd6ad9221b23328041
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 14 06:05:52 2016 -0500
Set nick name from preferences
And do away with the entry for the username. No real need
to let the user set this internally-used ID.
src/gr-preferences.c | 20 ++++++++++++--------
src/gr-preferences.ui | 28 ++++++++++++++--------------
2 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/src/gr-preferences.c b/src/gr-preferences.c
index cd5d969..a624f26 100644
--- a/src/gr-preferences.c
+++ b/src/gr-preferences.c
@@ -34,8 +34,8 @@ struct _GrPreferences
{
GtkDialog parent_instance;
- GtkWidget *name;
GtkWidget *fullname;
+ GtkWidget *name;
GtkWidget *description;
GtkWidget *image;
GtkWidget *error_revealer;
@@ -122,12 +122,17 @@ save_preferences (GrPreferences *self,
g_autoptr(GrChef) chef = NULL;
GrRecipeStore *store;
const char *name;
+ const char *nickname;
const char *fullname;
g_autofree char *description = NULL;
GtkTextBuffer *buffer;
GtkTextIter start, end;
- name = gtk_entry_get_text (GTK_ENTRY (self->name));
+ store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
+
+ name = gr_recipe_store_get_user_key (store);
+
+ nickname = gtk_entry_get_text (GTK_ENTRY (self->name));
fullname = gtk_entry_get_text (GTK_ENTRY (self->fullname));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->description));
gtk_text_buffer_get_bounds (buffer, &start, &end);
@@ -136,12 +141,11 @@ save_preferences (GrPreferences *self,
chef = g_object_new (GR_TYPE_CHEF,
"name", name,
"fullname", fullname,
+ "nickname", nickname,
"description", description,
"image-path", self->image_path,
NULL);
- store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
-
return gr_recipe_store_update_user (store, chef, error);
}
@@ -171,23 +175,23 @@ gr_preferences_init (GrPreferences *self)
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
name = gr_recipe_store_get_user_key (store);
- gtk_entry_set_text (GTK_ENTRY (self->name), name ? name : "");
if (name != NULL && name[0] != '\0')
chef = gr_recipe_store_get_chef (store, name);
if (chef) {
const char *fullname;
+ const char *nickname;
const char *description;
const char *image_path;
- name = gr_chef_get_name (chef);
fullname = gr_chef_get_fullname (chef);
+ nickname = gr_chef_get_nickname (chef);
description = gr_chef_get_description (chef);
image_path = gr_chef_get_image (chef);
- gtk_entry_set_text (GTK_ENTRY (self->name), name ? name : "");
gtk_entry_set_text (GTK_ENTRY (self->fullname), fullname ? fullname : "");
+ gtk_entry_set_text (GTK_ENTRY (self->name), nickname ? nickname : "");
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->description)),
description ? description : "", -1);
@@ -209,8 +213,8 @@ gr_preferences_class_init (GrPreferencesClass *klass)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
"/org/gnome/Recipes/gr-preferences.ui");
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, name);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, fullname);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, name);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, description);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, image);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrPreferences, error_revealer);
diff --git a/src/gr-preferences.ui b/src/gr-preferences.ui
index c04d15b..d451250 100644
--- a/src/gr-preferences.ui
+++ b/src/gr-preferences.ui
@@ -93,45 +93,45 @@
<child>
<object class="GtkLabel">
<property name="visible">1</property>
- <property name="label" translatable="yes">_Short Name:</property>
+ <property name="label" translatable="yes">_Name:</property>
<property name="use-underline">1</property>
- <property name="mnemonic-widget">name</property>
+ <property name="mnemonic-widget">fullname</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="name">
+ <object class="GtkEntry" id="fullname">
<property name="visible">1</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">1</property>
- <property name="label" translatable="yes">_Name:</property>
+ <property name="label" translatable="yes">_Short Name:</property>
<property name="use-underline">1</property>
- <property name="mnemonic-widget">fullname</property>
+ <property name="mnemonic-widget">name</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="fullname">
+ <object class="GtkEntry" id="name">
<property name="visible">1</property>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -144,7 +144,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -160,7 +160,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -173,7 +173,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -189,7 +189,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]