static void
screenshot_start (ScreenshotApplication *self)
{
  guint delay = screenshot_config->delay * 1000;

  /* hold the GApplication while doing the async screenshot op */
  g_application_hold (G_APPLICATION (self));

  if (screenshot_config->take_area_shot)
    delay = 0;

  /* HACK: give time to the dialog to actually disappear.
   * We don't have any way to tell when the compositor has finished 
   * re-drawing.
   */
  if (delay == 0 && screenshot_config->interactive)
    delay = 200;

  if (delay > 0)
    g_timeout_add (delay,
                   prepare_screenshot_timeout,
                   self);
  else
    g_idle_add (prepare_screenshot_timeout, self);
}
示例#2
0
static void
activate_cb (GApplication *application)
{
  GError *error = NULL;

  if (activated)
    return;

  activated = TRUE;

  if (!use_timer)
    {
      /* keep a 'ref' to the application */
      g_application_hold (G_APPLICATION (app));
    }

  g_assert (call_factory == NULL);
  call_factory = empathy_call_factory_initialise ();

  g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
      G_CALLBACK (new_call_handler_cb), NULL);
  g_signal_connect (G_OBJECT (call_factory), "incoming-call",
      G_CALLBACK (incoming_call_cb), NULL);

  if (!empathy_call_factory_register (call_factory, &error))
    {
      g_critical ("Failed to register Handler: %s", error->message);
      g_error_free (error);
    }
}
示例#3
0
static gboolean
photos_search_provider_get_subsearch_result_set (PhotosSearchProvider *self,
                                                 GDBusMethodInvocation *invocation,
                                                 const gchar *const *previous_results,
                                                 const gchar *const *terms)
{
  GApplication *app;
  PhotosFetchIdsJob *job;

  app = g_application_get_default ();
  g_application_hold (app);

  g_cancellable_cancel (self->cancellable);
  g_cancellable_reset (self->cancellable);

  job = photos_fetch_ids_job_new (terms);
  photos_fetch_ids_job_run (job,
                            self->state,
                            self->cancellable,
                            photos_search_provider_fetch_ids_executed,
                            g_object_ref (invocation));
  g_object_unref (job);

  return TRUE;
}
示例#4
0
gint
main (gint argc, gchar *argv[])
{
  GtkApplication *app;
  PhotosRemoteDisplayManager *remote_display_mngr;
  gint exit_status;

  setlocale (LC_ALL, "");

  photos_debug_init ();

  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  g_set_prgname (PACKAGE_TARNAME);

  app = photos_application_new ();
  if (g_getenv ("GNOME_PHOTOS_PERSIST") != NULL)
    g_application_hold (G_APPLICATION (app));

  remote_display_mngr = photos_remote_display_manager_dup_singleton ();
  exit_status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (remote_display_mngr);
  g_object_unref (app);

  return exit_status;
}
static void
gom_application_process_queue (GomApplication *self)
{
  GDBusMethodInvocation *invocation = NULL;
  const gchar **index_types;

  if (self->refreshing)
    goto out;

  if (g_queue_is_empty (self->queue))
    goto out;

  invocation = G_DBUS_METHOD_INVOCATION (g_queue_pop_head (self->queue));
  index_types = g_object_get_data (G_OBJECT (invocation), "index-types");
  gom_miner_set_index_types (self->miner, index_types);

  self->refreshing = TRUE;
  g_application_hold (G_APPLICATION (self));
  gom_miner_refresh_db_async (self->miner,
                              self->cancellable,
                              gom_application_refresh_db_cb,
                              g_object_ref (invocation));

 out:
  g_clear_object (&invocation);
}
示例#6
0
static void
new_call_handler_cb (EmpathyCallFactory *factory,
    EmpathyCallHandler *handler,
    gboolean outgoing,
    gpointer user_data)
{
  EmpathyCallWindow *window;
  EmpathyContact *contact;

  DEBUG ("Show the call window");

  contact = empathy_call_handler_get_contact (handler);

  window = g_hash_table_lookup (call_windows, contact);

  if (window != NULL)
    {
      empathy_call_window_present (window, handler);
    }
  else
    {
      window = empathy_call_window_new (handler);

      g_hash_table_insert (call_windows, g_object_ref (contact), window);
      g_application_hold (G_APPLICATION (app));
      g_signal_connect (window, "destroy",
          G_CALLBACK (call_window_destroyed_cb), contact);

      gtk_widget_show (GTK_WIDGET (window));
    }
}
示例#7
0
static void
activate_cb (GApplication *application)
{
  if (!use_timer && !activated)
    {
      /* keep a 'ref' to the application */
      g_application_hold (G_APPLICATION (application));
      activated = TRUE;
    }
}
示例#8
0
int
main (int argc, char *argv[])
{
    gint retval;
    NautilusApplication *application;

#if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD)
    /* Nautilus uses lots and lots of small and medium size allocations,
     * and then a few large ones for the desktop background. By default
     * glibc uses a dynamic treshold for how large allocations should
     * be mmaped. Unfortunately this triggers quickly for nautilus when
     * it does the desktop background allocations, raising the limit
     * such that a lot of temporary large allocations end up on the
     * heap and are thus not returned to the OS. To fix this we set
     * a hardcoded limit. I don't know what a good value is, but 128K
     * was the old glibc static limit, lets use that.
     */
    mallopt (M_MMAP_THRESHOLD, 128 *1024);
#endif

    /* This will be done by gtk+ later, but for now, force it to GNOME */
    g_desktop_app_info_set_desktop_env ("GNOME");

    if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
        eel_make_warnings_and_criticals_stop_in_debugger ();
    }

    /* Initialize gettext support */
    bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    g_set_prgname ("nautilus");

