static PhotosSharePoint *
photos_share_point_manager_create_share_point_online (PhotosSharePointManager *self, PhotosSource *source)
{
  GIOExtension *extension;
  GType type;
  GoaAccount *account;
  GoaObject *object;
  PhotosSharePoint *ret_val = NULL;
  const gchar *provider_type;

  object = photos_source_get_goa_object (source);
  if (object == NULL)
    goto out;

  account = goa_object_peek_account (object);
  provider_type = goa_account_get_provider_type (account);
  extension = g_io_extension_point_get_extension_by_name (self->extension_point_online, provider_type);
  if (extension == NULL)
    goto out;

  type = g_io_extension_get_type (extension);
  ret_val = PHOTOS_SHARE_POINT (g_object_new (type, "source", source, NULL));

 out:
  return ret_val;
}
Пример #2
0
static void
populate_union_monitor (GUnionVolumeMonitor *union_monitor)
{
  GVolumeMonitor *monitor;
  GNativeVolumeMonitorClass *native_class;
  GVolumeMonitorClass *klass;
  GIOExtensionPoint *ep;
  GIOExtension *extension;
  GList *l;

  native_class = get_native_class ();

  if (native_class != NULL)
    {
      monitor = g_object_new (G_TYPE_FROM_CLASS (native_class), NULL);
      g_union_volume_monitor_add_monitor (union_monitor, monitor);
      g_object_unref (monitor);
      g_type_class_unref (native_class);
    }

  ep = g_io_extension_point_lookup (G_VOLUME_MONITOR_EXTENSION_POINT_NAME);
  for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next)
    {
      extension = l->data;
      
      klass = G_VOLUME_MONITOR_CLASS (g_io_extension_ref_class (extension));
      if (klass->is_supported == NULL || klass->is_supported())
	{
	  monitor = g_object_new (g_io_extension_get_type (extension), NULL);
	  g_union_volume_monitor_add_monitor (union_monitor, monitor);
	  g_object_unref (monitor);
	}
      g_type_class_unref (klass);
    }
}
static void
_panel_applets_managers_ensure_loaded (void)
{
	GIOExtensionPoint *point;
	GList             *extensions, *l;

	if (panel_applets_managers != NULL)
		return;

	panel_cleanup_register (PANEL_CLEAN_FUNC (_panel_applets_manager_cleanup), NULL);

	panel_modules_ensure_loaded ();

	point = g_io_extension_point_lookup (PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME);

	extensions = g_io_extension_point_get_extensions (point);

	if (extensions == NULL)
		g_error ("No PanelAppletsManager implementations exist.");

	for (l = extensions; l != NULL; l = l->next) {
		GIOExtension *extension;
		GType         type;
		GObject      *object;

		extension = l->data;
		type = g_io_extension_get_type (extension);
		object = g_object_new (type, NULL);
		panel_applets_managers = g_slist_prepend (panel_applets_managers, object);
	}

	panel_applets_managers = g_slist_reverse (panel_applets_managers);
}
Пример #4
0
static void
gtk_inspector_window_init (GtkInspectorWindow *iw)
{
  GIOExtensionPoint *extension_point;
  GList *l, *extensions;

  gtk_widget_init_template (GTK_WIDGET (iw));

  gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));

  extension_point = g_io_extension_point_lookup ("gtk-inspector-page");
  extensions = g_io_extension_point_get_extensions (extension_point);

  for (l = extensions; l != NULL; l = l->next)
    {
      GIOExtension *extension = l->data;
      GType type;
      GtkWidget *widget;
      const char *name;
      char *title;
      GtkWidget *button;
      gboolean use_picker;

      type = g_io_extension_get_type (extension);

      widget = g_object_new (type, NULL);

      iw->extra_pages = g_list_prepend (iw->extra_pages, widget);

      name = g_io_extension_get_name (extension);
      g_object_get (widget, "title", &title, NULL);

      if (g_object_class_find_property (G_OBJECT_GET_CLASS (widget), "use-picker"))
        g_object_get (widget, "use-picker", &use_picker, NULL);
      else
        use_picker = FALSE;

      if (use_picker)
        {
          button = gtk_button_new_from_icon_name ("find-location-symbolic",
                                                  GTK_ICON_SIZE_MENU);
          gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
          gtk_widget_set_halign (button, GTK_ALIGN_START);
          gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
          g_signal_connect (button, "clicked",
                            G_CALLBACK (gtk_inspector_on_inspect), iw);
        }
      else
        button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

      gtk_stack_add_titled (GTK_STACK (iw->top_stack), widget, name, title);
      gtk_stack_add_named (GTK_STACK (iw->button_stack), button, name);
      gtk_widget_show (widget);
      gtk_widget_show (button);

      g_free (title);
    }

}
Пример #5
0
static gpointer
get_default_proxy_resolver (gpointer arg)
{
  const gchar *use_this;
  GProxyResolver *resolver;
  GList *l;
  GIOExtensionPoint *ep;
  GIOExtension *extension;
  

  use_this = g_getenv ("GIO_USE_PROXY_RESOLVER");
  
  /* Ensure proxy-resolver modules loaded */
  _g_io_modules_ensure_loaded ();

  ep = g_io_extension_point_lookup (G_PROXY_RESOLVER_EXTENSION_POINT_NAME);

  if (use_this)
    {
      extension = g_io_extension_point_get_extension_by_name (ep, use_this);
      if (extension)
	{
	   resolver = g_object_new (g_io_extension_get_type (extension), NULL);
	  
	   if (g_proxy_resolver_is_supported (resolver))
	     return resolver;
	  
	  g_object_unref (resolver);
	}
    }

  for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next)
    {
      extension = l->data;

      resolver = g_object_new (g_io_extension_get_type (extension), NULL);

      if (g_proxy_resolver_is_supported (resolver))
	return resolver;

      g_object_unref (resolver);
    }
  
  return NULL;
}
Пример #6
0
/**
 * g_proxy_get_default_for_protocol:
 * @protocol: the proxy protocol name (e.g. http, socks, etc)
 *
 * Lookup "gio-proxy" extension point for a proxy implementation that supports
 * specified protocol.
 *
 * Returns: (transfer full): return a #GProxy or NULL if protocol
 *               is not supported.
 *
 * Since: 2.26
 **/
