Skip to content

Commit 41899ec

Browse files
Show open button on search tile after install (#1319)
Users are probably more interested in running the app they just installed than removing it, so it now shows an "Open" button until the search is changed or something.
1 parent 655b462 commit 41899ec

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

src/bz-rich-app-tile.blp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ template $BzRichAppTile: $BzListTile {
160160
}
161161

162162
Button {
163-
visible: bind $invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable) as <bool>) as <bool>;
164-
sensitive: bind $invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable-and-available) as <bool>) as <bool>;
163+
visible: bind $logical_and($invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable) as <bool>) as <bool>, template.removable-at-start) as <bool>;
164+
sensitive: bind $logical_and($invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable-and-available) as <bool>) as <bool>, template.removable-at-start) as <bool>;
165165

166166
styles [
167167
"circular"
@@ -173,6 +173,19 @@ template $BzRichAppTile: $BzListTile {
173173
valign: center;
174174
clicked => $remove_button_clicked_cb(template);
175175
}
176+
177+
Button {
178+
visible: bind $logical_and($invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable) as <bool>) as <bool>, $invert_boolean(template.removable-at-start) as <bool>) as <bool>;
179+
sensitive: bind $logical_and($invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable-and-available) as <bool>) as <bool>, $invert_boolean(template.removable-at-start) as <bool>) as <bool>;
180+
181+
styles [
182+
"medium-pill",
183+
]
184+
185+
label: _("Open");
186+
valign: center;
187+
clicked => $run_button_clicked_cb(template);
188+
}
176189
}
177190
}
178191
};

src/bz-rich-app-tile.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct _BzRichAppTile
3232
BzEntryGroup *group;
3333
BzEntry *ui_entry;
3434
DexFuture *ui_entry_resolve;
35+
gboolean removable_at_start;
3536

3637
GtkWidget *picture_box;
3738
};
@@ -43,12 +44,12 @@ enum
4344
PROP_0,
4445
PROP_GROUP,
4546
PROP_UI_ENTRY,
47+
PROP_REMOVABLE_AT_START,
4648
LAST_PROP
4749
};
4850

4951
static GParamSpec *props[LAST_PROP] = { 0 };
5052

51-
5253
static void update_ui_entry (BzRichAppTile *self);
5354

5455
static DexFuture *
@@ -122,6 +123,9 @@ bz_rich_app_tile_get_property (GObject *object,
122123
case PROP_UI_ENTRY:
123124
g_value_set_object (value, self->ui_entry);
124125
break;
126+
case PROP_REMOVABLE_AT_START:
127+
g_value_set_boolean (value, self->removable_at_start);
128+
break;
125129
default:
126130
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
127131
}
@@ -140,6 +144,7 @@ bz_rich_app_tile_set_property (GObject *object,
140144
bz_rich_app_tile_set_group (self, g_value_get_object (value));
141145
break;
142146
case PROP_UI_ENTRY:
147+
case PROP_REMOVABLE_AT_START:
143148
default:
144149
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
145150
}
@@ -190,6 +195,14 @@ remove_button_clicked_cb (BzRichAppTile *self,
190195
bz_entry_group_get_id (self->group), FALSE);
191196
}
192197

198+
static void
199+
run_button_clicked_cb (BzRichAppTile *self,
200+
GtkButton *button)
201+
{
202+
gtk_widget_activate_action (GTK_WIDGET (self), "window.launch-group", "s",
203+
bz_entry_group_get_id (self->group));
204+
}
205+
193206
static void
194207
bz_rich_app_tile_class_init (BzRichAppTileClass *klass)
195208
{
@@ -214,6 +227,13 @@ bz_rich_app_tile_class_init (BzRichAppTileClass *klass)
214227
BZ_TYPE_ENTRY,
215228
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
216229

230+
props[PROP_REMOVABLE_AT_START] =
231+
g_param_spec_boolean (
232+
"removable-at-start",
233+
NULL, NULL,
234+
FALSE,
235+
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
236+
217237
g_object_class_install_properties (object_class, LAST_PROP, props);
218238

219239
g_type_ensure (BZ_TYPE_LIST_TILE);
@@ -227,6 +247,7 @@ bz_rich_app_tile_class_init (BzRichAppTileClass *klass)
227247
gtk_widget_class_bind_template_callback (widget_class, logical_and);
228248
gtk_widget_class_bind_template_callback (widget_class, install_button_clicked_cb);
229249
gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked_cb);
250+
gtk_widget_class_bind_template_callback (widget_class, run_button_clicked_cb);
230251
gtk_widget_class_bind_template_child (widget_class, BzRichAppTile, picture_box);
231252

232253
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
@@ -255,9 +276,10 @@ void
255276
bz_rich_app_tile_set_group (BzRichAppTile *self,
256277
BzEntryGroup *group)
257278
{
258-
const char *title = NULL;
259-
gboolean verified = FALSE;
260-
g_autofree char *label = NULL;
279+
const char *title = NULL;
280+
gboolean verified = FALSE;
281+
gboolean removable_at_start = FALSE;
282+
g_autofree char *label = NULL;
261283

262284
g_return_if_fail (BZ_IS_RICH_APP_TILE (self));
263285

@@ -267,12 +289,19 @@ bz_rich_app_tile_set_group (BzRichAppTile *self,
267289
{
268290
self->group = g_object_ref (group);
269291

270-
title = bz_entry_group_get_title (self->group);
292+
title = bz_entry_group_get_title (self->group);
271293
verified = bz_entry_group_get_is_verified (self->group);
272294

295+
removable_at_start = bz_entry_group_get_removable (self->group) != 0;
296+
if (self->removable_at_start != removable_at_start)
297+
{
298+
self->removable_at_start = removable_at_start;
299+
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_REMOVABLE_AT_START]);
300+
}
301+
273302
if (verified)
274303
{
275-
label = g_strdup_printf ("%s, %s", title, _("Verified"));
304+
label = g_strdup_printf ("%s, %s", title, _ ("Verified"));
276305
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
277306
GTK_ACCESSIBLE_PROPERTY_LABEL, label,
278307
-1);

0 commit comments

Comments
 (0)