open-with-widget: add a "Show more applications" button
So that we don't always show them all unconditionally in HEADINGS mode.
This commit is contained in:
@ -45,9 +45,12 @@ struct _GtkOpenWithWidgetPrivate {
|
|||||||
GtkOpenWithWidgetShowMode show_mode;
|
GtkOpenWithWidgetShowMode show_mode;
|
||||||
|
|
||||||
GtkWidget *program_list;
|
GtkWidget *program_list;
|
||||||
|
GtkWidget *show_more;
|
||||||
GtkListStore *program_list_store;
|
GtkListStore *program_list_store;
|
||||||
|
|
||||||
GtkCellRenderer *padding_renderer;
|
GtkCellRenderer *padding_renderer;
|
||||||
|
|
||||||
|
gboolean show_more_clicked;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -500,7 +503,7 @@ gtk_open_with_widget_real_add_items (GtkOpenWithWidget *self)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
show_all = TRUE;
|
show_all = self->priv->show_more_clicked;
|
||||||
show_headings = TRUE;
|
show_headings = TRUE;
|
||||||
show_recommended = TRUE;
|
show_recommended = TRUE;
|
||||||
}
|
}
|
||||||
@ -769,6 +772,32 @@ gtk_open_with_widget_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_more_button_clicked_cb (GtkButton *button,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkOpenWithWidget *self = user_data;
|
||||||
|
|
||||||
|
self->priv->show_more_clicked = TRUE;
|
||||||
|
gtk_widget_hide (GTK_WIDGET (button));
|
||||||
|
|
||||||
|
_gtk_open_with_widget_refilter (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_open_with_widget_ensure_show_more_button (GtkOpenWithWidget *self)
|
||||||
|
{
|
||||||
|
if (self->priv->show_mode == GTK_OPEN_WITH_WIDGET_SHOW_MODE_HEADINGS)
|
||||||
|
{
|
||||||
|
if (!self->priv->show_more_clicked)
|
||||||
|
gtk_widget_show (self->priv->show_more);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_widget_hide (self->priv->show_more);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_open_with_widget_constructed (GObject *object)
|
gtk_open_with_widget_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -779,6 +808,7 @@ gtk_open_with_widget_constructed (GObject *object)
|
|||||||
if (G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed != NULL)
|
if (G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed != NULL)
|
||||||
G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed (object);
|
G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
gtk_open_with_widget_ensure_show_more_button (self);
|
||||||
gtk_open_with_widget_add_items (self);
|
gtk_open_with_widget_add_items (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,11 +892,12 @@ gtk_open_with_widget_class_init (GtkOpenWithWidgetClass *klass)
|
|||||||
static void
|
static void
|
||||||
gtk_open_with_widget_init (GtkOpenWithWidget *self)
|
gtk_open_with_widget_init (GtkOpenWithWidget *self)
|
||||||
{
|
{
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window, *button, *w;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_OPEN_WITH_WIDGET,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_OPEN_WITH_WIDGET,
|
||||||
GtkOpenWithWidgetPrivate);
|
GtkOpenWithWidgetPrivate);
|
||||||
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (self), 5);
|
gtk_container_set_border_width (GTK_CONTAINER (self), 5);
|
||||||
|
|
||||||
@ -899,6 +930,18 @@ gtk_open_with_widget_init (GtkOpenWithWidget *self)
|
|||||||
g_signal_connect (self->priv->program_list, "button-press-event",
|
g_signal_connect (self->priv->program_list, "button-press-event",
|
||||||
G_CALLBACK (program_list_button_press_event_cb),
|
G_CALLBACK (program_list_button_press_event_cb),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label (_("Show more applications..."));
|
||||||
|
w = gtk_image_new_from_stock (GTK_STOCK_ADD,
|
||||||
|
GTK_ICON_SIZE_BUTTON);
|
||||||
|
|
||||||
|
gtk_button_set_image (GTK_BUTTON (button), w);
|
||||||
|
gtk_box_pack_start (GTK_BOX (self), button, TRUE, TRUE, 6);
|
||||||
|
|
||||||
|
g_signal_connect (button, "clicked",
|
||||||
|
G_CALLBACK (show_more_button_clicked_cb), self);
|
||||||
|
|
||||||
|
self->priv->show_more = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GAppInfo *
|
static GAppInfo *
|
||||||
@ -921,6 +964,9 @@ gtk_open_with_widget_iface_init (GtkOpenWithIface *iface)
|
|||||||
void
|
void
|
||||||
_gtk_open_with_widget_refilter (GtkOpenWithWidget *self)
|
_gtk_open_with_widget_refilter (GtkOpenWithWidget *self)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
gtk_open_with_widget_ensure_show_more_button (self);
|
||||||
|
|
||||||
if (self->priv->program_list_store != NULL)
|
if (self->priv->program_list_store != NULL)
|
||||||
{
|
{
|
||||||
gtk_list_store_clear (self->priv->program_list_store);
|
gtk_list_store_clear (self->priv->program_list_store);
|
||||||
@ -963,6 +1009,7 @@ gtk_open_with_widget_set_show_mode (GtkOpenWithWidget *self,
|
|||||||
self->priv->show_mode = show_mode;
|
self->priv->show_mode = show_mode;
|
||||||
g_object_notify (G_OBJECT (self), "show-mode");
|
g_object_notify (G_OBJECT (self), "show-mode");
|
||||||
|
|
||||||
|
self->priv->show_more_clicked = FALSE;
|
||||||
_gtk_open_with_widget_refilter (self);
|
_gtk_open_with_widget_refilter (self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user