GProxy *
g_proxy_get_default_for_protocol (const gchar *protocol)
{
  GIOExtensionPoint *ep;
  GIOExtension *extension;

  /* Ensure proxy modules loaded */
  _g_io_modules_ensure_loaded ();

  ep = g_io_extension_point_lookup (G_PROXY_EXTENSION_POINT_NAME);

  extension = g_io_extension_point_get_extension_by_name (ep, protocol);

  if (extension)
      return g_object_new (g_io_extension_get_type (extension), NULL);

  return NULL;
}
Пример #7
0
static void
ide_recent_projects_init (IdeRecentProjects *self)
{
  GIOExtensionPoint *extension_point;
  GList *extensions;

  self->projects = g_sequence_new (g_object_unref);
  self->miners = g_ptr_array_new_with_free_func (g_object_unref);
  self->cancellable = g_cancellable_new ();
  self->recent_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
  self->file_uri = g_build_filename (g_get_user_data_dir (),
                                     ide_get_program_name (),
                                     IDE_RECENT_PROJECTS_BOOKMARK_FILENAME,
                                     NULL);


  extension_point = g_io_extension_point_lookup (IDE_PROJECT_MINER_EXTENSION_POINT);
  extensions = g_io_extension_point_get_extensions (extension_point);

  for (; extensions; extensions = extensions->next)
    {
      IdeProjectMiner *miner;
      GIOExtension *extension = extensions->data;
      GType type_id;

      type_id = g_io_extension_get_type (extension);

      if (!g_type_is_a (type_id, IDE_TYPE_PROJECT_MINER))
        {
          g_warning ("%s is not an IdeProjectMiner", g_type_name (type_id));
          continue;
        }

      miner = g_object_new (type_id, NULL);
      ide_recent_projects_add_miner (self, miner);
      g_object_unref (miner);
    }
}
Пример #8
0
IdeFileSettings *
ide_file_settings_new (IdeObject   *parent,
                       GFile       *file,
                       const gchar *language)
{
  IdeFileSettingsPrivate *priv;
  GIOExtensionPoint *extension_point;
  IdeFileSettings *ret;
  GList *list;

  g_return_val_if_fail (G_IS_FILE (file), NULL);
  g_return_val_if_fail (IDE_IS_OBJECT (parent), NULL);

  ret = g_object_new (IDE_TYPE_FILE_SETTINGS,
                      "file", file,
                      "language", language,
                      NULL);
  priv = ide_file_settings_get_instance_private (ret);

  ide_object_append (parent, IDE_OBJECT (ret));

  extension_point = g_io_extension_point_lookup (IDE_FILE_SETTINGS_EXTENSION_POINT);
  list = g_io_extension_point_get_extensions (extension_point);

  /*
   * Don't allow our unsettled count to hit zero until we are finished.
   */
  priv->unsettled_count++;

  for (; list; list = list->next)
    {
      GIOExtension *extension = list->data;
      g_autoptr(IdeFileSettings) child = NULL;
      GType gtype;

      gtype = g_io_extension_get_type (extension);

      if (!g_type_is_a (gtype, IDE_TYPE_FILE_SETTINGS))
        {
          g_warning ("%s is not an IdeFileSettings", g_type_name (gtype));
          continue;
        }

      child = g_object_new (gtype,
                            "file", file,
                            "language", language,
                            NULL);
      ide_object_append (IDE_OBJECT (ret), IDE_OBJECT (child));

      if (G_IS_INITABLE (child))
        {
          g_autoptr(GError) error = NULL;

          if (!g_initable_init (G_INITABLE (child), NULL, &error))
            {
              if (!ide_error_ignore (error))
                g_warning ("%s", error->message);
            }
        }
      else if (G_IS_ASYNC_INITABLE (child))
        {
          priv->unsettled_count++;
          g_async_initable_init_async (G_ASYNC_INITABLE (child),
                                       G_PRIORITY_DEFAULT,
                                       NULL,
                                       ide_file_settings__init_cb,
                                       g_object_ref (ret));
        }

      _ide_file_settings_append (ret, child);
    }

  priv->unsettled_count--;

  return ret;
}
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);
}
static gboolean
activate_panel (GnomeControlCenter *shell,
                const gchar        *id,
		const gchar       **argv,
                const gchar        *desktop_file,
                const gchar        *name,
                GIcon              *gicon)
{
  GnomeControlCenterPrivate *priv = shell->priv;
  GType panel_type = G_TYPE_INVALID;
  GList *panels, *l;
  GtkWidget *panel;
  GtkWidget *box;
  const gchar *icon_name;

  /* check if there is an plugin that implements this panel */
  panels = g_io_extension_point_get_extensions (priv->extension_point);

  if (!desktop_file)
    return FALSE;
  if (!id)
    return FALSE;

  for (l = panels; l != NULL; l = l->next)
    {
      GIOExtension *extension;
      const gchar *name;

      extension = l->data;

      name = g_io_extension_get_name (extension);

      if (!g_strcmp0 (name, id))
        {
          panel_type = g_io_extension_get_type (extension);
          break;
        }
    }

  if (panel_type == G_TYPE_INVALID)
    {
      g_warning ("Could not find the loadable module for panel '%s'", id);
      return FALSE;
    }

  /* create the panel plugin */
  panel = g_object_new (panel_type, "shell", shell, "argv", argv, NULL);
  cc_shell_set_active_panel (CC_SHELL (shell), CC_PANEL (panel));
  gtk_widget_show (panel);

  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button),
                                  cc_panel_get_permission (CC_PANEL (panel)));

  box = gtk_alignment_new (0, 0, 1, 1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);

  gtk_container_add (GTK_CONTAINER (box), panel);

  gtk_widget_set_name (box, id);
  notebook_add_page (priv->notebook, box);

  /* switch to the new panel */
  gtk_widget_show (box);
  notebook_select_page (priv->notebook, box);

  /* set the title of the window */
  icon_name = get_icon_name_from_g_icon (gicon);
  gtk_window_set_role (GTK_WINDOW (priv->window), id);
  gtk_window_set_title (GTK_WINDOW (priv->window), name);
  gtk_window_set_default_icon_name (icon_name);
  gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name);

  priv->current_panel = box;

  return TRUE;
}
static gboolean
activate_panel (GnomeControlCenter *shell,
                const gchar        *id,
		const gchar       **argv,
                const gchar        *desktop_file,
                const gchar        *name,
                GIcon              *gicon)
{
  GDesktopAppInfo     *appinfo;
  GdkAppLaunchContext *context;
  GdkScreen           *screen;
  GdkDisplay          *display;
  GError              *error;

  appinfo = g_desktop_app_info_new_from_filename (desktop_file);

  screen = gtk_widget_get_screen (shell->priv->window);
  display = gdk_screen_get_display (screen);
  context = gdk_display_get_app_launch_context (display);
  gdk_app_launch_context_set_screen (context, screen);
  gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());

  error = NULL;
  g_app_info_launch_uris (G_APP_INFO (appinfo), NULL,
                          (GAppLaunchContext *) context,
                          &error);

  if (error) {
    g_printerr ("Could not launch '%s': %s\n", id, error->message);
    g_clear_error (&error);
  }

  g_object_unref (context);
  g_object_unref (appinfo);
