app-chooser-button: don't insert empty rows in the combobox

This commit is contained in:
Cosimo Cecchi 2010-12-01 20:18:12 +01:00
parent b17f033857
commit 6587652433

View File

@ -231,18 +231,22 @@ gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
GtkTreeIter *prev_iter)
{
GIcon *icon;
GtkTreeIter iter;
GtkTreeIter iter, iter2;
if (!self->priv->show_dialog_item)
return;
icon = g_themed_icon_new ("application-x-executable");
gtk_list_store_insert_after (self->priv->store, &iter, prev_iter);
real_insert_separator (self, FALSE, &iter);
*prev_iter = iter;
if (prev_iter == NULL)
gtk_list_store_append (self->priv->store, &iter);
else
gtk_list_store_insert_after (self->priv->store, &iter, prev_iter);
gtk_list_store_insert_after (self->priv->store, &iter, prev_iter);
real_insert_separator (self, FALSE, &iter);
iter2 = iter;
gtk_list_store_insert_after (self->priv->store, &iter, &iter2);
real_insert_custom_item (self, CUSTOM_ITEM_OTHER_APP,
_("Other application..."), icon,
FALSE, &iter);
@ -257,12 +261,10 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
GAppInfo *app;
GtkTreeIter iter, iter2;
GIcon *icon;
gboolean first;
gboolean cycled_recommended;
recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
first = TRUE;
get_first_iter (self->priv->store, &iter);
cycled_recommended = FALSE;
for (l = recommended_apps; l != NULL; l = l->next)
{
@ -275,15 +277,16 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
else
g_object_ref (icon);
if (first)
{
first = FALSE;
}
else
if (cycled_recommended)
{
gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
iter = iter2;
}
else
{
get_first_iter (self->priv->store, &iter);
cycled_recommended = TRUE;
}
gtk_list_store_set (self->priv->store, &iter,
COLUMN_APP_INFO, app,
@ -295,7 +298,11 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
g_object_unref (icon);
}
gtk_app_chooser_button_ensure_dialog_item (self, &iter);
if (!cycled_recommended)
gtk_app_chooser_button_ensure_dialog_item (self, NULL);
else
gtk_app_chooser_button_ensure_dialog_item (self, &iter);
gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
}