static void
gom_application_refresh_db_cb (GObject *source,
                               GAsyncResult *res,
                               gpointer user_data)
{
  GomApplication *self;
  GDBusMethodInvocation *invocation = user_data;
  GError *error = NULL;

  self = GOM_APPLICATION (g_application_get_default ());
  g_application_release (G_APPLICATION (self));
  self->refreshing = FALSE;

  gom_miner_refresh_db_finish (GOM_MINER (source), res, &error);
  if (error != NULL)
    {
      g_printerr ("Failed to refresh the DB cache: %s\n", error->message);
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  gom_dbus_complete_refresh_db (self->skeleton, invocation);

 out:
  g_object_unref (invocation);
  gom_application_process_queue (self);
}
static void
gom_application_insert_shared_content_cb (GObject *source,
                                          GAsyncResult *res,
                                          gpointer user_data)
{
  GomApplication *self;
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  GError *error;

  self = GOM_APPLICATION (g_application_get_default ());
  g_application_release (G_APPLICATION (self));

  error = NULL;
  if (!gom_miner_insert_shared_content_finish (GOM_MINER (source), res, &error))
    {
      g_printerr ("Failed to insert shared content: %s\n", error->message);
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  gom_dbus_complete_insert_shared_content (self->skeleton, invocation);

 out:
  g_object_unref (invocation);
}
Beispiel #3
0
static void
photos_search_provider_fetch_ids_executed (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  GApplication *app;
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  PhotosFetchIdsJob *job = PHOTOS_FETCH_IDS_JOB (source_object);
  GError *error = NULL;
  GVariant *parameters;
  const gchar *const *ids;

  app = g_application_get_default ();
  g_application_release (app);

  ids = photos_fetch_ids_job_finish (job, res, &error);
  if (error != NULL)
    {
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  parameters = g_variant_new ("(^as)", ids);
  g_dbus_method_invocation_return_value (invocation, parameters);

 out:
  g_object_unref (invocation);
}
Beispiel #4
0
static void
photos_search_provider_return_metas_from_cache (PhotosSearchProvider *self,
                                                const gchar *const *identifiers,
                                                GDBusMethodInvocation *invocation)
{
  GApplication *app;
  GVariantBuilder builder;
  guint i;

  g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));

  for (i = 0; identifiers[i] != NULL; i++)
    {
      PhotosFetchMeta *meta;
      const gchar *id = identifiers[i];

      meta = (PhotosFetchMeta *) g_hash_table_lookup (self->cache, id);
      if (meta == NULL)
        continue;

      g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
      g_variant_builder_add (&builder, "{sv}", "id", g_variant_new_string (meta->id));
      g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (meta->title));
      if (meta->icon != NULL)
        g_variant_builder_add (&builder, "{sv}", "icon", g_icon_serialize (meta->icon));

      g_variant_builder_close (&builder);
    }

  app = g_application_get_default ();
  g_application_release (app);

  shell_search_provider2_complete_get_result_metas (self->skeleton, invocation, g_variant_builder_end (&builder));
}
static void
photos_thumbnailer_handle_generate_thumbnail_generate_thumbnail (GObject *source_object,
                                                                 GAsyncResult *res,
                                                                 gpointer user_data)
{
  PhotosThumbnailer *self = PHOTOS_THUMBNAILER (source_object);
  g_autoptr (GDBusMethodInvocation) invocation = G_DBUS_METHOD_INVOCATION (user_data);

  {
    g_autoptr (GError) error = NULL;

    if (!photos_thumbnailer_generate_thumbnail_finish (self, res, &error))
      {
        g_dbus_method_invocation_take_error (invocation, g_steal_pointer (&error));
        goto out;
      }
  }

  photos_thumbnailer_dbus_complete_generate_thumbnail (self->skeleton, invocation);

 out:
  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Completed GenerateThumbnail");
  g_application_release (G_APPLICATION (self));
  g_hash_table_remove (self->cancellables, invocation);
}
Beispiel #6
0
static gboolean
session_command_dispatch (EphySession *session)
{
	EphySessionPrivate *priv = session->priv;
	SessionCommand *cmd;
	gboolean run_again = TRUE;

	cmd = g_queue_pop_head (priv->queue);
	g_assert (cmd != NULL);

	LOG ("dispatching queue cmd:%d", cmd->command);

	switch (cmd->command)
	{
		case EPHY_SESSION_CMD_RESUME_SESSION:
			session_command_autoresume (session, cmd->user_time);
			break;
		case EPHY_SESSION_CMD_LOAD_SESSION:
			ephy_session_load (session, cmd->arg, cmd->user_time);
			break;
		case EPHY_SESSION_CMD_OPEN_BOOKMARKS_EDITOR:
			session_command_open_bookmarks_editor (session, cmd->user_time);
			break;
		case EPHY_SESSION_CMD_OPEN_URIS:
			session_command_open_uris (session, cmd->args, cmd->arg, cmd->user_time);
			break;
		case EPHY_SESSION_CMD_MAYBE_OPEN_WINDOW:
			/* FIXME: maybe just check for normal windows? */
			if (priv->windows == NULL &&
			    priv->tool_windows == NULL)
			{
				ephy_shell_new_tab_full (ephy_shell_get_default (),
							 NULL /* window */, NULL /* tab */,
							 NULL /* NetworkRequest */,
							 EPHY_NEW_TAB_IN_NEW_WINDOW |
							 EPHY_NEW_TAB_HOME_PAGE,
							 EPHY_WEB_VIEW_CHROME_ALL,
							 FALSE /* is popup? */,
							 cmd->user_time);
			}
			break;
		default:
			g_assert_not_reached ();
			break;
	}

	/* Look if there's anything else to dispatch */
	if (g_queue_is_empty (priv->queue))
	{
		priv->queue_idle_id = 0;
		run_again = FALSE;
	}

	g_application_release (G_APPLICATION (ephy_shell_get_default ()));

	/* This unrefs the shell! */
	session_command_free (cmd);

	return run_again;
}
static void
call_window_destroyed_cb (GtkWidget *window,
    EmpathyContact *contact)
{
  g_hash_table_remove (call_windows, contact);

  g_application_release (G_APPLICATION (app));
}
static void
release_application (AthenaProgressInfo *info,
                     AthenaProgressUIHandler *self)
{
    AthenaApplication *app;

    /* release the GApplication hold we acquired */
    app = athena_application_get_singleton ();
    g_application_release (G_APPLICATION (app));
}
Beispiel #9
0
static void
release_application (NemoProgressInfo *info,
		     NemoProgressUIHandler *self)
{
	NemoApplication *app;

	/* release the GApplication hold we acquired */
	app = nemo_application_get_singleton ();
	g_application_release (G_APPLICATION (app));
}
Beispiel #10
0
static void
account_manager_ready_for_accounts_cb (GObject *source_object,
    GAsyncResult *result,
    gpointer user_data)
{
  TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
  GError *error = NULL;
  GApplication *app = G_APPLICATION (user_data);

  if (!tp_proxy_prepare_finish (manager, result, &error))
    {
      DEBUG ("Failed to prepare account manager: %s", error->message);
      g_clear_error (&error);
      goto out;
    }

  if (selected_account_name != NULL)
    {
      gchar *account_path;
      TpAccount *account;

      /* create and prep the corresponding TpAccount so it's fully ready by the
       * time we try to select it in the accounts dialog */
      if (g_str_has_prefix (selected_account_name, TP_ACCOUNT_OBJECT_PATH_BASE))
        account_path = g_strdup (selected_account_name);
      else
        account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
            selected_account_name);

      account = find_account (manager, account_path);

      if (account != NULL)
        {
          empathy_accounts_show_accounts_ui (manager, account, app);
          goto out;
        }
      else
        {
          DEBUG ("Failed to find account with path %s", account_path);

          g_clear_error (&error);

          maybe_show_accounts_ui (manager, app);
        }

      g_free (account_path);
    }
  else
    {
      maybe_show_accounts_ui (manager, app);
    }