#ifdef HAVE_EXEMPI
    xmp_init();
#endif

    /* Run the nautilus application. */
    application = nautilus_application_new ();

    /* hold indefinitely if we're asked to persist */
    if (g_getenv ("NAUTILUS_PERSIST") != NULL) {
        g_application_hold (G_APPLICATION (application));
    }

    retval = g_application_run (G_APPLICATION (application),
                                argc, argv);

    g_object_unref (application);

    eel_debug_shut_down ();

    return retval;
}
示例#9
0
static void
handled_chats_changed_cb (EmpathyChatManager *mgr,
    guint nb_chats,
    gpointer user_data)
{
  DEBUG ("New chat count: %u", nb_chats);

  if (nb_chats == 0)
    g_application_release (G_APPLICATION (app));
  else
    g_application_hold (G_APPLICATION (app));
}
示例#10
0
static gboolean
photos_search_provider_get_result_metas (PhotosSearchProvider *self,
                                         GDBusMethodInvocation *invocation,
                                         const gchar *const *identifiers)
{
  GApplication *app;
  GPtrArray *to_fetch_arr;
  const gchar *const *to_fetch;
  guint i;
  guint n_identifiers;
  guint n_to_fetch;

  app = g_application_get_default ();
  g_application_hold (app);

  n_identifiers = g_strv_length ((gchar **) identifiers);
  to_fetch_arr = g_ptr_array_sized_new (n_identifiers + 1);

  for (i = 0; identifiers[i] != NULL; i++)
    {
      if (g_hash_table_lookup (self->cache, identifiers[i]) == NULL)
        g_ptr_array_add (to_fetch_arr, (gpointer) identifiers[i]);
    }

  g_ptr_array_add (to_fetch_arr, NULL);
  to_fetch = (const gchar * const *) to_fetch_arr->pdata;

  n_to_fetch = g_strv_length ((gchar **) to_fetch);
  if (n_to_fetch > 0)
    {
      PhotosFetchMetasJob *job;

      job = photos_fetch_metas_job_new (to_fetch);
      g_object_set_data_full (G_OBJECT (invocation),
                              "identifiers",
                              g_boxed_copy (G_TYPE_STRV, identifiers),
                              (GDestroyNotify) g_strfreev);
      g_object_set_data_full (G_OBJECT (invocation), "self", g_object_ref (self), g_object_unref);
      photos_fetch_metas_job_run (job,
                                  self->state,
                                  photos_search_provider_fetch_metas_executed,
                                  g_object_ref (invocation));
      g_object_unref (job);
    }
  else
    photos_search_provider_return_metas_from_cache (self, identifiers, invocation);

  g_ptr_array_unref (to_fetch_arr);

  return TRUE;
}
static gboolean
execute_search (GcalShellSearchProvider *search_provider)
{
  GcalShellSearchProviderPrivate *priv;

  guint i;
  gchar *search_query;

  icaltimezone *zone;
  time_t range_start, range_end;

  priv = search_provider->priv;

  if (!gcal_manager_load_completed (priv->manager))
    return TRUE;

  zone = gcal_manager_get_system_timezone (priv->manager);
  priv->pending_search->date = icaltime_current_time_with_zone (zone);
  icaltime_adjust (&(priv->pending_search->date), -7, 0, 0, 0); /* -1 weeks from today */
  range_start = icaltime_as_timet_with_zone (priv->pending_search->date, zone);

  icaltime_adjust (&(priv->pending_search->date), 21 * 2, 0, 0, 0); /* +3 weeks from today */
  range_end = icaltime_as_timet_with_zone (priv->pending_search->date, zone);

  gcal_manager_set_shell_search_subscriber (priv->manager, E_CAL_DATA_MODEL_SUBSCRIBER (search_provider),
                                            range_start, range_end);

  search_query = g_strdup_printf ("(or (contains? \"summary\" \"%s\") (contains? \"description\" \"%s\"))",
                                  priv->pending_search->terms[0], priv->pending_search->terms[0]);
  for (i = 1; i < g_strv_length (priv->pending_search->terms); i++)
    {
      gchar *complete_query;
      gchar *second_query = g_strdup_printf ("(or (contains? \"summary\" \"%s\") (contains? \"description\" \"%s\"))",
                                             priv->pending_search->terms[0], priv->pending_search->terms[0]);
      complete_query = g_strdup_printf ("(and %s %s)", search_query, second_query);

      g_free (second_query);
      g_free (search_query);

      search_query = complete_query;
    }

  gcal_manager_set_shell_search_query (priv->manager,  search_query);
  g_free (search_query);

  priv->scheduled_search_id = 0;
  g_application_hold (g_application_get_default ());
  return FALSE;
}
示例#12
0
static void
app_activate (GApplication *app)
{
  TpAccountManager *account_manager;

  empathy_gtk_init ();
  account_manager = tp_account_manager_dup ();

  /* Hold the application while preparing the AM */
  g_application_hold (app);

  tp_proxy_prepare_async (account_manager, NULL,
    account_manager_ready_for_accounts_cb, app);

  g_object_unref (account_manager);
}
static void
activate_cb (GApplication *app)
{
  if (window == NULL)
    {
      window = empathy_debug_window_new (NULL);
      g_signal_connect (window, "destroy", gtk_main_quit, NULL);

      /* don't let this application exit automatically */
      g_application_hold (G_APPLICATION (app));
    }
  else
    {
      gtk_window_present (GTK_WINDOW (window));
    }
}
void
ide_application_run_tests (IdeApplication *self)
{
  IDE_ENTRY;

  g_assert (IDE_IS_APPLICATION (self));

  if (self->test_funcs != NULL)
    {
      g_test_log_set_fatal_handler (fatal_log_handler, NULL);
      g_application_hold (G_APPLICATION (self));
      ide_application_run_next_test (self);
    }

  IDE_EXIT;
}
示例#15
0
static gboolean
photos_thumbnailer_handle_generate_thumbnail (PhotosThumbnailer *self,
                                              GDBusMethodInvocation *invocation,
                                              const gchar *uri,
                                              const gchar *mime_type,
                                              const gchar *orientation,
                                              gint64 original_height,
                                              gint64 original_width,
                                              GVariant *pipeline_uris_variant,
                                              const gchar *thumbnail_path,
                                              gint thumbnail_size)
{
  g_autoptr (GCancellable) cancellable = NULL;
  g_auto (GStrv) pipeline_uris = NULL;

  g_return_val_if_fail (PHOTOS_IS_THUMBNAILER (self), FALSE);
  g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
  g_return_val_if_fail (uri != NULL && uri[0] != '\0', FALSE);
  g_return_val_if_fail (mime_type != NULL && mime_type[0] != '\0', FALSE);
  g_return_val_if_fail (orientation != NULL && orientation[0] != '\0', FALSE);
  g_return_val_if_fail (g_variant_is_of_type (pipeline_uris_variant, G_VARIANT_TYPE ("as")), FALSE);
  g_return_val_if_fail (thumbnail_path != NULL && thumbnail_path[0] != '\0', FALSE);

  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Handling GenerateThumbnail for %s", uri);

  pipeline_uris = g_variant_dup_strv (pipeline_uris_variant, NULL);

  cancellable = g_cancellable_new ();
  g_hash_table_insert (self->cancellables, g_object_ref (invocation), g_object_ref (cancellable));

  g_application_hold (G_APPLICATION (self));
  photos_thumbnailer_generate_thumbnail_async (self,
                                               uri,
                                               mime_type,
                                               orientation,
                                               original_height,
                                               original_width,
                                               (const gchar *const *) pipeline_uris,
                                               thumbnail_path,
                                               thumbnail_size,
                                               cancellable,
                                               photos_thumbnailer_handle_generate_thumbnail_generate_thumbnail,
                                               g_object_ref (invocation));

  return TRUE;
}
示例#16
0
static gboolean
photos_thumbnailer_handle_cancel (PhotosThumbnailer *self,
                                  GDBusMethodInvocation *invocation,
                                  guint serial)
{
  GCancellable *cancellable;
  GDBusConnection *connection;
  GDBusMethodInvocation *invocation_ongoing;
  GHashTableIter iter;

  g_return_val_if_fail (PHOTOS_IS_THUMBNAILER (self), FALSE);
  g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);

  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Handling Cancel for %u", serial);
  g_application_hold (G_APPLICATION (self));

  connection = g_dbus_method_invocation_get_connection (invocation);

  g_hash_table_iter_init (&iter, self->cancellables);
  while (g_hash_table_iter_next (&iter, (gpointer *) &invocation_ongoing, (gpointer *) &cancellable))
    {
      GDBusConnection *connection_ongoing;
      GDBusMessage *message_ongoing;
      guint32 serial_ongoing;

      connection_ongoing = g_dbus_method_invocation_get_connection (invocation_ongoing);
      message_ongoing = g_dbus_method_invocation_get_message (invocation_ongoing);
      serial_ongoing = g_dbus_message_get_serial (message_ongoing);

      if (connection == connection_ongoing && (guint32) serial == serial_ongoing)
        {
          g_cancellable_cancel (cancellable);
          photos_thumbnailer_dbus_complete_cancel (self->skeleton, invocation);
          goto out;
        }
    }

  g_dbus_method_invocation_return_error_literal (invocation, PHOTOS_ERROR, 0, "Invalid serial");

 out:
  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Completed Cancel");
  g_application_release (G_APPLICATION (self));
  return TRUE;
}
示例#17
0
static gboolean
gom_application_insert_shared_content (GomApplication *self,
                                       GDBusMethodInvocation *invocation,
                                       const gchar *account_id,
                                       const gchar *shared_id,
                                       const gchar *shared_type,
                                       const gchar *source_urn)
{
  g_application_hold (G_APPLICATION (self));
  gom_miner_insert_shared_content_async (self->miner,
                                         account_id,
                                         shared_id,
                                         shared_type,
                                         source_urn,
                                         self->cancellable,
                                         gom_application_insert_shared_content_cb,
                                         g_object_ref (invocation));
  return TRUE;
}
示例#18
0
static void
new_call_handler_cb (EmpathyStreamedMediaFactory *factory,
    EmpathyStreamedMediaHandler *handler,
    gboolean outgoing,
    gpointer user_data)
{
  EmpathyStreamedMediaWindow *window;

  DEBUG ("Create a new StreamedMedia window");

  window = empathy_streamed_media_window_new (handler);

  g_application_hold (G_APPLICATION (app));

  g_signal_connect_swapped (window, "destroy",
      G_CALLBACK (g_application_release), app);

  gtk_widget_show (GTK_WIDGET (window));
}
示例#19
0
static void
progress_info_queued_cb (NemoProgressInfo *info,
			  NemoProgressUIHandler *self)
{
	NemoApplication *app;
	TimeoutData *data;

	/* hold GApplication so we never quit while there's an operation pending */
	app = nemo_application_get_singleton ();
	g_application_hold (G_APPLICATION (app));

	g_signal_connect (info, "finished",
			  G_CALLBACK (release_application), self);

	data = timeout_data_new (self, info);

	/* timeout for the progress window to appear */
	g_timeout_add_seconds (2,
			       (GSourceFunc) new_op_queued_timeout,
			       data);
}
static int
app_command_line_cb (GApplication *app,
    GApplicationCommandLine *cmdline)
{
  g_application_hold (app);

  /* if the window is ready, present it; otherwise, it will be presented when
   * the accounts manager is prepared */
  if (account_manager_prepared)
    {
      TpAccountManager *account_manager;

      account_manager = tp_account_manager_dup ();
      empathy_accounts_show_accounts_ui (account_manager, NULL,
              G_CALLBACK (gtk_main_quit));

      g_object_unref (account_manager);
    }

  return 0;
}
示例#21
0
static void
fr_application_register_archive_manager_service (FrApplication *self)
{
	gsize         size;
	guchar       *buffer;
	GInputStream *stream;
	gsize         bytes_read;
	GError       *error = NULL;

	g_application_hold (G_APPLICATION (self));

	g_resources_get_info (ORG_GNOME_ARCHIVEMANAGER_XML, 0, &size, NULL, NULL);
	buffer = g_new (guchar, size + 1);
	stream = g_resources_open_stream (ORG_GNOME_ARCHIVEMANAGER_XML, 0, NULL);
	if (g_input_stream_read_all (stream, buffer, size, &bytes_read, NULL, NULL)) {
		buffer[bytes_read] = '\0';

		self->introspection_data = g_dbus_node_info_new_for_xml ((gchar *) buffer, &error);
		if (self->introspection_data != NULL) {
			self->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
							 "org.gnome.ArchiveManager1",
							 G_BUS_NAME_OWNER_FLAGS_NONE,
							 on_bus_acquired_for_archive_manager,
							 NULL /*on_name_acquired*/,
							 NULL /*on_name_lost*/,
							 self,
							 NULL);
		}
		else {
			g_warning ("%s", error->message);
			g_clear_error (&error);
		}
	}

	g_timeout_add_seconds (SERVICE_TIMEOUT, service_timeout_cb, self);

	g_free (buffer);
}
示例#22
0
int
main (int argc,
      char **argv)
{
  GApplication *app;
  gint exit_status;

  tracker_sched_idle ();
  tracker_ioprio_init ();

  errno = 0;
  if (nice (19) == -1 && errno != 0)
    {
      const gchar *str;

      str = g_strerror (errno);
      g_warning ("Couldn't set nice value to 19, %s", (str != NULL) ? str : "no error given");
    }

  app = gom_application_new (MINER_BUS_NAME, MINER_TYPE);
  if (g_getenv (MINER_NAME "_MINER_PERSIST") != NULL)
    g_application_hold (app);

  g_unix_signal_add_full (G_PRIORITY_DEFAULT,
			  SIGTERM,
			  signal_handler_cb,
			  app, NULL);
  g_unix_signal_add_full (G_PRIORITY_DEFAULT,
			  SIGINT,
			  signal_handler_cb,
			  app, NULL);

  exit_status = g_application_run (app, argc, argv);
  g_object_unref (app);

  return exit_status;
}
示例#23
0
static void
na_application_activate (GApplication *application)
{
  NAApplication *self = NA_APPLICATION (application);
  //G_APPLICATION_CLASS (na_application_parent_class)->startup (application);

  get_devices (self);

  introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
  g_assert (introspection_data != NULL);

  g_application_hold (application);

  guint owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
                                   NETWORK_ANALYZER_DBUS_NAME,
                                   G_BUS_NAME_OWNER_FLAGS_NONE,
                                   on_bus_acquired,
                                   on_name_acquired,
                                   on_name_lost,
                                   self,
                                   NULL);

  g_assert (owner_id > 0);
}
示例#24
0
static void
nemo_desktop_manager_init (NemoDesktopManager *manager)
{
    NemoDesktopManagerPrivate *priv;

    manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, NEMO_TYPE_DESKTOP_MANAGER, NemoDesktopManagerPrivate);

    DEBUG ("Desktop Manager Initialization");

    priv = manager->priv;

    priv->scale_factor_changed_id = 0;
    priv->desktops = NULL;
    priv->desktop_on_primary_only = FALSE;

    priv->action_manager = nemo_action_manager_new ();

    priv->update_layout_idle_id = 0;

    g_signal_connect_swapped (nemo_desktop_preferences, 
                              "changed::" NEMO_PREFERENCES_SHOW_DESKTOP,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_desktop_preferences,
                              "changed::" NEMO_PREFERENCES_DESKTOP_LAYOUT,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_desktop_preferences,
                              "changed::" NEMO_PREFERENCES_USE_DESKTOP_GRID,
                              G_CALLBACK (queue_update_layout),
                              manager);

    /* Monitor the preference to have the desktop */
    /* point to the Unix home folder */

    g_signal_connect_swapped (nemo_preferences,
                              "changed::" NEMO_PREFERENCES_DESKTOP_IS_HOME_DIR,
                              G_CALLBACK (queue_update_layout),
                              manager);

    g_signal_connect_swapped (nemo_preferences,
                              "changed::" NEMO_PREFERENCES_SHOW_ORPHANED_DESKTOP_ICONS,
                              G_CALLBACK (queue_update_layout),
                              manager);

    /* If we're a cinnamon session, increase the use count temporarily for the application,
     * and establish a proxy for org.Cinnamon.  The hold prevents the GApplication from simply
     * exiting while waiting for the GAsyncReadyCallback.
     * 
     * If we're not running cinnamon,  */

    g_application_hold (G_APPLICATION (nemo_application_get_singleton ()));

    if (is_cinnamon_desktop ()) {
         g_message ("nemo-desktop: session is cinnamon, establishing proxy");

        nemo_cinnamon_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                                         G_DBUS_PROXY_FLAGS_NONE,
                                         "org.Cinnamon",
                                         "/org/Cinnamon",
                                         NULL,
                                         (GAsyncReadyCallback) on_proxy_created,
                                         manager);
    } else {
        g_message ("nemo-desktop: session is not cinnamon (checked XDG_SESSION_DESKTOP,"
                   "DESKTOP_SESSION environment variables.) Applying default behavior");

        priv->other_desktop = TRUE;
        connect_fallback_signals (manager);

        /* Even though we start immediately when we can't do a proxy, we need to get out
         * of the desktop manager's init first, or else we have recursion problems. */
        g_idle_add ((GSourceFunc) fallback_startup_idle_cb, manager);
    }
}
示例#25
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  EmpathyChatManager *chat_mgr;
  EmpathyIdle *idle;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Chat Client"));
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error))
    {
      g_print ("%s\nRun '%s --help' to see a full list of available command "
          "line options.\n",
          error->message, argv[0]);
      g_warning ("Error in empathy-av init: %s", error->message);
      return EXIT_FAILURE;
    }

  g_option_context_free (optcontext);

  empathy_gtk_init ();

  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_CHAT_DBUS_NAME, G_APPLICATION_IS_SERVICE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  /* Setting up Idle */
  idle = empathy_idle_dup_singleton ();

  chat_mgr = empathy_chat_manager_dup_singleton ();

  g_signal_connect (chat_mgr, "handled-chats-changed",
      G_CALLBACK (handled_chats_changed_cb), GUINT_TO_POINTER (1));

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  DEBUG ("Waiting for text channels to handle");

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  g_object_unref (idle);
  g_object_unref (chat_mgr);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