#if 0
  GnomeControlCenterPrivate *priv = shell->priv;
  GType panel_type = G_TYPE_INVALID;
  GList *panels, *l;
  GtkWidget *box;
  const gchar *icon_name;

  /* check if there is an plugin that implements this panel */
  panels = g_io_extension_point_get_extensions (priv->extension_point);

  if (!desktop_file)
    return FALSE;
  if (!id)
    return FALSE;

  for (l = panels; l != NULL; l = l->next)
    {
      GIOExtension *extension;
      const gchar *name;

      extension = l->data;

      name = g_io_extension_get_name (extension);

      if (!g_strcmp0 (name, id))
        {
          panel_type = g_io_extension_get_type (extension);
          break;
        }
    }

  if (panel_type == G_TYPE_INVALID)
    {
      g_warning ("Could not find the loadable module for panel '%s'", id);
      return FALSE;
    }

  /* create the panel plugin */
  priv->current_panel = g_object_new (panel_type, "shell", shell, "argv", argv, NULL);
  cc_shell_set_active_panel (CC_SHELL (shell), CC_PANEL (priv->current_panel));
  gtk_widget_show (priv->current_panel);

  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button),
                                  cc_panel_get_permission (CC_PANEL (priv->current_panel)));

  box = gtk_alignment_new (0, 0, 1, 1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);

  gtk_container_add (GTK_CONTAINER (box), priv->current_panel);

  gtk_widget_set_name (box, id);
  notebook_add_page (priv->notebook, box);

  /* switch to the new panel */
  gtk_widget_show (box);
  notebook_select_page (priv->notebook, box);

  /* set the title of the window */
  icon_name = get_icon_name_from_g_icon (gicon);
  gtk_window_set_role (GTK_WINDOW (priv->window), id);
  gtk_window_set_title (GTK_WINDOW (priv->window), name);
  gtk_window_set_default_icon_name (icon_name);
  gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name);

  priv->current_panel_box = box;