out:
  g_application_release (app);
}
Beispiel #11
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));
}
void
ges_validate_handle_request_state_change (GstMessage * message,
    GApplication * application)
{
  GstState state;

  gst_message_parse_request_state (message, &state);

  if (GST_IS_VALIDATE_SCENARIO (GST_MESSAGE_SRC (message))
      && state == GST_STATE_NULL) {
    gst_validate_printf (GST_MESSAGE_SRC (message),
        "State change request NULL, " "quiting application\n");
    g_application_release (application);
  }
}
Beispiel #13
0
static void
on_run_state_changed (NemoDesktopManager *manager)
{
    g_return_if_fail (NEMO_IS_DESKTOP_MANAGER (manager));

    FETCH_PRIV (manager);
    RunState new_state;

    DEBUG ("New run state...");

    /* If we're already running (showing icons,) there's no
     * change in behavior, we just keep showing. */
    if (priv->current_run_state == RUN_STATE_RUNNING) {
        return;
    }

    new_state = get_run_state (manager);

    /* If our state is INIT, we're waiting for the proxy to
     * get picked up (cinnamon starting) and still within our
     * failsafe timeout, so we just return */
    if (new_state == RUN_STATE_INIT) {
        priv->current_run_state = new_state;
        return;
    }

    /* If our state is STARTUP, RUNNING, or FAILSAFE, we can
     * cancel our failsafe timer.  We've either gotten a proxy
     * owner, given up waiting, or are now running */
    if (new_state > RUN_STATE_INIT) {
        if (priv->failsafe_timeout_id > 0) {
            g_source_remove (priv->failsafe_timeout_id);
            priv->failsafe_timeout_id = 0;
        }
    }

    /* RUNNING or FALLBACK is the final endpoint of the desktop startup
     * sequence.  Either way we trigger the desktop to start and release
     * our hold on the GApplication (the windows created in layout_changed
     * will keep the application alive from here on out.) */
    if (new_state == RUN_STATE_RUNNING || new_state == RUN_STATE_FALLBACK) {
        priv->current_run_state = new_state;
        layout_changed (manager);
        g_application_release (G_APPLICATION (nemo_application_get_singleton ()));
    }
}
static gboolean
query_completed_cb (GcalShellSearchProvider *search_provider,
                    GcalManager             *manager)
{
  GcalShellSearchProviderPrivate *priv = search_provider->priv;
  GList *events, *l;
  GVariantBuilder builder;
  time_t current_time_t;

  g_hash_table_remove_all (priv->events);

  events = gcal_manager_get_shell_search_events (priv->manager);
  if (events == NULL)
    {
      g_dbus_method_invocation_return_value (priv->pending_search->invocation, g_variant_new ("(as)", NULL));
      goto out;
    }

  g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));

  current_time_t = time (NULL);
  events = g_list_sort_with_data (events, (GCompareDataFunc) sort_event_data, &current_time_t);
  for (l = events; l != NULL; l = g_list_next (l))
    {
      const gchar *uid;

      uid = gcal_event_get_uid (l->data);

      if (g_hash_table_contains (priv->events, uid))
        continue;

      g_variant_builder_add (&builder, "s", uid);

      g_hash_table_insert (priv->events, g_strdup (uid), l->data);
    }
  g_list_free (events);

  g_dbus_method_invocation_return_value (priv->pending_search->invocation, g_variant_new ("(as)", &builder));

