Skip to content
Snippets Groups Projects

Fix screenshot finalize behavior for plugin

Merged Andre Miranda requested to merge andreldm/xfce4-screenshooter:issue-96 into master
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • assigned to @andreldm

  • mentioned in issue #96 (closed)

    • @Tamaranch could you please review? I'm not entirely happy with my solution, I've tried to use GTasks but they can only be completed once, meaning I would need to be instaciating and unrefing. Suggestions are very welcome :grin:

    • I'm having a little trouble figuring out what would be expected/what is achieved, but it seems to work well. The plugin button is insensitive during the screenshot, which is certainly better.

      For GTask yes the idea is to instantiate one per task, how is that a problem?

    • Sorry, I should have provided some context: originally the plugin button was correctly made insensitive and sensitive when the screenshot was done, over the years I changed screenshooter_take_screenshot to be non blocking to fix some nasty bugs (I don't remember what). Now what was requested is to store the last unused save directory, it would be super easy if that function was still blocking.

      For GTask yes the idea is to instantiate one per task, how is that a problem?

      I think I would be abusing it for this scenario and would need to keep track of their lifecycle (risk of leaks). I also considered GClosure but it needed a marshaller, I couldn't figure out how to make it work.

      In the end what I really wanted was a simple callback, which is different for the main application and plugin, while the latter needs a reference to a struct (PluginData), in C++ that could be a capturing lambda.

    • I don't see why you should care about the lifecycle of the GTask, if you use it like this normally you don't need to worry about it:

      cancellable = g_cancellable_new ();                        
      task = g_task_new (object, cancellable, callback, data);
      g_task_run_in_thread (task, task_func);
      g_object_unref (task);
      g_object_unref (cancellable);

      That said the current change produces understandable code so if it works properly there may be no need to do otherwise :)

    • That's an interesting approach, I've tried to apply it but GTaskThreadFunc is limiting here, there is no way to pass another pointer because the task_data, there is also the delay question, I tried a few things but they would only complicate things.

      Anyway thanks for the review :)

    • Please register or sign in to reply
  • Andre Miranda added 1 commit

    added 1 commit

    Compare with previous version

  • merged

Please register or sign in to reply
Loading