Commit Graph

203 Commits

Author SHA1 Message Date
Mario Sanchez Prada
07d6c53346 application: Complete startup notification sequence for remote invocations
When a remote instance of a GTK application implementing the Startup
Notification protocol gets spawned it will pass the startup sequence
ID as "platform data" to the main instance. Thus, we need to make sure
that the startup sequence gets completed in that case, since the remote
instance won't do it by itself, since it won't map any top level window.

Checking for this "platform data" in the implementation of the after_emit()
virtual method in the primary instance should be a good place to do so, since
the existence of such data proves that a remote instance has been spawned.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Mario Sanchez Prada
479c341545 application: Use the new API to get the startup notification ID
The DESKTOP_STARTUP_ID gets cleared early after the process is spawned,
meaning that it's too late at add_platform_data() to pick it up and send
it over to the primary instance, as it will be always unset at that point.

To solve this, we use the new gdk_display_get_startup_notification_id()
method to pull the startup notification ID for the application, if present,
out of the display and pass it over to that primary instance.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Emmanuele Bassi
888dfe499d Drop the Big GDK Lock
GDK has a lock to mark critical sections inside the backends.
Additionally, code that would re-enter into the GTK main loop was
supposed to hold the lock.

Back in the Good Old Days™ this was guaranteed to kind of work only on
the X11 backend, and would cause a neat explosion on any other GDK
backend.

During GTK+ 3.x we deprecated the API to enter and leave the critical
sections, and now we can remove all the internal uses of the lock, since
external API that uses GTK+ 4.x won't be able to hold the GDK lock.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:07:10 +01:00
Matthias Clasen
b12371e1b0 application: Stop using ::focus-in-event
We are really interested in the active window, so use
that property directly.
2018-01-16 14:14:10 -05:00
Benjamin Otte
2d5c82b4ec gtk: Remove GtkClipboard 2017-12-03 05:46:49 +01:00
Benjamin Otte
4cce109e16 application: Put shared code into a common function 2017-12-03 05:46:48 +01:00
Matthias Clasen
65808418e1 Drop gtk_application_is_inhibited
This function returns global session state that may
not be available to applications (e.g. in sandboxed
environments), and is not needed by applications,
so just drop it, instead of keeping a function around
that can't be guaranteed to work.
2017-11-28 23:02:58 -05:00
Matthias Clasen
4371f370bc Improve the docs
Document that gtk_application_is_inhibited can't
be guaranteed to work.
2017-11-28 22:52:44 -05:00
Matthias Clasen
2ff175938d application: Append a / to the icon resource path
g_resources_enumerate_children expects the path to end
in a '/' (even though thats not stated in the docs), and
will copy it if that isn't the case. Avoid the copy
by putting  a '/' there to begin with.
2017-11-13 07:35:18 -05:00
Arun Raghavan
4b1853b32f gtkapplication: Mark gtk_application_get_active_window() as nullable
https://bugzilla.gnome.org/show_bug.cgi?id=784888
2017-07-18 14:03:59 -04:00
Matthias Clasen
2c7e567f05 Update callers
Adapt all our tests and examples to the new initialization api.
2017-01-19 13:50:17 -05:00
Matthias Clasen
63d6e2d8e2 Don't export gtk_get_option_group
We want to get rid of commandline option handling in GTK+.
This is a step in that direction.
2017-01-19 13:21:12 -05:00
Timm Bäder
e0d50233f6 gtkapplication: Remove deprecated API 2016-10-18 00:29:19 +02:00
Sébastien Wilmet
554de0be2a app: replace private accels functions by get_application_accels()
It's like gtk_application_get_action_muxer().

https://bugzilla.gnome.org/show_bug.cgi?id=764879
2016-04-22 12:43:27 +02:00
Sébastien Wilmet
3b988ce523 app: share function to normalise detailed action name
Put the function in gtkactionmuxer.c, where
gtk_print_action_and_target() is implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=764879
2016-04-22 12:40:08 +02:00
Sébastien Wilmet
bce4a0abde app: extract GtkApplicationAccels private class
This has several benefits:
- Less code in GtkApplication. The accels handling is something
  self-contained, and GtkApplication now delegates the work.
- For the accels functions, there is now a distinction between static
  functions and functions in the gtkapplicationaccelsprivate.h header,
  which makes the code easier to understand, because we have a good
  overview just by reading the header.