#endif
  return TRUE;
}
static gboolean
activate_panel (CinnamonControlCenter *shell,
                const gchar        *id,
		const gchar       **argv,
                const gchar        *desktop_file,
                const gchar        *name,
                GIcon              *gicon)
{
  CinnamonControlCenterPrivate *priv = shell->priv;
  GType panel_type = G_TYPE_INVALID;
  GList *panels, *l;
  GtkWidget *box;
  const gchar *icon_name;

  /* check if there is an plugin that implements this panel */
  panels = g_io_extension_point_get_extensions (priv->extension_point);

  if (!desktop_file)
    return FALSE;
  if (!id)
    return FALSE;

  for (l = panels; l != NULL; l = l->next)
    {
      GIOExtension *extension;
      const gchar *name;

      extension = l->data;

      name = g_io_extension_get_name (extension);

      if (!g_strcmp0 (name, id))
        {
          panel_type = g_io_extension_get_type (extension);
          break;
        }
    }

  if (panel_type == G_TYPE_INVALID)
    {
	  GKeyFile *key_file;

	  /* It might be an external panel */
	  key_file = g_key_file_new ();
	  if (g_key_file_load_from_file (key_file, desktop_file, G_KEY_FILE_NONE, NULL))
	    {
	      gchar *command;

	      command = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
	      if (command && command[0])
	        {
		  g_spawn_command_line_async (command, NULL);
		  g_free (command);
		}
	    }

	  g_key_file_free (key_file);
      return FALSE;
    }

  /* create the panel plugin */
  priv->current_panel = g_object_new (panel_type, "shell", shell, "argv", argv, NULL);
  cc_shell_set_active_panel (CC_SHELL (shell), CC_PANEL (priv->current_panel));
  gtk_widget_show (priv->current_panel);

  gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button),
                                  cc_panel_get_permission (CC_PANEL (priv->current_panel)));

  box = gtk_alignment_new (0, 0, 1, 1);
  gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);

  gtk_container_add (GTK_CONTAINER (box), priv->current_panel);

  gtk_widget_set_name (box, id);
  notebook_add_page (priv->notebook, box);

  /* switch to the new panel */
  gtk_widget_show (box);
  notebook_select_page (priv->notebook, box);
  cc_shell_nav_bar_show_detail_button (CC_SHELL_NAV_BAR(shell->priv->nav_bar), name);

  /* set the title of the window */
  icon_name = get_icon_name_from_g_icon (gicon);
  gtk_window_set_role (GTK_WINDOW (priv->window), id);
  gtk_window_set_title (GTK_WINDOW (priv->window), name);
  gtk_window_set_default_icon_name (icon_name);
  gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name);

  priv->current_panel_box = box;

  return TRUE;
}