/** * gstyle_palette_remove: * @self: a #GstylePalette * @color: A #GstyleColor * * Try to remove a #GstyleColor from the palette. * * Returns: %TRUE on succes, %FALSE otherwise. */ gboolean gstyle_palette_remove (GstylePalette *self, GstyleColor *color) { GPtrArray *array; g_return_val_if_fail (GSTYLE_IS_PALETTE (self), FALSE); g_return_val_if_fail (GSTYLE_IS_COLOR (color), FALSE); array = self->colors; for (gint i = 0; i < array->len; ++i) { if (array->pdata[i] == color) { remove_color_to_names_sets (self, color); g_ptr_array_remove_index (array, i); g_list_model_items_changed (G_LIST_MODEL (self), i, 1, 0); gstyle_palette_set_changed (self, TRUE); return TRUE; } } return FALSE; }
static void ide_recent_projects_added (IdeRecentProjects *self, IdeProjectInfo *project_info) { g_autofree gchar *uri = NULL; GFile *file; g_assert (IDE_IS_RECENT_PROJECTS (self)); g_assert (IDE_IS_PROJECT_INFO (project_info)); file = ide_project_info_get_file (project_info); uri = g_file_get_uri (file); if (!g_hash_table_contains (self->recent_uris, uri)) { GSequenceIter *iter; gint position; iter = g_sequence_insert_sorted (self->projects, g_object_ref (project_info), (GCompareDataFunc)ide_project_info_compare, NULL); position = g_sequence_iter_get_position (iter); g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1); } }
/** * gstyle_palette_remove_at_index: * @self: a #GstylePalette * @position: A position to remove the #GstyleColor from * * Try to remove the #GstyleColor at @position from the palette * * Returns: %TRUE on succes, %FALSE otherwise. */ gboolean gstyle_palette_remove_at_index (GstylePalette *self, gint position) { GstyleColor *color; g_return_val_if_fail (GSTYLE_IS_PALETTE (self), FALSE); if (0 <= position && position < self->colors->len) { color = GSTYLE_COLOR (g_ptr_array_index (self->colors, position)); remove_color_to_names_sets (self, color); g_ptr_array_remove_index (self->colors, position); g_list_model_items_changed (G_LIST_MODEL (self), position, 1, 0); gstyle_palette_set_changed (self, TRUE); return TRUE; } else { g_warning ("Trying to remove a Color in palette '%s' at out-of-bounds position %i in (0, %i)\n", gstyle_palette_get_name (self), position, self->colors->len - 1); return FALSE; } }
static void ide_frame_destroy (GtkWidget *widget) { IdeFrame *self = (IdeFrame *)widget; IdeFramePrivate *priv = ide_frame_get_instance_private (self); g_assert (IDE_IS_FRAME (self)); g_clear_object (&priv->addins); g_clear_pointer (&priv->in_transition, g_ptr_array_unref); if (priv->pages != NULL) { g_list_model_items_changed (G_LIST_MODEL (self), 0, priv->pages->len, 0); g_clear_pointer (&priv->pages, g_ptr_array_unref); } if (priv->bindings != NULL) { dzl_binding_group_set_source (priv->bindings, NULL); g_clear_object (&priv->bindings); } if (priv->signals != NULL) { dzl_signal_group_set_target (priv->signals, NULL); g_clear_object (&priv->signals); } g_clear_object (&priv->pan); GTK_WIDGET_CLASS (ide_frame_parent_class)->destroy (widget); }
static void ide_frame_page_added (IdeFrame *self, IdePage *page) { IdeFramePrivate *priv = ide_frame_get_instance_private (self); guint position; g_assert (IDE_IS_FRAME (self)); g_assert (IDE_IS_PAGE (page)); /* * Make sure that the header has dismissed all of the popovers immediately. * We don't want them lingering while we do other UI work which might want to * grab focus, etc. */ _ide_frame_header_popdown (priv->header); /* Notify GListModel consumers of the new page and it's position within * our stack of page widgets. */ position = priv->pages->len; g_ptr_array_add (priv->pages, page); g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1); /* * Now ensure that the page is displayed and focus the widget so the * user can immediately start typing. */ ide_frame_set_visible_child (self, page); gtk_widget_grab_focus (GTK_WIDGET (page)); }
static inline void emit_items_changed (CbTweetModel *self, guint position, guint removed, guint added) { g_list_model_items_changed (G_LIST_MODEL (self), position, removed, added); }
static void photos_base_manager_objects_changed (PhotosBaseManager *self, guint position, guint removed, guint added) { PhotosBaseManagerPrivate *priv; priv = photos_base_manager_get_instance_private (self); if (position <= priv->last_position) { priv->last_iter = NULL; priv->last_position = G_MAXUINT; } g_list_model_items_changed (G_LIST_MODEL (self), position, removed, added); }
static void animation_state_complete (gpointer data) { IdeFramePrivate *priv; AnimationState *state = data; g_assert (state != NULL); g_assert (IDE_IS_FRAME (state->source)); g_assert (IDE_IS_FRAME (state->dest)); g_assert (IDE_IS_PAGE (state->page)); /* Add the widget to the new stack */ if (state->dest != state->source) { gtk_container_add (GTK_CONTAINER (state->dest), GTK_WIDGET (state->page)); /* Now remove it from our temporary transition. Be careful in case we were * destroyed in the mean time. */ priv = ide_frame_get_instance_private (state->source); if (priv->in_transition != NULL) { guint position = 0; if (g_ptr_array_find_with_equal_func (priv->pages, state->page, NULL, &position)) { g_ptr_array_remove (priv->in_transition, state->page); g_ptr_array_remove_index (priv->pages, position); g_list_model_items_changed (G_LIST_MODEL (state->source), position, 1, 0); } } } /* * We might need to reshow the widget in cases where we are in a * three-finger-swipe of the page. There is also a chance that we * aren't the proper visible child and that needs to be restored now. */ gtk_widget_show (GTK_WIDGET (state->page)); ide_frame_set_visible_child (state->dest, state->page); g_clear_object (&state->source); g_clear_object (&state->dest); g_clear_object (&state->page); g_clear_object (&state->theatric); g_slice_free (AnimationState, state); }
/** * gstyle_palette_add_at_index: * @self: a #GstylePalette * @color: A #GstyleColor * @position: Position to insert the new color, from 0 to gstyle_palette_get_len() -1, * or -1 to append it * @error: (nullable): a #GError location or %NULL * * Add a #GstyleColor to the palette. * * Returns: %TRUE on succes, %FALSE otherwise. */ gboolean gstyle_palette_add_at_index (GstylePalette *self, GstyleColor *color, gint position, GError **error) { g_return_val_if_fail (GSTYLE_IS_PALETTE (self), FALSE); g_return_val_if_fail (GSTYLE_IS_COLOR (color), FALSE); /* If we are just after the last position, we in fact do an append */ if (position == self->colors->len) position = -1; if (position == -1 || (position == 0 && self->colors->len == 0) || (0 <= position && position < self->colors->len)) { g_object_ref (color); g_ptr_array_insert (self->colors, position, color); add_color_to_names_sets (self, color); gstyle_palette_set_changed (self, TRUE); position = (position == -1) ? self->colors->len - 1 : position; g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1); return TRUE; } else { g_warning ("Color inserted in palette '%s' at out-of-bounds position %i in (0, %i)\n", gstyle_palette_get_name (self), position, self->colors->len - 1); return FALSE; } }
static void ide_frame_page_removed (IdeFrame *self, IdePage *page) { IdeFramePrivate *priv = ide_frame_get_instance_private (self); g_assert (IDE_IS_FRAME (self)); g_assert (IDE_IS_PAGE (page)); if (priv->pages != NULL) { guint position = 0; /* If this is the last page, hide the popdown now. We use our hide * variant instead of popdown so that we don't have jittery animations. */ if (priv->pages->len == 1) _ide_frame_header_hide (priv->header); /* * Only remove the page if it is not in transition. We hold onto the * page during the transition so that we keep the list stable. */ if (!g_ptr_array_find_with_equal_func (priv->in_transition, page, NULL, &position)) { for (guint i = 0; i < priv->pages->len; i++) { if ((gpointer)page == g_ptr_array_index (priv->pages, i)) { g_ptr_array_remove_index (priv->pages, i); g_list_model_items_changed (G_LIST_MODEL (self), i, 1, 0); } } } } }