コード例 #1
0
void
ide_workbench_remove_perspective (IdeWorkbench   *self,
                                  IdePerspective *perspective)
{
  guint n_items;
  guint i;

  g_assert (IDE_IS_WORKBENCH (self));
  g_assert (IDE_IS_PERSPECTIVE (perspective));
  g_assert (gtk_widget_get_parent (GTK_WIDGET (perspective)) ==
            GTK_WIDGET (self->perspectives_stack));

  n_items = g_list_model_get_n_items (G_LIST_MODEL (self->perspectives));

  for (i = 0; i < n_items; i++)
    {
      g_autoptr(IdePerspective) item = NULL;

      item = g_list_model_get_item (G_LIST_MODEL (self->perspectives), i);

      if (item == perspective)
        {
          g_list_store_remove (self->perspectives, i);
          break;
        }
    }

  gtk_container_remove (GTK_CONTAINER (self->perspectives_stack),
                        GTK_WIDGET (perspective));
}
コード例 #2
0
void
tmpl_iterator_init (TmplIterator *iter,
                    const GValue *value)
{
  memset (iter, 0, sizeof *iter);

  if (value == NULL)
    return;

  if (G_VALUE_HOLDS_STRING (value))
    {
      iter->instance = (gchar *)g_value_get_string (value);
      iter->move_next = string_move_next;
      iter->get_value = string_get_value;
      iter->destroy = NULL;
    }
  else if (G_VALUE_HOLDS (value, G_TYPE_LIST_MODEL))
    {
      iter->instance = g_value_get_object (value);
      iter->move_next = list_model_move_next;
      iter->get_value = list_model_get_value;
      iter->destroy = NULL;

      if (iter->instance != NULL)
        {
          guint n_items;

          n_items = g_list_model_get_n_items (iter->instance);
          iter->data1 = GUINT_TO_POINTER (iter->data1);
          iter->data2 = GUINT_TO_POINTER (n_items);
        }
    }

  /* TODO: More iter types */
}
コード例 #3
0
ファイル: flattenlistmodel.c プロジェクト: sam-m888/gtk
static char *
model_to_string (GListModel *model)
{
  GString *string = g_string_new (NULL);
  guint i;

  for (i = 0; i < g_list_model_get_n_items (model); i++)
    {
      if (i > 0)
        g_string_append (string, " ");
      g_string_append_printf (string, "%u", get (model, i));
    }

  return g_string_free (string, FALSE);
}
コード例 #4
0
ファイル: gb-vim.c プロジェクト: GNOME/gnome-builder
static gboolean
gb_vim_command_bprevious (GtkWidget      *active_widget,
                          const gchar    *command,
                          const gchar    *options,
                          GError        **error)
{
  IdeFrame *frame_;

  g_assert (GTK_IS_WIDGET (active_widget));

  if ((frame_ = (IdeFrame *)gtk_widget_get_ancestor (active_widget, IDE_TYPE_FRAME)) &&
      g_list_model_get_n_items (G_LIST_MODEL (frame_)) > 0)
    dzl_gtk_widget_action (GTK_WIDGET (active_widget), "frame", "previous-page", NULL);

  return TRUE;
}
コード例 #5
0
static void
on_clear_all_button_clicked (GtkButton *button,
                             gpointer   user_data)
{
  PpJobsDialog *dialog = user_data;
  guint num_items;
  guint i;

  num_items = g_list_model_get_n_items (G_LIST_MODEL (dialog->store));

  for (i = 0; i < num_items; i++)
    {
      PpJob *job = PP_JOB (g_list_model_get_item (G_LIST_MODEL (dialog->store), i));

      pp_job_cancel_purge_async (job, FALSE);
    }
}
コード例 #6
0
void
egg_app_info_model_changed (GAppInfoMonitor *monitor,
                            gpointer         user_data)
{
  EggKeyedListStore *store = user_data;
  GHashTable *old_app_ids;
  GList *new_apps;
  GList *it;
  guint n_items;
  gint i;
  GHashTableIter iter;
  const gchar *id;

  old_app_ids = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
  n_items = g_list_model_get_n_items (G_LIST_MODEL (store));
  for (i = 0; i < n_items; i++)
    {
      GAppInfo *info;

      info = g_list_model_get_item (G_LIST_MODEL (store), i);
      g_hash_table_insert (old_app_ids, (gpointer) g_app_info_get_id (info), info);
    }

  new_apps = g_app_info_get_all ();
  for (it = new_apps; it; it = it->next)
    {
      GAppInfo *info = it->data;

      if (!g_app_info_should_show (info))
        continue;

      id = g_app_info_get_id (info);

      /* only add the application if we didn't have it before */
      if (!g_hash_table_remove (old_app_ids, id))
        egg_keyed_list_store_insert (store, id, info);
    }

  /* remove app ids that aren't in new_apps */
  g_hash_table_iter_init (&iter, old_app_ids);
  while (g_hash_table_iter_next (&iter, (gpointer) &id, NULL))
    egg_keyed_list_store_remove (store, id);

  g_list_free_full (new_apps, g_object_unref);
  g_hash_table_destroy (old_app_ids);
}
コード例 #7
0
static void
photos_base_model_refresh (PhotosBaseModel *self)
{
  g_autoptr (GMenu) section = NULL;
  const gchar *action_id;
  const gchar *title;
  guint i;
  guint n_items;

  g_menu_remove_all (self->model);

  title = photos_base_manager_get_title (self->mngr);
  action_id = photos_base_manager_get_action_id (self->mngr);

  section = g_menu_new ();
  g_menu_append_section (self->model, title, G_MENU_MODEL (section));

  n_items = g_list_model_get_n_items (G_LIST_MODEL (self->mngr));
  for (i = 0; i < n_items; i++)
    {
      g_autoptr (GMenuItem) menu_item = NULL;
      g_autoptr (GObject) object = NULL;
      const gchar *id;
      g_autofree gchar *name = NULL;

      object = g_list_model_get_object (G_LIST_MODEL (self->mngr), i);
      if (!photos_filterable_is_search_criterion (PHOTOS_FILTERABLE (object)))
        continue;

      id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
      g_object_get (object, "name", &name, NULL);

      menu_item = g_menu_item_new (name, NULL);
      g_menu_item_set_action_and_target (menu_item, action_id, "s", id);
      g_menu_append_item (section, menu_item);
    }
}
コード例 #8
0
static void
bind_buffer_manager (GbpEditorWorkspaceAddin *self,
                     IdeBufferManager        *buffer_manager,
                     DzlSignalGroup          *signal_group)
{
  guint n_items;

  g_assert (GBP_IS_EDITOR_WORKSPACE_ADDIN (self));
  g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
  g_assert (DZL_IS_SIGNAL_GROUP (signal_group));

  if (self->surface == NULL)
    return;

  n_items = g_list_model_get_n_items (G_LIST_MODEL (buffer_manager));

  for (guint i = 0; i < n_items; i++)
    {
      g_autoptr(IdeBuffer) buffer = NULL;

      buffer = g_list_model_get_item (G_LIST_MODEL (buffer_manager), i);
      ide_editor_surface_focus_buffer (self->surface, buffer);
    }
}
コード例 #9
0
static void
photos_share_point_manager_refresh_share_points (PhotosSharePointManager *self)
{
  GHashTable *new_share_points;
  GList *extensions;
  GList *l;
  guint i;
  guint n_items;

  new_share_points = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);

  extensions = g_io_extension_point_get_extensions (self->extension_point);
  for (l = extensions; l != NULL; l = l->next)
    {
      GError *error;
      GIOExtension *extension = (GIOExtension *) l->data;
      GType type;
      PhotosSharePoint *share_point;
      const gchar *id;

      type = g_io_extension_get_type (extension);
      if (g_type_is_a (type, G_TYPE_INITABLE))
        {
          error = NULL;
          share_point = PHOTOS_SHARE_POINT (g_initable_new (type, NULL, &error, NULL));
          if (share_point == NULL)
            {
              const gchar *name;

              name = g_io_extension_get_name (extension);
              g_debug ("Unable to initialize share point %s: %s", name, error->message);
              g_error_free (error);
              continue;
            }
        }
      else
        {
          share_point = PHOTOS_SHARE_POINT (g_object_new (type, NULL));
        }

      id = photos_filterable_get_id (PHOTOS_FILTERABLE (share_point));
      g_hash_table_insert (new_share_points, g_strdup (id), g_object_ref (share_point));
      g_object_unref (share_point);
    }

  n_items = g_list_model_get_n_items (G_LIST_MODEL (self->src_mngr));
  for (i = 0; i < n_items; i++)
    {
      PhotosSharePoint *share_point = NULL;
      PhotosSource *source;

      source = PHOTOS_SOURCE (g_list_model_get_object (G_LIST_MODEL (self->src_mngr), i));
      share_point = photos_share_point_manager_create_share_point_online (self, source);
      if (share_point != NULL)
        {
          const gchar *id;

          id = photos_filterable_get_id (PHOTOS_FILTERABLE (share_point));
          g_hash_table_insert (new_share_points, g_strdup (id), g_object_ref (share_point));
        }

      g_clear_object (&share_point);
      g_object_unref (source);
    }

  photos_base_manager_process_new_objects (PHOTOS_BASE_MANAGER (self), new_share_points);
  g_hash_table_unref (new_share_points);
}