out:
  g_object_unref (priv->pending_search->invocation);
  g_strfreev (priv->pending_search->terms);
  g_clear_pointer (&(priv->pending_search), g_free);
  g_application_release (g_application_get_default ());
  return FALSE;
}
static void
save_pixbuf_handle_success (ScreenshotApplication *self)
{
  set_recent_entry (self);

  if (screenshot_config->interactive)
    {
      ScreenshotDialog *dialog = self->priv->dialog;

      save_folder_to_settings (self);
      gtk_widget_destroy (dialog->dialog);
    }
  else
    {
      g_application_release (G_APPLICATION (self));
    }
}
static void
schedule_search (GcalShellSearchProvider *search_provider,
                 GDBusMethodInvocation   *invocation,
                 gchar                  **terms)
{
  GcalShellSearchProviderPrivate *priv = search_provider->priv;

  /* don't attempt searches for a single character */
  if (g_strv_length (terms) == 1 && g_utf8_strlen (terms[0], -1) == 1)
    {
      g_dbus_method_invocation_return_value (invocation, g_variant_new ("(as)", NULL));
      return;
    }

  if (priv->pending_search != NULL)
    {
      g_object_unref (priv->pending_search->invocation);
      g_strfreev (priv->pending_search->terms);

      if (priv->scheduled_search_id == 0)
        g_application_release (g_application_get_default ());
    }
  else
    {
      priv->pending_search = g_new0 (PendingSearch, 1);
    }

  if (priv->scheduled_search_id != 0)
    {
      g_source_remove (priv->scheduled_search_id);
      priv->scheduled_search_id = 0;
    }

  priv->pending_search->invocation = g_object_ref (invocation);
  priv->pending_search->terms = g_strdupv (terms);

  if (!gcal_manager_load_completed (priv->manager))
    {
      priv->scheduled_search_id = g_timeout_add_seconds (1, (GSourceFunc) execute_search, search_provider);
      return;
    }

  execute_search (search_provider);
  return;
}
static gboolean
application_service_timeout_cb (gpointer data)
{
  g_autoptr(IdeApplication) self = data;

  g_assert (IDE_IS_APPLICATION (self));

  /*
   * We have a reference and a hold on the #IdeApplication as we are waiting
   * for operations to be received via DBus. If we got any requests, for
   * something like Activate(), we'll already have another hold on the
   * application for the window. Therefore, all we should need to do is drop
   * the application hold we took before registering our timeout.
   */
  g_application_release (G_APPLICATION (self));

  return G_SOURCE_REMOVE;
}
Beispiel #18
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;
}
Beispiel #19
0
void
sflphone_quit(gboolean force_quit, SFLPhoneClient *client)
{
    if (force_quit || calllist_get_size(current_calls_tab) == 0 || main_window_ask_quit(client)) {
        dbus_unregister(getpid());
        dbus_clean();
        account_list_free();
        calllist_clean(current_calls_tab);
        calllist_clean(contacts_tab);
        calllist_clean(history_tab);
        free_addressbook();

#if GLIB_CHECK_VERSION(2,32,0)
        g_application_quit(G_APPLICATION(client));
#else
        g_application_release(G_APPLICATION(client));
#endif
    }
}
static void
rectangle_found_cb (GdkRectangle *rectangle,
                    gpointer user_data)
{
  ScreenshotApplication *self = user_data;

  if (rectangle != NULL)
    {
      finish_prepare_screenshot (self, rectangle);
    }
  else
    {
      /* user dismissed the area selection, possibly show the dialog again */
      g_application_release (G_APPLICATION (self));

      if (screenshot_config->interactive)
        screenshot_show_interactive_dialog (self);
    }
}
static void
write_diagnostics_cb (GObject      *source,
                      GAsyncResult *result,
                      gpointer      user_data)
{
  g_autoptr(GisFinishedPage) self = GIS_FINISHED_PAGE (user_data);
  GisFinishedPagePrivate *priv = gis_finished_page_get_instance_private (self);
  g_autoptr(GError) error = NULL;
  g_autoptr(GFile) output = gis_write_diagnostics_finish (result, &error);

  g_application_release (G_APPLICATION (GIS_PAGE (self)->driver));

  if (output != NULL)
    {
      g_autofree gchar *basename_ = g_file_get_basename (output);
      g_autofree gchar *link = NULL;
      g_autofree gchar *markup = NULL;

      if (priv->gedit != NULL)
        {
          g_assert (error == NULL);
          g_autofree gchar *url = g_file_get_uri (output);

          link = g_markup_printf_escaped ("<a href=\"%s\">%s</a>",
                                          url, basename_);
        }
      else
        {
          link = g_strdup (basename_);
        }

      markup = g_strdup_printf (_("A debug log has been saved as %s."), link);
      gtk_label_set_markup (priv->diagnostics_label, markup);
    }
  else if (error != NULL)
    {
      g_prefix_error (&error, _("Failed to save debug log: "));
      gtk_label_set_text (priv->diagnostics_label, error->message);
      g_warning ("%s: %s", G_STRFUNC, error->message);
    }
  /* else, both possible target directories were NULL */
}
static void
ide_application_run_tests_cb (GObject      *object,
                              GAsyncResult *result,
                              gpointer      user_data)
{
  AsyncTest *test = user_data;
  GError *error = NULL;
  gboolean ret;

  ret = test->test_completion (result, &error);
  g_assert_no_error (error);
  g_assert (ret == TRUE);

  if (test->self->test_funcs)
    ide_application_run_next_test (test->self);
  else
    g_application_release (G_APPLICATION (test->self));

  g_clear_pointer (&test->name, g_free);
  g_clear_object (&test->self);
  g_slice_free (AsyncTest, test);
}
Beispiel #23
0
void
sflphone_quit(gboolean force_quit, SFLPhoneClient *client)
{
    if (force_quit || calllist_get_size(current_calls_tab) == 0 || main_window_ask_quit(client)) {
        dbus_unregister(getpid());
        dbus_clean();
        account_list_free();
        calllist_clean(current_calls_tab);
        calllist_clean(contacts_tab);
        calllist_clean(history_tab);
        free_addressbook();

        // make sure all open dialogs get a response signal so that they can close
        GList* top_level_windows = gtk_window_list_toplevels();
        g_list_foreach(top_level_windows, (GFunc)send_response_to_dialogs, NULL);

#if GLIB_CHECK_VERSION(2,32,0)
        g_application_quit(G_APPLICATION(client));
#else
        g_application_release(G_APPLICATION(client));
#endif
    }
}
Beispiel #24
0
static gboolean
service_timeout_cb (gpointer user_data)
{
	g_application_release (G_APPLICATION (user_data));
	return FALSE;
}
static void
save_pixbuf_handle_error (ScreenshotApplication *self,
                          GError *error)
{
  if (!g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") || screenshot_config->interactive)
    {
      ScreenshotDialog *dialog = self->priv->dialog;

      screenshot_dialog_set_busy (dialog, FALSE);

      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS) &&
          !self->priv->should_overwrite)
        {
          gchar *folder = screenshot_dialog_get_folder (dialog);
          gchar *folder_uri = g_path_get_basename (folder);
          gchar *folder_name = g_uri_unescape_string (folder_uri, NULL);
          gchar *file_name = screenshot_dialog_get_filename (dialog);
          gchar *detail = g_strdup_printf (_("A file named \"%s\" already exists in \"%s\""),
                                           file_name, folder_name);
          gint response;
                                             
          response = screenshot_show_dialog (GTK_WINDOW (dialog->dialog),
                                             GTK_MESSAGE_WARNING,
                                             GTK_BUTTONS_YES_NO,
                                             _("Overwrite existing file?"),
                                             detail);

          g_free (folder);
          g_free (folder_name);
          g_free (folder_uri);
          g_free (file_name);
          g_free (detail);

          if (response == GTK_RESPONSE_YES)
            {
              self->priv->should_overwrite = TRUE;
              screenshot_save_to_file (self);

              return;
            }
        }
      else
        {
          screenshot_show_dialog (GTK_WINDOW (dialog->dialog),
                                  GTK_MESSAGE_ERROR,
                                  GTK_BUTTONS_OK,
                                  _("Unable to capture a screenshot"),
                                  _("Error creating file. Please choose another location and retry."));
        }

      gtk_widget_grab_focus (dialog->filename_entry);
    }
  else
    {
      g_critical ("Unable to save the screenshot: %s", error->message);
      screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot"));
      g_application_release (G_APPLICATION (self));
      if (screenshot_config->file != NULL)
        exit (EXIT_FAILURE);
    }
}
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;
}
static void
finish_prepare_screenshot (ScreenshotApplication *self,
                           GdkRectangle *rectangle)
{
  GdkPixbuf *screenshot;

  screenshot = screenshot_get_pixbuf (rectangle);

  if (screenshot == NULL)
    {
      g_critical ("Unable to capture a screenshot of any window");

      if (screenshot_config->interactive)
        screenshot_show_dialog (NULL,
                                GTK_MESSAGE_ERROR,
                                GTK_BUTTONS_OK,
                                _("Unable to capture a screenshot"),
                                _("All possible methods failed"));
      else
        screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot"));

      g_application_release (G_APPLICATION (self));
      if (screenshot_config->file != NULL)
        exit (EXIT_FAILURE);

      return;
    }

  if (screenshot_config->take_window_shot)
    {
      switch (screenshot_config->border_effect[0])
        {
        case 's': /* shadow */
          screenshot_add_shadow (&screenshot);
          break;
        case 'b': /* border */
          screenshot_add_border (&screenshot);
          break;
        case 'n': /* none */
        default:
          break;
        }
    }

  self->priv->screenshot = screenshot;

  if (screenshot_config->copy_to_clipboard)
    {
      screenshot_save_to_clipboard (self);
      screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));

      g_application_release (G_APPLICATION (self));

      return;
    }

  /* FIXME: apply the ICC profile according to the preferences.
   * org.gnome.ColorManager.GetProfileForWindow() does not exist anymore,
   * so we probably need to fetch the color profile of the screen where
   * the area/window was.
   *
   * screenshot_ensure_icc_profile (window);
   */
  if (screenshot_config->file != NULL)
    {
      self->priv->save_uri = g_file_get_uri (screenshot_config->file);
      self->priv->should_overwrite = TRUE;
      screenshot_save_to_file (self);
    }
  else
    screenshot_build_filename_async (screenshot_config->save_dir, NULL, build_filename_ready_cb, self);
}
Beispiel #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);
    }
}
Beispiel #30
0
/**
 * gpk_log_button_close_cb:
 **/
static void
gpk_log_button_close_cb (GtkWidget *widget, GtkApplication *application)
{
	g_application_release (G_APPLICATION (application));
}