- The struct _GtkApplicationPrivate is now easier to find instead of
  being in the middle of the file.

https://bugzilla.gnome.org/show_bug.cgi?id=764879
2016-04-22 12:39:18 +02:00
Sébastien Wilmet
e0c34fd028 app: write higher-level gtk_application_accels static functions
These will become the functions present in the
gtkapplicationaccelsprivate.h header.

The gtk_application_accels functions deal with detailed_action_name's
instead of action_and_target's. action_and_target is an implementation
detail of Accels.

The added function prototype is temporary, it'll be removed in a later
commit.

https://bugzilla.gnome.org/show_bug.cgi?id=764879
2016-04-22 12:38:56 +02:00
Sébastien Wilmet
f9ba55eaad app: add missing g_returns
And have the g_returns in the same order as the function parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-12 20:32:49 +02:00
Sébastien Wilmet
ee58a52a61 app: minor code improvements
- use GDK_EVENT_PROPAGATE
- pass better zero-values to gtk_init(), since the parameters are
  pointers.

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
1f87c1cc0b app: improve code of extract_accels_from_menu()
sub_model is clearer than "m". And we don't use the key, so we can pass
NULL instead.

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
687d3eb48f app: use g_set_object()
https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
29971b0cc9 app: don't use deprecated function
gtk_application_add_accelerator() is deprecated, but was still used
inside IGNORE_DEPRECATIONS's.

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
399e8db336 app: improve doc of gtk_application_get_window_by_id()
https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
40e40b7ffc app: improve doc of gtk_application_set_accels_for_action()
When reading the API for the first time I didn't know what was the
"detailed" action name.

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:07 +02:00
Sébastien Wilmet
48afd8a5f0 app: avoid code duplication for setting accels
The implementation of the deprecated functions is now based on the
non-deprecated gtk_application_set_accels_for_action().

https://bugzilla.gnome.org/show_bug.cgi?id=764846
2016-04-10 16:54:06 +02:00
Sébastien Wilmet
6db7de3f7b app: fix indentation
And add missing curly braces.
2016-04-09 18:54:42 +02:00
Sébastien Wilmet
b3dc473057 docs: trivial fixes in GtkApplication-related documentation 2016-04-09 09:45:33 +02:00
Timm Bäder
aeed695e26 gtkapplication: _get_app_menu can return NULL 2016-03-28 18:18:20 +02:00
Matthias Clasen
cb738bc201 Remove private clipboard api from public headers 2016-03-26 23:17:53 -04:00
Phillip Wood
934b3f6865 Document that GtkApplication loads gtk/menus-common.ui
Add a comment about the resource gtk/menus-common.ui to the
documentation of the other resources loaded by GtkApplication.

https://bugzilla.gnome.org/show_bug.cgi?id=761432
2016-02-18 14:11:14 +00:00
Phillip Wood
c38c3361ca Document help overlay action name in GtkApplication
This means all the information needed to automatically load a
shortcuts window and create a menu item to show it is in one place.

https://bugzilla.gnome.org/show_bug.cgi?id=761431
2016-02-18 14:11:14 +00:00
Allison Ryan Lortie
0d109867d2 Tweak startup-notification after the first window
Presently, Gtk will only send a startup notification completion message
for the first window that is shown.  This is not good for the case of
GtkApplication, where we are expected to participate in
startup-notification for all windows.

We have avoided this problem by manually emitting the startup complete
message from after_emit in GtkApplication.

Unfortunately, this causes problems for windows that are shown with a
delay.  It is also a dirty hack.

The reason for the original behaviour is simple: there is a static
boolean in gtkwindow.c which controls it.  We remove this.

Instead, clear the startup notification ID stored in GDK when sending
the completion message.  GtkApplication will re-set this the next time
an event comes in which needs startup-notification handling.  In the
non-GtkApplication case, newly shown windows will still not send the
message, since the cookie will have been cleared.

Finally, we remove the hack from GtkApplication's after_emit.

This will probably cause some regressions in terms of lingering startup
notification messages.  The correct solution here is to always use
gtk_window_present(), including when merely opening a new document (with
a new tab, for example).

https://bugzilla.gnome.org/show_bug.cgi?id=690791
2016-01-27 18:14:40 +01:00
Matthias Clasen
0049be4e58 application: Protect against double shutdown
It is not something that can happen normally.
But if it does, we shouldn't crash.

