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); } }
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; }