r7433 - mugshot-client/trunk/common/stacker
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7433 - mugshot-client/trunk/common/stacker
- Date: Fri, 18 Apr 2008 12:39:10 -0500 (CDT)
Author: otaylor
Date: 2008-04-18 12:39:10 -0500 (Fri, 18 Apr 2008)
New Revision: 7433
Modified:
mugshot-client/trunk/common/stacker/hippo-block-account-question.c
mugshot-client/trunk/common/stacker/hippo-canvas-block-account-question.c
mugshot-client/trunk/common/stacker/hippo-canvas-block.c
mugshot-client/trunk/common/stacker/hippo-canvas-block.h
Log:
hippo-canvas-block.[ch]: Allow dynamic changes to 'linkify_title'
hippo-block-account-question.c: Remove duplication title property
hippo-canvas-block-account-question.c: Allow an optional title
link, make the more link optional. Special case alignment of
buttons when there is only one button.
Modified: mugshot-client/trunk/common/stacker/hippo-block-account-question.c
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-block-account-question.c 2008-04-17 22:09:55 UTC (rev 7432)
+++ mugshot-client/trunk/common/stacker/hippo-block-account-question.c 2008-04-18 17:39:10 UTC (rev 7433)
@@ -28,7 +28,6 @@
HippoBlock parent;
char *answer;
- char *title;
char *description;
char *more_link;
GSList *buttons;
@@ -54,7 +53,6 @@
enum {
PROP_0,
PROP_ANSWER,
- PROP_TITLE,
PROP_DESCRIPTION,
PROP_BUTTONS,
PROP_MORE_LINK
@@ -90,14 +88,6 @@
G_PARAM_READABLE));
g_object_class_install_property(object_class,
- PROP_TITLE,
- g_param_spec_string("title",
- _("Title"),
- _("Main heading of the question"),
- NULL,
- G_PARAM_READABLE));
-
- g_object_class_install_property(object_class,
PROP_DESCRIPTION,
g_param_spec_string("description",
_("Description"),
@@ -137,20 +127,6 @@
}
static void
-set_title(HippoBlockAccountQuestion *block_account_question,
- const char *title)
-{
- if (title == block_account_question->title ||
- (title && block_account_question->title && strcmp(title, block_account_question->title) == 0))
- return;
-
- g_free(block_account_question->title);
- block_account_question->title = g_strdup(title);
-
- g_object_notify(G_OBJECT(block_account_question), "title");
-}
-
-static void
set_description(HippoBlockAccountQuestion *block_account_question,
const char *description)
{
@@ -199,7 +175,6 @@
HippoBlockAccountQuestion *block_account_question = HIPPO_BLOCK_ACCOUNT_QUESTION(object);
set_answer(block_account_question, NULL);
- set_title(block_account_question, NULL);
set_description(block_account_question, NULL);
set_buttons(block_account_question, NULL);
set_more_link(block_account_question, NULL);
@@ -234,9 +209,6 @@
case PROP_ANSWER:
g_value_set_string(value, block_account_question->answer);
break;
- case PROP_TITLE:
- g_value_set_string(value, block_account_question->title);
- break;
case PROP_DESCRIPTION:
g_value_set_string(value, block_account_question->description);
break;
@@ -257,7 +229,6 @@
hippo_block_account_question_update (HippoBlock *block)
{
HippoBlockAccountQuestion *block_account_question = HIPPO_BLOCK_ACCOUNT_QUESTION(block);
- const char *title = NULL;
const char *description = NULL;
const char *more_link = NULL;
const char *answer = NULL;
@@ -268,7 +239,6 @@
HIPPO_BLOCK_CLASS(hippo_block_account_question_parent_class)->update(block);
ddm_data_resource_get(block->resource,
- "title", DDM_DATA_STRING, &title,
"description", DDM_DATA_STRING, &description,
"moreLink", DDM_DATA_URL, &more_link,
"answer", DDM_DATA_STRING, &answer,
@@ -293,7 +263,6 @@
buttons = g_slist_reverse(buttons);
set_answer(block_account_question, answer);
- set_title(block_account_question, title);
set_description(block_account_question, description);
set_more_link(block_account_question, more_link);
hippo_block_set_pinned(block, answer == NULL);
Modified: mugshot-client/trunk/common/stacker/hippo-canvas-block-account-question.c
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-canvas-block-account-question.c 2008-04-17 22:09:55 UTC (rev 7432)
+++ mugshot-client/trunk/common/stacker/hippo-canvas-block-account-question.c 2008-04-18 17:39:10 UTC (rev 7433)
@@ -31,6 +31,7 @@
HippoCanvasBox *parent_box);
static void hippo_canvas_block_account_question_set_block (HippoCanvasBlock *canvas_block,
HippoBlock *block);
+static void hippo_canvas_block_account_question_title_activated (HippoCanvasBlock *canvas_block);
static void hippo_canvas_block_account_question_expand (HippoCanvasBlock *canvas_block);
static void hippo_canvas_block_account_question_unexpand (HippoCanvasBlock *canvas_block);
@@ -76,9 +77,9 @@
block->required_type = HIPPO_BLOCK_TYPE_ACCOUNT_QUESTION;
block->expandable = FALSE;
block->message_block = TRUE;
- block->linkify_title = FALSE;
block->skip_lock = TRUE;
block->skip_standard_right = TRUE;
+ hippo_canvas_block_set_linkify_title(block, FALSE);
}
static HippoCanvasItemIface *item_parent_class;
@@ -104,6 +105,7 @@
canvas_block_class->append_content_items = hippo_canvas_block_account_question_append_content_items;
canvas_block_class->append_right_items = hippo_canvas_block_account_question_append_right_items;
canvas_block_class->set_block = hippo_canvas_block_account_question_set_block;
+ canvas_block_class->title_activated = hippo_canvas_block_account_question_title_activated;
canvas_block_class->expand = hippo_canvas_block_account_question_expand;
canvas_block_class->unexpand = hippo_canvas_block_account_question_unexpand;
}
@@ -190,8 +192,8 @@
block_account_question->buttons_box = g_object_new(HIPPO_TYPE_CANVAS_BOX,
"orientation", HIPPO_ORIENTATION_HORIZONTAL,
- "xalign", HIPPO_ALIGNMENT_CENTER,
"spacing", 20,
+ "padding-top", 5,
NULL);
hippo_canvas_box_append(parent_box, HIPPO_CANVAS_ITEM(block_account_question->buttons_box), 0);
@@ -242,22 +244,46 @@
}
static void
-on_title_changed(HippoBlock *block,
- GParamSpec *arg, /* null when first calling this */
- HippoCanvasBlockAccountQuestion *block_account_question)
+update_title(HippoCanvasBlockAccountQuestion *block_account_question)
{
+ HippoCanvasBlock *canvas_block = HIPPO_CANVAS_BLOCK(block_account_question);
+
+ char *answer = NULL;
char *title = NULL;
-
- g_object_get(block,
- "title", &title,
- NULL);
+ char *title_link = NULL;
- hippo_canvas_block_set_title(HIPPO_CANVAS_BLOCK(block_account_question), title, NULL, FALSE);
+ if (canvas_block->block)
+ g_object_get(canvas_block->block,
+ "title", &title,
+ "title-link", &title_link,
+ "answer", &answer,
+ NULL);
+ hippo_canvas_block_set_title(canvas_block, title, NULL, answer != NULL);
+ hippo_canvas_block_set_linkify_title(canvas_block, title_link != NULL);
+
+ g_free(answer);
g_free(title);
+ g_free(title_link);
}
static void
+on_title_changed(HippoBlock *block,
+ GParamSpec *arg, /* null when first calling this */
+ HippoCanvasBlockAccountQuestion *block_account_question)
+{
+ update_title(block_account_question);
+}
+
+static void
+on_title_link_changed(HippoBlock *block,
+ GParamSpec *arg, /* null when first calling this */
+ HippoCanvasBlockAccountQuestion *block_account_question)
+{
+ update_title(block_account_question);
+}
+
+static void
on_description_changed(HippoBlock *block,
GParamSpec *arg, /* null when first calling this */
HippoCanvasBlockAccountQuestion *block_account_question)
@@ -288,6 +314,16 @@
NULL);
disconnect_buttons(block_account_question);
+
+ hippo_canvas_item_set_visible(HIPPO_CANVAS_ITEM(block_account_question->buttons_box),
+ buttons != NULL);
+
+ /* It looks weird to center only one button, but it looks a bit weird to left-align a set of
+ * buttons, so make the alignment conditional.
+ */
+ g_object_set(G_OBJECT(block_account_question->buttons_box),
+ "xalign", (buttons && buttons->next) ? HIPPO_ALIGNMENT_CENTER : HIPPO_ALIGNMENT_START,
+ NULL);
for (l = buttons; l; l = l->next) {
HippoAccountQuestionButton *button = l->data;
@@ -301,10 +337,10 @@
g_object_set_data_full(G_OBJECT(button_item),
"response", g_strdup(response),
(GDestroyNotify)g_free);
- g_signal_connect(button_item, "activated",
- G_CALLBACK(on_button_activated), block_account_question);
-
- hippo_canvas_box_append(block_account_question->buttons_box, button_item, 0);
+ g_signal_connect(button_item, "activated",
+ G_CALLBACK(on_button_activated), block_account_question);
+
+ hippo_canvas_box_append(block_account_question->buttons_box, button_item, 0);
}
}
@@ -323,6 +359,8 @@
"url", more_link,
NULL);
+ hippo_canvas_item_set_visible(block_account_question->read_more_item, more_link != NULL);
+
g_free(more_link);
}
@@ -341,6 +379,8 @@
hippo_canvas_item_set_visible(block_account_question->timestamp_item, answer != NULL);
g_free(answer);
+
+ update_title(block_account_question);
}
static void
@@ -375,6 +415,9 @@
G_CALLBACK(on_title_changed),
canvas_block);
g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
+ G_CALLBACK(on_title_link_changed),
+ canvas_block);
+ g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
G_CALLBACK(on_description_changed),
canvas_block);
g_signal_handlers_disconnect_by_func(G_OBJECT(canvas_block->block),
@@ -398,6 +441,8 @@
if (canvas_block->block != NULL) {
g_signal_connect(canvas_block->block, "notify::title",
G_CALLBACK(on_title_changed), block_account_question);
+ g_signal_connect(canvas_block->block, "notify::title-link",
+ G_CALLBACK(on_title_link_changed), block_account_question);
g_signal_connect(canvas_block->block, "notify::description",
G_CALLBACK(on_description_changed), block_account_question);
g_signal_connect(canvas_block->block, "notify::buttons",
@@ -409,7 +454,7 @@
g_signal_connect(canvas_block->block, "notify::timestamp",
G_CALLBACK(on_timestamp_changed), block_account_question);
- on_title_changed(block, NULL, block_account_question);
+ update_title(block_account_question);
on_description_changed(block, NULL, block_account_question);
on_buttons_changed(block, NULL, block_account_question);
on_more_link_changed(block, NULL, block_account_question);
@@ -419,6 +464,23 @@
}
static void
+hippo_canvas_block_account_question_title_activated(HippoCanvasBlock *canvas_block)
+{
+ HippoActions *actions = hippo_canvas_block_get_actions(canvas_block);
+ char *title_link = NULL;
+
+ if (canvas_block->block)
+ g_object_get(canvas_block->block,
+ "title-link", &title_link,
+ NULL);
+
+ if (title_link != NULL) {
+ hippo_actions_open_url(actions, title_link);
+ g_free(title_link);
+ }
+}
+
+static void
hippo_canvas_block_account_question_expand(HippoCanvasBlock *canvas_block)
{
HippoCanvasBlockAccountQuestion *block_account_question = HIPPO_CANVAS_BLOCK_ACCOUNT_QUESTION(canvas_block);
Modified: mugshot-client/trunk/common/stacker/hippo-canvas-block.c
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-canvas-block.c 2008-04-17 22:09:55 UTC (rev 7432)
+++ mugshot-client/trunk/common/stacker/hippo-canvas-block.c 2008-04-18 17:39:10 UTC (rev 7433)
@@ -385,6 +385,45 @@
#define PRELIGHT_GRADIENT_END 0xffffbbff
#define MESSAGE_BLOCK_COLOR 0xffffddff
+static void
+update_title_item(HippoCanvasBlock *block)
+{
+ char *old_title = NULL;
+
+ if (block->title_item) {
+ g_object_get(G_OBJECT(block->title_item),
+ "text", &old_title,
+ NULL);
+ hippo_canvas_item_destroy(block->title_item);
+ block->title_item = NULL;
+ }
+
+ if (block->linkify_title) {
+ block->title_item = g_object_new(HIPPO_TYPE_CANVAS_LINK,
+ "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
+ "xalign", HIPPO_ALIGNMENT_START,
+ "yalign", HIPPO_ALIGNMENT_START,
+ NULL);
+ g_signal_connect(G_OBJECT(block->title_item), "activated",
+ G_CALLBACK(on_title_activated), block);
+ } else {
+ block->title_item = g_object_new(HIPPO_TYPE_CANVAS_TEXT,
+ "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
+ "xalign", HIPPO_ALIGNMENT_START,
+ "yalign", HIPPO_ALIGNMENT_START,
+ NULL);
+ }
+
+ if (old_title) {
+ g_object_set(G_OBJECT(block->title_item),
+ "text", old_title,
+ NULL);
+ g_free(old_title);
+ }
+
+ hippo_canvas_box_append(block->heading_box, block->title_item, 0);
+}
+
static GObject*
hippo_canvas_block_constructor (GType type,
guint n_construct_properties,
@@ -594,26 +633,7 @@
hippo_canvas_box_append(box, block->heading_text_item, 0);
#endif
- if (block->linkify_title) {
- block->title_link_item = g_object_new(HIPPO_TYPE_CANVAS_LINK,
- "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
- "xalign", HIPPO_ALIGNMENT_START,
- "yalign", HIPPO_ALIGNMENT_START,
- "text", NULL,
- NULL);
- g_signal_connect(G_OBJECT(block->title_link_item), "activated",
- G_CALLBACK(on_title_activated), block);
- } else {
- block->title_link_item = g_object_new(HIPPO_TYPE_CANVAS_TEXT,
- "size-mode", HIPPO_CANVAS_SIZE_ELLIPSIZE_END,
- "xalign", HIPPO_ALIGNMENT_START,
- "yalign", HIPPO_ALIGNMENT_START,
- "text", NULL,
- NULL);
- }
-
- hippo_canvas_box_append(box, block->title_link_item, 0);
-
+ update_title_item(block);
}
if (klass->append_content_items)
@@ -1067,7 +1087,7 @@
return;
/* keep in mind that title and tooltip may be NULL */
- g_object_set(G_OBJECT(canvas_block->title_link_item),
+ g_object_set(G_OBJECT(canvas_block->title_item),
"text", text,
"tooltip", tooltip,
canvas_block->linkify_title ? "visited" : NULL, visited,
@@ -1075,6 +1095,19 @@
}
void
+hippo_canvas_block_set_linkify_title(HippoCanvasBlock *canvas_block,
+ gboolean linkify_title)
+{
+ linkify_title = linkify_title != FALSE;
+
+ if (canvas_block->linkify_title != linkify_title) {
+ canvas_block->linkify_title = linkify_title;
+ if (canvas_block->title_item) /* we might not be constructed yet */
+ update_title_item(canvas_block);
+ }
+}
+
+void
hippo_canvas_block_set_sender(HippoCanvasBlock *canvas_block,
HippoEntity *entity)
{
Modified: mugshot-client/trunk/common/stacker/hippo-canvas-block.h
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-canvas-block.h 2008-04-17 22:09:55 UTC (rev 7432)
+++ mugshot-client/trunk/common/stacker/hippo-canvas-block.h 2008-04-18 17:39:10 UTC (rev 7433)
@@ -44,7 +44,7 @@
HippoCanvasBox *heading_box;
HippoCanvasItem *heading_icon_item;
HippoCanvasItem *heading_lock_item;
- HippoCanvasItem *title_link_item;
+ HippoCanvasItem *title_item;
HippoCanvasItem *headshot_item;
HippoCanvasItem *name_item;
HippoCanvasItem *toggle_hush_link;
@@ -101,6 +101,9 @@
const char *tooltip,
gboolean visited);
+void hippo_canvas_block_set_linkify_title (HippoCanvasBlock *canvas_block,
+ gboolean linkify_title);
+
void hippo_canvas_block_set_expanded(HippoCanvasBlock *canvas_block,
gboolean value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]