https://bugzilla.gnome.org/show_bug.cgi?id=760680
2016-01-15 17:37:55 -05:00
Alberto Ruiz
496f0892fc introspection: This patch fixes nullable return values fixes for the following symbols in gtk
gtk_accel_group_query
  gtk_accel_group_from_accel_closure
  gtk_accel_label_get_accel_widget
  gtk_accessible_get_widget
  gtk_actionable_get_action_name
  gtk_app_chooser_get_app_info
  gtk_app_chooser_button_get_heading
  gtk_app_chooser_dialog_get_heading
  gtk_application_get_window_by_id
  gtk_assistant_get_nth_page
  gtk_binding_set_find
  gtk_builder_get_object
  gtk_builder_lookup_callback_symbol
  gtk_builder_get_application
  gtk_button_get_image
  gtk_cell_area_get_focus_from_sibling
  gtk_cell_renderer_start_editing
  gtk_cell_view_get_model
  gtk_cell_view_get_displayed_row
  gtk_clipboard_get_owner
  gtk_container_get_focus_child
  gtk_container_get_focus_vadjustment
  gtk_container_get_focus_hadjustment
  gtk_dialog_get_widget_for_response
  gtk_drag_get_source_widget
  gtk_drag_dest_get_target_list
  gtk_drag_source_get_target_list
  gtk_entry_completion_get_model
  gtk_entry_completion_compute_prefix
  gtk_expander_get_label_widget
  gtk_file_chooser_get_filename
  gtk_file_chooser_get_current_folder
  gtk_file_chooser_get_uri
  gtk_file_chooser_get_current_folder_uri
  gtk_file_chooser_get_preview_widget
  gtk_file_chooser_get_preview_file
  gtk_file_chooser_get_preview_filename
  gtk_file_chooser_get_preview_uri
  gtk_file_chooser_get_extra_widget
  gtk_file_chooser_get_filter
  gtk_file_chooser_native_get_accept_label
  gtk_file_chooser_native_get_cancel_label
  gtk_file_filter_get_name
  gtk_font_chooser_get_font_family
  gtk_font_chooser_get_font_face
  gtk_font_chooser_get_font
  gtk_font_chooser_get_font_desc
  gtk_font_chooser_get_font_map
  gtk_frame_get_label
  gtk_gesture_get_device
  gtk_gesture_get_window
  gtk_gl_area_get_error
  gtk_header_bar_get_title
  gtk_header_bar_get_subtitle
  gtk_header_bar_get_custom_title
  gtk_icon_info_get_filename
  gtk_icon_view_get_path_at_pos
  gtk_icon_view_get_model
  gtk_image_get_pixbuf
  gtk_image_get_animation
  gtk_label_get_mnemonic_widget
  gtk_label_get_attributes
  gtk_check_version
  gtk_menu_button_get_popup
  gtk_menu_button_get_menu_model
  gtk_menu_button_get_align_widget
  gtk_menu_button_get_popover
  gtk_menu_item_get_submenu
  gtk_menu_item_get_accel_path
  gtk_native_dialog_get_title
  gtk_native_dialog_get_transient_for
  gtk_notebook_get_nth_page
  gtk_notebook_get_tab_label_text
  gtk_notebook_get_menu_label
  gtk_notebook_get_menu_label_text
  gtk_notebook_get_group_name
  gtk_notebook_get_action_widget
  gtk_offscreen_window_get_surface
  gtk_offscreen_window_get_pixbuf
  gtk_paned_get_child1
  gtk_paned_get_child2
  gtk_places_sidebar_get_location
  gtk_places_sidebar_get_nth_bookmark
  gtk_plug_get_socket_window
  gtk_popover_get_default_widget
  gtk_progress_bar_get_text
  gtk_recent_filter_get_name
  gtk_recent_manager_lookup_item
  gtk_settings_get_default
  gtk_socket_get_plug_window
  gtk_stack_sidebar_get_stack
  gtk_stack_switcher_get_stack
  gtk_style_context_get_section
  gtk_style_context_get_parent
  gtk_style_context_get_frame_clock
  gtk_test_find_widget
  gtk_text_buffer_get_mark
  gtk_text_tag_table_lookup
  gtk_text_view_get_tabs
  gtk_text_view_toggle_cursor_visible
  gtk_text_view_get_window
  gtk_toolbar_get_nth_item
  gtk_tool_button_get_label
  gtk_tool_button_get_icon_name
  gtk_tool_button_get_label_widget
  gtk_tool_button_get_icon_widget
  gtk_tool_palette_get_drop_item
  gtk_tool_palette_get_drop_group
  gtk_tree_model_filter_convert_child_path_to_path
  gtk_tree_model_filter_convert_path_to_child_path
  gtk_tree_model_sort_convert_child_path_to_path
  gtk_tree_model_sort_convert_path_to_child_path
  gtk_tree_view_get_column
  gtk_tree_view_get_bin_window
  gtk_tree_view_column_get_widget
  gtk_tree_view_column_get_tree_view
  gtk_widget_get_frame_clock
  gtk_window_group_get_current_device_grab
  GtkTextBufferSerializeFunc