示例#26
0
static void
gis_finished_page_shown (GisPage *page)
{
  GisFinishedPage *self = GIS_FINISHED_PAGE (page);
  GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (self);
  GError *error = gis_store_get_error();

  gis_driver_save_data (GIS_PAGE (page)->driver);

  if (error != NULL)
    {
      GisAssistant *assistant = gis_driver_get_assistant (page->driver);
      const gchar *heading = NULL;
      const gchar *detail = error->message;

      g_warning ("%s: %s %d %s", G_STRFUNC,
                 g_quark_to_string (error->domain), error->code, error->message);

      if (error->domain == GIS_UNATTENDED_ERROR)
        {
          heading = _("Oops, something is wrong with your unattended installation configuration.");
        }
      else if (error->domain == GIS_IMAGE_ERROR)
        {
          heading = _("Oops, something is wrong with your Endless OS file.");
        }
      else if (error->domain == GIS_DISK_ERROR)
        {
          heading = _("Oops, something went wrong while finding suitable disks to reformat.");
        }
      else if (error->domain == GIS_INSTALL_ERROR)
        {
          heading = _("Oops, something went wrong while reformatting.");
        }
      else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
          heading = error->message;
          detail = NULL;
          gtk_widget_hide (GTK_WIDGET (priv->error_label));
          gtk_widget_hide (GTK_WIDGET (priv->diagnostics_label));
          gtk_widget_hide (GTK_WIDGET (priv->support_label));
        }
      else
        {
          heading = _("Oops, something went wrong.");
        }

      if (heading != NULL)
        gtk_label_set_text (priv->error_heading_label, heading);

      if (detail != NULL)
        gtk_label_set_text (priv->error_label, detail);

      gtk_widget_show (priv->error_box);
      gtk_widget_hide (priv->success_box);
      gis_assistant_locale_changed (assistant);

      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
          /* Running eos-diagnostics can be slow enough that we can't do it
           * synchronously on the UI thread.
           */
          GFile *image_dir = G_FILE (gis_store_get_object (GIS_STORE_IMAGE_DIR));
          /* See implementation of gis_write_diagnostics_async for rationale. */
          const gchar *home_dir = priv->gedit != NULL ? g_get_home_dir () : NULL;

          g_application_hold (G_APPLICATION (page->driver));
          gis_write_diagnostics_async (NULL, image_dir, home_dir,
                                       NULL, write_diagnostics_cb,
                                       g_object_ref (self));
        }

      if (gis_store_is_unattended())
        {
          g_timeout_add_seconds (1, (GSourceFunc)toggle_leds, page);
        }

      /* If running within a live session, hide the "Turn off" button on error,
       * since we have a perfectly good [X] button on the titlebar and we want
       * to encourage the user to notice the link to the diagnostics file.
       */
      GisDriverMode mode = gis_driver_get_mode (GIS_PAGE (self)->driver);
      gtk_widget_set_visible (GTK_WIDGET (priv->restart_button),
                              mode == GIS_DRIVER_MODE_NEW_USER);
    }
  else
    {
      gboolean optical = is_eosdvd ();

      gtk_widget_set_visible (priv->removelabel_usb, !optical);
      gtk_widget_set_visible (priv->removelabel_dvd,  optical);
    }
}
示例#27
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
    g_print ("%s\nRun '%s --help' to see a full list of available command "
        "line options.\n",
        error->message, argv[0]);
    g_warning ("Error in empathy-av init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);

  /* Make empathy and empathy-av appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
示例#28
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;
  GtkSettings *gtk_settings;

  /* Init */
  g_thread_init (NULL);

#ifdef GDK_WINDOWING_X11
  /* We can't call clutter_gst_init() before gtk_clutter_init(), so no choice
   * but to intiialise X11 threading ourself */
  XInitThreads ();
#endif

  /* Clutter needs this */
  gdk_disable_multidevice ();

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_group (optcontext, cogl_get_option_group ());
  g_option_context_add_group (optcontext,
      clutter_get_option_group_without_init ());
  g_option_context_add_group (optcontext, gtk_clutter_get_option_group ());
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
    g_print ("%s\nRun '%s --help' to see a full list of available command "
        "line options.\n",
        error->message, argv[0]);
    g_warning ("Error in empathy-call init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));

  /* Make empathy and empathy-call appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  gtk_settings = gtk_settings_get_default ();
  g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme",
      TRUE, NULL);

  app = gtk_application_new (EMPATHY_CALL_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  call_windows = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      g_object_unref, NULL);

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_hash_table_unref (call_windows);
  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
static void
build_filename_ready_cb (GObject *source,
                         GAsyncResult *res,
                         gpointer user_data)
{
  ScreenshotApplication *self = user_data;
  GError *error = NULL;
  char *save_path;

  save_path = screenshot_build_filename_finish (res, &error);
  if (save_path != NULL)
    {
      GFile *file;

      file = g_file_new_for_path (save_path);
      g_free (save_path);

      self->priv->save_uri = g_file_get_uri (file);
      g_object_unref (file);
    }
  else
    self->priv->save_uri = NULL;

  /* now release the application */
  g_application_release (G_APPLICATION (self));

  if (error != NULL)
    {
      g_critical ("Impossible to find a valid location to save the screenshot: %s",
                  error->message);
      g_error_free (error);

      if (screenshot_config->interactive)
        screenshot_show_dialog (NULL,
                                GTK_MESSAGE_ERROR,
                                GTK_BUTTONS_OK,
                                _("Unable to capture a screenshot"),
                                _("Error creating file"));
      else
        {
          screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot"));
          if (screenshot_config->file != NULL)
            exit (EXIT_FAILURE);
        }

      return;
    }

  screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));

  if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") || screenshot_config->interactive)
    {
      self->priv->dialog = screenshot_dialog_new (self->priv->screenshot, self->priv->save_uri);
      g_signal_connect (self->priv->dialog->dialog,
                        "response",
                        G_CALLBACK (screenshot_dialog_response_cb),
                        self);
    }
  else
    {
      g_application_hold (G_APPLICATION (self));
      screenshot_save_to_file (self);
    }
}