Example #1
0
static void
shell_prepare_for_online (EShell *shell)
{
	/* Are preparations already in progress? */
	if (shell->priv->preparing_for_line_change != NULL)
		return;

	shell->priv->preparing_for_line_change = e_activity_new ();

	e_activity_set_text (
		shell->priv->preparing_for_line_change,
		_("Preparing to go online..."));

	g_object_add_toggle_ref (
		G_OBJECT (shell->priv->preparing_for_line_change),
		(GToggleNotify) shell_ready_for_online, shell);

	g_object_add_weak_pointer (
		G_OBJECT (shell->priv->preparing_for_line_change),
		&shell->priv->preparing_for_line_change);

	g_signal_emit (
		shell, signals[PREPARE_FOR_ONLINE], 0,
		shell->priv->preparing_for_line_change);

	g_object_unref (shell->priv->preparing_for_line_change);
}
FlowSshMaster *
flow_ssh_master_registry_get_master (FlowSshMasterRegistry *ssh_master_registry, FlowIPService *remote_ip_service, const gchar *remote_user)
{
  FlowSshMasterRegistryPrivate *priv;
  FlowSshMaster *ssh_master;
  gchar *key;

  g_return_val_if_fail (FLOW_IS_SSH_MASTER_REGISTRY (ssh_master_registry), NULL);
  g_return_val_if_fail (FLOW_IS_IP_SERVICE (remote_ip_service), NULL);

  priv = ssh_master_registry->priv;

  key = generate_key (remote_ip_service, remote_user);
  ssh_master = g_hash_table_lookup (priv->masters, key);

  if (ssh_master)
  {
    g_free (key);
  }
  else
  {
    ssh_master = flow_ssh_master_new (remote_ip_service, remote_user);
    g_hash_table_insert (priv->masters, key, ssh_master);
    g_object_add_toggle_ref ((GObject *) ssh_master, (GToggleNotify) toggle_ref_cb, ssh_master_registry);
    g_object_unref (ssh_master);
  }

  return ssh_master;
}
void
rejilla_mime_filter_add_mime (RejillaMimeFilter *filter,
                              const gchar *mime)
{
	GtkFileFilter *item;

	item = g_hash_table_lookup (filter->priv->table, mime);
	if (!item) {
		GIcon *icon;
		GtkTreeIter row;
		gchar *description;
		GtkTreeModel *model;

		description = g_content_type_get_description (mime);
		icon = g_content_type_get_icon (mime);

		/* create the GtkFileFilter */
		item = gtk_file_filter_new ();
		gtk_file_filter_set_name (item, mime);
		gtk_file_filter_add_mime_type (item, mime);
		g_hash_table_insert (filter->priv->table,
				     g_strdup (mime),
				     item);

		g_object_add_toggle_ref (G_OBJECT (item),
		                         (GToggleNotify) rejilla_mime_filter_destroy_item_cb,
		                         filter);

		model = gtk_combo_box_get_model (GTK_COMBO_BOX (filter->combo));
		gtk_list_store_append (GTK_LIST_STORE (model), &row);

		g_object_ref_sink (item);
		gtk_list_store_set (GTK_LIST_STORE (model), &row,
				    REJILLA_MIME_FILTER_DISPLAY_COL, description,
				    REJILLA_MIME_FILTER_ICON_COL, icon,
				    REJILLA_MIME_FILTER_FILTER_COL, item,
				    -1);
		g_object_unref (icon);
		g_free (description);

		/* we check that the first entry at least is visible */
		if (gtk_combo_box_get_active (GTK_COMBO_BOX (filter->combo)) == -1
		&&  gtk_tree_model_get_iter_first (model, &row) == TRUE)
			gtk_combo_box_set_active_iter (GTK_COMBO_BOX (filter->combo),
						       &row);
	}
	else
		g_object_ref (item);
}
Example #4
0
gboolean
_g_object_wait_for_single_ref_do (gpointer object)
{
  WaitSingleRefData data;
  guint timeout_id;

  data.timed_out = FALSE;

  if (G_OBJECT (object)->ref_count == 1)
    goto out;

  data.loop = g_main_loop_new (NULL, FALSE);
  timeout_id = g_timeout_add (30 * 1000,
                              on_wait_single_ref_timeout,
                              &data);

  g_object_add_toggle_ref (G_OBJECT (object),
                           on_wait_for_single_ref_toggled,
                           &data);
  /* the reference could have been removed between us checking the
   * ref_count and the toggle ref being added
   */
  if (G_OBJECT (object)->ref_count == 2)
    goto single_ref_already;

  g_object_unref (object);
  g_main_loop_run (data.loop);
  g_object_ref (object);

single_ref_already:
  g_object_remove_toggle_ref (object,
                              on_wait_for_single_ref_toggled,
                              &data);

  g_source_remove (timeout_id);
  g_main_loop_unref (data.loop);

 out:
  if (data.timed_out)
    {
      g_printerr ("b ref_count is %d\n", G_OBJECT (object)->ref_count);
    }
  return data.timed_out;
}
Example #5
0
static void
shell_prepare_for_quit (EShell *shell)
{
	GtkApplication *application;
	GList *list, *iter;

	/* Are preparations already in progress? */
	if (shell->priv->preparing_for_quit != NULL)
		return;

	application = GTK_APPLICATION (shell);

	shell->priv->inhibit_cookie = gtk_application_inhibit (
		application, NULL,
		GTK_APPLICATION_INHIBIT_SWITCH |
		GTK_APPLICATION_INHIBIT_LOGOUT |
		GTK_APPLICATION_INHIBIT_SUSPEND,
		_("Preparing to quit"));

	shell->priv->preparing_for_quit = e_activity_new ();

	e_activity_set_text (
		shell->priv->preparing_for_quit,
		_("Preparing to quit..."));

	g_object_add_toggle_ref (
		G_OBJECT (shell->priv->preparing_for_quit),
		(GToggleNotify) shell_ready_for_quit, shell);

	g_object_add_weak_pointer (
		G_OBJECT (shell->priv->preparing_for_quit),
		&shell->priv->preparing_for_quit);

	g_signal_emit (
		shell, signals[PREPARE_FOR_QUIT], 0,
		shell->priv->preparing_for_quit);

	g_object_unref (shell->priv->preparing_for_quit);

	/* Desensitize all watched windows to prevent user action. */
	list = gtk_application_get_windows (application);
	for (iter = list; iter != NULL; iter = iter->next)
		gtk_widget_set_sensitive (GTK_WIDGET (iter->data), FALSE);
}
Example #6
0
GdkPixbuf *
nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo  *icon)
{
	GdkPixbuf *res;

	if (icon->pixbuf == NULL) {
		res = NULL;
	} else {
		res = g_object_ref (icon->pixbuf);

		if (icon->sole_owner) {
			icon->sole_owner = FALSE;
			g_object_add_toggle_ref (G_OBJECT (res),
						 pixbuf_toggle_notify,
						 icon);
		}
	}
	
	return res;
}
/**
 * nm_supplicant_manager_create_interface:
 * @self: the #NMSupplicantManager
 * @ifname: the interface for which to obtain the supplicant interface
 * @is_wireless: whether the interface is supposed to be wireless.
 *
 * Note: the manager owns a reference to the instance and the only way to
 *   get the manager to release it, is by dropping all other references
 *   to the supplicant-interface (or destroying the manager).
 *
 * Retruns: (transfer-full): returns a #NMSupplicantInterface or %NULL.
 *   Must be unrefed at the end.
 * */
NMSupplicantInterface *
nm_supplicant_manager_create_interface (NMSupplicantManager *self,
                                        const char *ifname,
                                        gboolean is_wireless)
{
	NMSupplicantManagerPrivate *priv;
	NMSupplicantInterface *iface;
	GSList *ifaces;

	g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL);
	g_return_val_if_fail (ifname != NULL, NULL);

	priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);

	nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname);

	/* assert against not requesting duplicate interfaces. */
	for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) {
		if (g_strcmp0 (nm_supplicant_interface_get_ifname (ifaces->data), ifname) == 0)
			g_return_val_if_reached (NULL);
	}

	iface = nm_supplicant_interface_new (ifname,
	                                     is_wireless,
	                                     priv->fast_supported,
	                                     priv->ap_support);

	priv->ifaces = g_slist_prepend (priv->ifaces, iface);
	g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self);

	/* If we're making the supplicant take a time out for a bit, don't
	 * let the supplicant interface start immediately, just let it hang
	 * around in INIT state until we're ready to talk to the supplicant
	 * again.
	 */
	if (is_available (self))
		nm_supplicant_interface_set_supplicant_available (iface, TRUE);

	return iface;
}