2016-01-08 12:18:23 +00:00
Matthias Clasen
f6d9f9f93d Add automatic help overlay support to GtkApplication
When the $(resource_prefix)/gtk/help-overlay.ui resource exists,
load a GtkShortcutsWindow from it for each GtkApplicationWindow,
and set up a win.show-help-overlay action with accels <Primary>F1
and <Primary>? to show it.
2015-10-21 15:33:09 -04:00
Emmanuele Bassi
707a071c66 app: Warn when trying to add windows on an inert instance
Application windows can only be added after the application has been
started.

https://bugzilla.gnome.org/show_bug.cgi?id=755954
2015-10-01 19:24:12 +01:00
Matthias Clasen
aff6835f1b application: Be save against impl being NULL
We clear the impl in shutdown, so all callbacks that may
happen at a later time need to be prepared for this.

https://bugzilla.gnome.org/show_bug.cgi?id=755432
2015-09-23 14:38:08 -04:00
Matthias Clasen
66f0bdee0a Intern all signal names beforehand
This avoids pointless allocations
2015-09-12 12:50:39 -04:00
Matthias Clasen
0585780de1 application: Convert to g_object_notify_by_pspec
This avoid pspec lookup overhead in g_object_notify.
2015-09-06 17:11:35 -04:00
Matthias Clasen
75f0146c69 application: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:15 -04:00
Matthias Clasen
7db74e3aa9 GtkApplication: Fix some small doc formatting issues 2015-04-26 10:19:26 -04:00
Matthias Clasen
7603b52790 GtkApplication: Prevent more crashes around shutdown
gtk_application_shutdown clears the impl member, so all
callbacks, signal handlers, etc that might still be triggered
between a shutdown call and the return from the mainloop
better be prepared to deal with impl being NULL.
2015-04-10 08:04:53 -04:00
Matthias Clasen
c0ac3c3386 GtkApplication: avoid a crash
It can apparently happen that we get focus in events
on windows after gtk_application_shutdown() has been
called. Avoid an unnecessary crash in this case.

See
https://bugzilla.redhat.com/show_bug.cgi?id=1176339
2015-04-08 15:44:21 -04:00
Bastian Ilsø
9c49144cbe Add reference to HowDoI and getting-started 2015-02-02 20:52:35 +01:00
Matthias Clasen
d55e3b25a7 Fix various compiler warnings
Mostly missing declarations and missing statics.
2014-09-05 21:21:49 -04:00
Paolo Borelli
db3a01b589 GtkApplication: fix annotation of get_menu_by_id
https://bugzilla.gnome.org/show_bug.cgi?id=735034
2014-08-19 18:28:19 +02:00
Ryan Lortie
7d81d0a3bb Add gtk_application_get_actions_for_accel()
This counterpart to gtk_application_get_accels_for_action() lets you
find out if a particular accelerator has one or more actions associated
with it. This might be useful from an accelerator editor or plugin
system to prevent the the installation of conflicting accelerators.

https://bugzilla.gnome.org/show_bug.cgi?id=721367
2014-08-03 20:27:51 +02:00
Ryan Lortie
ffbfee0738 GtkApplication: load gtk/menus-common.ui resource
Allow the app to install a resource called gtk/menus-common.ui which
will always be loaded, regardless of which type of menus we are using.

https://bugzilla.gnome.org/show_bug.cgi?id=733925
2014-07-30 09:57:33 +02:00
Matthias Clasen
d1099b1759 Document gtk_application_get_menu_by_id 2014-07-07 19:44:39 -04:00