diff --git a/README.md b/README.md index ede56d5..3993e45 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ This project is still relatively new though and we can't yet commit to a stable ABI. You are welcome to use libxapp or xapps-common in your application, but if you do, please make sure to tell us, so that we can communicate with you going forward about any potential changes. + +# API Reference + +http://developer.linuxmint.com/xapps/reference/index.html ## XAppMonitorBlanker diff --git a/debian/changelog b/debian/changelog index 9e47542..29b701b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,92 @@ +xapp (1.6.2) tricia; urgency=medium + + [ Eli Schwartz ] + * mate applet: fix configuring + * mate applet: fix regression in install location + * debian: fixup changed file locations + + [ Michael Webster ] + * mate-xapp-status-applet.py: handle a null icon name correctly. + * test-scripts: have xapp-status-applet sort icons in the same manner the real applets do (symbolic to the right, then by alpha process name). + * xapp-status-icon.c: Keep an account of button presses so an orphan release doesn't activate or pop up a menu. + * xapp-status-icon: Track and notify changes in types of support for the icon - notify when a status icon is picked up by a native applet, a traditional system tray, or is not being picked up by anything. + * xapp-status-icon.c: Replace g_enum_to_string with a custom function, this isn't available with lmde's glib. + + -- Clement Lefebvre Fri, 22 Nov 2019 10:36:41 +0000 + +xapp (1.6.1) tricia; urgency=medium + + [ Michael Webster ] + * xapp-status-icon: Add a function to check for the existence of any active status applets. + + -- Clement Lefebvre Wed, 13 Nov 2019 17:33:22 +0100 + +xapp (1.6.0) tricia; urgency=medium + + [ Clement Lefebvre ] + * Implement XAppStatusIcon (#67) + + [ James Ross ] + * libxapp: cleanup compile warnings (#69) + + [ Michael Webster ] + * status icons: Add a monitor class for applets - XAppStatusIconMonitor, (#70) + * test-scripts: add a status-icon-via-libappindicator script. + * xapp-status-icon.c: Remove leftover debug line + * xapp-status-icon: When a menu is provided to XAppStatusIcon, handle positioning and showing it internally instead of requiring the application to do it. + * xapp-status-icon.c: Use G_ class macros to cleanup header file, fix xapp_status_icon_get_menu() (copy/paste error). + * Add some useful build C-flags, fix test script exec bit. + + [ Clement Lefebvre ] + * Add API reference in docs/reference/ + * Set theme jekyll-theme-architect + * README: Add link to API reference + + [ Michael Webster ] + * xapp-status-icon.c: Emit 'activate' during fallback status icon activation. + * docs: Generate html automatically + + [ Stephen Collins ] + * xapp-icon-chooser-dialog.c: Remove unused variable + * icon chooser dialog: add default_icon property + * icon chooser dialog: add *_add_custom_category () function + + [ Michael Webster ] + * Add a Mate status applet (#72) + * xapp-status-icon.c: Refactor event handling. + + [ Stephen Collins ] + * xapp-icon-chooser-dialog.c: prevent segfault on non-existent icon name (#76) + + [ Clement Lefebvre ] + * IconChooserButton: Add the ability to set the default category (#77) + + [ Stephen Collins ] + * xapp-icon-chooser-button.c: add missing dispose method (#78) + + [ Michael Webster ] + * mate-xapp-status-applet.py: Make improvements to event handling and widget appearance during clicks. + * Add a custom install script for installing the generated header file. + * Add i18n for the mate applet. + * mate applet: Add an about window, use more appropriate install locations, move build replacement strings to a separate imported file. + * xapp-status-icon.c: During async ops, when checking for cancellation, use the error code, as the cancellable may have reset in the interim, but the code will be correct. + + [ Michael Webster ] + * status icons: Support multiple icons from the same process. + + [ Clement Lefebvre ] + * Revert "docs: Generate html automatically" + * Add a makedoc script to update docs/reference + * Update reference docs + + [ Stephen Collins ] + * xapp-icon-chooser-dialog.c: color the symbolic icons properly and fix hidpi (#79) + + [ Clement Lefebvre ] + * l10n: Update POT + + -- Clement Lefebvre Tue, 12 Nov 2019 11:12:12 +0100 + xapp (1.4.9) tina; urgency=medium [ Michael Webster ] diff --git a/debian/xapps-common.install b/debian/xapps-common.install index c5e7b1b..efba269 100644 --- a/debian/xapps-common.install +++ b/debian/xapps-common.install @@ -2,3 +2,6 @@ usr/bin/ usr/share/icons usr/share/locale +usr/libexec/xapps +usr/share/mate-panel/applets +usr/share/dbus-1/services diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..3397c9a --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file diff --git a/docs/reference/XAppGtkWindow.html b/docs/reference/XAppGtkWindow.html new file mode 100644 index 0000000..c4a8f14 --- /dev/null +++ b/docs/reference/XAppGtkWindow.html @@ -0,0 +1,721 @@ + + + + +XAppGtkWindow: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppGtkWindow

+

XAppGtkWindow — A subclass of GtkWindow that allows additional + communication with the window manager.

+
+
+

Functions

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+GtkWidget * + +xapp_gtk_window_new () +
+void + +xapp_gtk_window_set_icon_name () +
+void + +xapp_gtk_window_set_icon_from_file () +
+void + +xapp_gtk_window_set_progress () +
+void + +xapp_gtk_window_set_progress_pulse () +
+void + +xapp_set_window_icon_name () +
+void + +xapp_set_window_icon_from_file () +
+void + +xapp_set_window_progress () +
+void + +xapp_set_window_progress_pulse () +
+void + +xapp_set_xid_icon_name () +
+void + +xapp_set_xid_icon_from_file () +
+void + +xapp_set_xid_progress () +
+void + +xapp_set_xid_progress_pulse () +
+
+
+

Types and Values

+
++++ + + + + + + + + + + + + + + +
#defineXAPP_TYPE_GTK_WINDOW
structXAppGtkWindowClass
 XAppGtkWindow
+
+
+

Object Hierarchy

+
    GObject
+    ╰── GInitiallyUnowned
+        ╰── GtkWidget
+            ╰── GtkContainer
+                ╰── GtkBin
+                    ╰── GtkWindow
+                        ╰── XAppGtkWindow
+                            ╰── XAppIconChooserDialog
+
+
+
+

Implemented Interfaces

+

+XAppGtkWindow implements + AtkImplementorIface and GtkBuildable.

+
+
+

Description

+

This widget is a simple subclass of GtkWindow that provides the following +additional capabilities:

+
    +
  • Ability to set an icon name or icon file path for the window manager to +make use of, rather than relying on a desktop file or fixed-size window- +backed icon that Gtk normally generates. The window manager must support +the NET_WM_XAPP_ICON_NAME hint.

  • +
  • Ability to send progress info to the window manager, in the form of an integer, +0-100, which can then be used to display this progress in some manner in a task +manager or window list. The window manager must support the NET_WM_XAPP_PROGRESS +hint.

  • +
  • Ability to signal a 'pulsing' progress state, of potentially indeterminate value, +in the form of a boolean, which can be passed on to a window list. The window +manager must support the NET_WM_XAPP_PROGRESS_PULSE hint

  • +
+

Wrappers:

+

Also provided are corresponding wrapper functions for normal GtkWindows. +They are not class methods - they are called with the target widget as their first +argument.

+

For example:

+

win = Gtk.Window() +XApp.set_window_icon_name(win, "foobar")

+

These functions mirror those of the XAppGtkWindow class, but allow the properties +to work with normal GtkWindows and descendants of GtkWindow.

+
+
+

Functions

+
+

xapp_gtk_window_new ()

+
GtkWidget *
+xapp_gtk_window_new (GtkWindowType type);
+

Creates a new XAppGtkWindow of type type +. See gtk_window_new() +for more details.

+
+

Parameters

+
+++++ + + + + + +

type

The GtkWindowType to use

 
+
+
+

Returns

+

A new XAppGtkWindow (transfer: full)

+
+
+
+
+

xapp_gtk_window_set_icon_name ()

+
void
+xapp_gtk_window_set_icon_name (XAppGtkWindow *window,
+                               const gchar *icon_name);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This also chains up and calls GtkWindow.set_icon_name +for convenience and compatibility. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The XAppGtkWindow to set the icon name for

 

icon_name

The icon name or path to set, or NULL to unset.

[nullable]
+
+
+
+
+

xapp_gtk_window_set_icon_from_file ()

+
void
+xapp_gtk_window_set_icon_from_file (XAppGtkWindow *window,
+                                    const gchar *file_name,
+                                    GError **error);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This also chains up and calls GtkWindow.set_icon_from_file +for convenience and compatibility. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

window

The XAppGtkWindow to set the icon name for

 

file_name

The icon path to set, or NULL to unset.

[nullable]

error

An error to set if something goes wrong.

[nullable]
+
+
+
+
+

xapp_gtk_window_set_progress ()

+
void
+xapp_gtk_window_set_progress (XAppGtkWindow *window,
+                              gint progress);
+

Sets the progress hint for a window manager (like muffin) to make +available when applications want to display the application's progress +in some operation. The value sent to the WM will be clamped to +between 0 and 100.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists.

+

Setting progress will also cancel the 'pulsing' flag on the window as +well, if it has been set.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The XAppGtkWindow to set the progress for

 

progress

The value to set for progress.

 
+
+
+
+
+

xapp_gtk_window_set_progress_pulse ()

+
void
+xapp_gtk_window_set_progress_pulse (XAppGtkWindow *window,
+                                    gboolean pulse);
+

Sets the progress pulse hint hint for a window manager (like muffin) +to make available when applications want to display indeterminate or +ongoing progress in a task manager.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists. This will also remove the pulse state, if it is set.

+

Setting an explicit progress value will unset this flag.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The XAppGtkWindow to set the progress for

 

pulse

Whether to have pulsing set or not.

 
+
+
+
+
+

xapp_set_window_icon_name ()

+
void
+xapp_set_window_icon_name (GtkWindow *window,
+                           const gchar *icon_name);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This is a function, not a method, for taking +advantage of this feature with descendants of GtkWindows, such as +GtkDialogs. Sets gtk_window_set_icon_name as well, to avoid needing +to have two calls each time. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The GtkWindow to set the icon name for

 

icon_name

The icon name to set, or NULL to unset.

[nullable]
+
+
+
+
+

xapp_set_window_icon_from_file ()

+
void
+xapp_set_window_icon_from_file (GtkWindow *window,
+                                const gchar *file_name,
+                                GError **error);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This also chains up and calls GtkWindow.set_icon_from_file +for convenience and compatibility. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

window

The GtkWindow to set the icon name for

 

file_name

The icon path to set, or NULL to unset.

[nullable]

error

An error to set if something goes wrong.

[nullable]
+
+
+
+
+

xapp_set_window_progress ()

+
void
+xapp_set_window_progress (GtkWindow *window,
+                          gint progress);
+

Sets the progress hint for a window manager (like muffin) to make +available when applications want to display the application's progress +in some operation. The value sent to the WM will be clamped to +between 0 and 100.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists.

+

Setting progress will also cancel the 'pulsing' flag on the window as +well, if it has been set.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The GtkWindow to set the progress for

 

progress

The value to set for progress.

 
+
+
+
+
+

xapp_set_window_progress_pulse ()

+
void
+xapp_set_window_progress_pulse (GtkWindow *window,
+                                gboolean pulse);
+

Sets the progress pulse hint hint for a window manager (like muffin) +to make available when applications want to display indeterminate or +ongoing progress in a task manager.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists. This will also remove the pulse state, if it is set.

+

Setting an explicit progress value will unset this flag.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

window

The GtkWindow to set the progress for

 

pulse

Whether to have pulsing set or not.

 
+
+
+
+
+

xapp_set_xid_icon_name ()

+
void
+xapp_set_xid_icon_name (gulong xid,
+                        const gchar *icon_name);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This is a function, not a method, for applying +the icon name property for a given (possibly foreign) window, by passing +the window's XID. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

xid

The Window to set the icon name for

 

icon_name

The icon name to set, or NULL to unset.

[nullable]
+
+
+
+
+

xapp_set_xid_icon_from_file ()

+
void
+xapp_set_xid_icon_from_file (gulong xid,
+                             const gchar *file_name);
+

Sets the icon name hint for a window manager (like muffin) to make +available when applications want to change their icons during runtime +without having to resort to the internal low-res pixbufs that GdkWindow +sets on the client side. This is a function, not a method, for applying +the icon name property for a given (possibly foreign) window, by passing +the window's XID. Set to NULL to unset.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

xid

The Window to set the icon name for

 

file_name

The icon path to set, or NULL to unset.

[nullable]
+
+
+
+
+

xapp_set_xid_progress ()

+
void
+xapp_set_xid_progress (gulong xid,
+                       gint progress);
+

Sets the progress hint for a window manager (like muffin) to make +available when applications want to display the application's progress +in some operation. The value sent to the WM will be clamped to +between 0 and 100.

+

Setting progress will also cancel the 'pulsing' flag on the window as +well, if it has been set.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists.

+

This is a function, not a method, for applying the progress property for +a given (possibly foreign) window, by passing the window's XID.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

xid

The Window to set the progress for

 

progress

The value to set for progress.

 
+
+
+
+
+

xapp_set_xid_progress_pulse ()

+
void
+xapp_set_xid_progress_pulse (gulong xid,
+                             gboolean pulse);
+

Sets the progress pulse hint hint for a window manager (like muffin) +to make available when applications want to display indeterminate or +ongoing progress in a task manager.

+

Note: If a window will stick around after progress is complete, you will +probaby need to set progress to 0 to remove any progress effects on taskbars +and window lists.

+

Setting an explicit progress value will unset this flag.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

xid

The Window to set the progress for

 

pulse

Whether to have pulsing set or not.

 
+
+
+
+
+

Types and Values

+
+

XAPP_TYPE_GTK_WINDOW

+
#define XAPP_TYPE_GTK_WINDOW (xapp_gtk_window_get_type ())
+
+
+
+
+

struct XAppGtkWindowClass

+
struct XAppGtkWindowClass {
+  GtkWindowClass parent_class;
+
+  gpointer padding[12];
+};
+
+
+
+
+

XAppGtkWindow

+
typedef struct _XAppGtkWindow XAppGtkWindow;
+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppIconChooserButton.html b/docs/reference/XAppIconChooserButton.html new file mode 100644 index 0000000..7d8c803 --- /dev/null +++ b/docs/reference/XAppIconChooserButton.html @@ -0,0 +1,409 @@ + + + + +XAppIconChooserButton: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppIconChooserButton

+

XAppIconChooserButton — A button for selecting an icon

+
+ +
+

Properties

+
+++++ + + + + + + + + + + + + + + + + + +
+gchar *categoryRead / Write
+gchar *iconRead / Write
GtkIconSizeicon-sizeRead / Write
+
+
+

Types and Values

+
++++ + + + + + + + + + + +
#defineXAPP_TYPE_ICON_CHOOSER_BUTTON
 XAppIconChooserButton
+
+
+

Object Hierarchy

+
    GObject
+    ╰── GInitiallyUnowned
+        ╰── GtkWidget
+            ╰── GtkContainer
+                ╰── GtkBin
+                    ╰── GtkButton
+                        ╰── XAppIconChooserButton
+
+
+
+

Implemented Interfaces

+

+XAppIconChooserButton implements + AtkImplementorIface, GtkBuildable, GtkActionable and GtkActivatable.

+
+
+

Description

+

The XAppIconChooserButton creates a button so that +the user can select an icon. When the button is clicked +it will open an XAppIconChooserDialog. The currently +selected icon will be displayed as the button image.

+
+
+

Functions

+
+

xapp_icon_chooser_button_new ()

+
XAppIconChooserButton *
+xapp_icon_chooser_button_new (void);
+

Creates a new XAppIconChooserButton and sets its icon to icon +.

+
+

Returns

+

a newly created XAppIconChooserButton

+
+
+
+
+

xapp_icon_chooser_button_new_with_size ()

+
XAppIconChooserButton *
+xapp_icon_chooser_button_new_with_size
+                               (GtkIconSize icon_size);
+

Creates a new XAppIconChooserButton, and sets the sizes of the button image and the icons in +the dialog. Note that xapp_icon_chooser_button_new_with_size (NULL, NULL) is the same as calling +xapp_icon_chooser_button_new().

+
+

Parameters

+
+++++ + + + + + +

icon_size

the size of icon to use in the button, or NULL to use the default value.

 
+
+
+

Returns

+

a newly created XAppIconChooserButton

+
+
+
+
+

xapp_icon_chooser_button_set_icon_size ()

+
void
+xapp_icon_chooser_button_set_icon_size
+                               (XAppIconChooserButton *button,
+                                GtkIconSize icon_size);
+

Sets the icon size used in the button.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

button

a XAppIconChooserButton

 

icon_size

the size of icon to use in the button, or -1 to use the default value.

 
+
+
+
+
+

xapp_icon_chooser_button_set_icon ()

+
void
+xapp_icon_chooser_button_set_icon (XAppIconChooserButton *button,
+                                   const gchar *icon);
+

Sets the icon on the XAppIconChooserButton.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

button

a XAppIconChooserButton

 

icon

a string representing the icon to be set. This may be an icon name or a file path.

[nullable]
+
+
+
+
+

xapp_icon_chooser_button_set_default_category ()

+
void
+xapp_icon_chooser_button_set_default_category
+                               (XAppIconChooserButton *button,
+                                const gchar *category);
+

Sets the icon on the XAppIconChooserButton.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

button

a XAppIconChooserButton

 

category

a string representing the category selected by default.

[nullable]
+
+
+
+
+

xapp_icon_chooser_button_get_icon ()

+
const gchar *
+xapp_icon_chooser_button_get_icon (XAppIconChooserButton *button);
+

Gets the icon from the XAppIconChooserButton.

+
+

Parameters

+
+++++ + + + + + +

button

a XAppIconChooserButton

 
+
+
+

Returns

+

a string representing the icon. This may be an icon name or a file path.

+
+
+
+
+

xapp_icon_chooser_button_get_dialog ()

+
XAppIconChooserDialog *
+xapp_icon_chooser_button_get_dialog (XAppIconChooserButton *button);
+

Gets a reference to the icon chooser dialog for the XAppIconChooserButton. +This is useful for setting properties on the dialog.

+
+

Parameters

+
+++++ + + + + + +

button

a XAppIconChooserButton

 
+
+
+

Returns

+

the XAppIconChooserDialog.

+

[transfer none]

+
+
+
+
+

Types and Values

+
+

XAPP_TYPE_ICON_CHOOSER_BUTTON

+
#define XAPP_TYPE_ICON_CHOOSER_BUTTON   (xapp_icon_chooser_button_get_type ())
+
+
+
+
+

XAppIconChooserButton

+
typedef struct _XAppIconChooserButton XAppIconChooserButton;
+
+
+
+

Property Details

+
+

The “category” property

+
  “category”                 gchar *
+

The category selected by default.

+

Flags: Read / Write

+

Default value: ""

+
+
+
+

The “icon” property

+
  “icon”                     gchar *
+

The preferred size to use when looking up icons. This only works with icon names. +Additionally, there is no guarantee that a selected icon name will exist in a +particular size.

+

Flags: Read / Write

+

Default value: ""

+
+
+
+

The “icon-size” property

+
  “icon-size”                GtkIconSize
+

The size to use when displaying the icon.

+

Flags: Read / Write

+

Default value: GTK_ICON_SIZE_DND

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppIconChooserDialog.html b/docs/reference/XAppIconChooserDialog.html new file mode 100644 index 0000000..a43cb14 --- /dev/null +++ b/docs/reference/XAppIconChooserDialog.html @@ -0,0 +1,603 @@ + + + + +XAppIconChooserDialog: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppIconChooserDialog

+

XAppIconChooserDialog — A dialog for selecting an icon

+
+ +
+

Properties

+
+++++ + + + + + + + + + + + + + + + + + +
gbooleanallow-pathsRead / Write
+gchar *default-iconRead / Write
XAppIconSizeicon-sizeRead / Write
+
+
+

Signals

+
+++++ + + + + + + + + + + + + +
voidcloseAction
voidselectAction
+
+
+

Types and Values

+
++++ + + + + + + + + + + + + + + +
#defineXAPP_TYPE_ICON_CHOOSER_DIALOG
enumXAppIconSize
 XAppIconChooserDialog
+
+
+

Object Hierarchy

+
    GEnum
+    ╰── XAppIconSize
+    GObject
+    ╰── GInitiallyUnowned
+        ╰── GtkWidget
+            ╰── GtkContainer
+                ╰── GtkBin
+                    ╰── GtkWindow
+                        ╰── XAppGtkWindow
+                            ╰── XAppIconChooserDialog
+
+
+
+

Implemented Interfaces

+

+XAppIconChooserDialog implements + AtkImplementorIface and GtkBuildable.

+
+
+

Description

+

The XAppIconChooserDialog creates a dialog so that +the user can select an icon. It provides the ability +to browse by category, search by icon name, or select +from a specific file.

+
+
+

Functions

+
+

xapp_icon_chooser_dialog_new ()

+
XAppIconChooserDialog *
+xapp_icon_chooser_dialog_new (void);
+

Creates a new XAppIconChooserDialog.

+
+

Returns

+

a newly created XAppIconChooserDialog

+
+
+
+
+

xapp_icon_chooser_dialog_run ()

+
gint
+xapp_icon_chooser_dialog_run (XAppIconChooserDialog *dialog);
+

Shows the dialog and enters a separate main loop until an icon is chosen or the action is canceled.

+

xapp_icon_chooser_dialog_run (), xapp_icon_chooser_dialog_run_with_icon(), and +xapp_icon_chooser_dialog_run_with_category() may all be called multiple times. This is useful for +applications which use this dialog multiple times, as it may improve performance for subsequent +calls.

+
+

Parameters

+
+++++ + + + + + +

dialog

a XAppIconChooserDialog

 
+
+
+

Returns

+

GTK_RESPONSE_OK if the user selected an icon, or GTK_RESPONSE_CANCEL otherwise

+
+
+
+
+

xapp_icon_chooser_dialog_run_with_icon ()

+
gint
+xapp_icon_chooser_dialog_run_with_icon
+                               (XAppIconChooserDialog *dialog,
+                                gchar *icon);
+

Like xapp_icon_chooser_dialog_run but selects the icon specified by icon +. This can be either an +icon name or a path. Passing an icon string or path that doesn't exist is accepted, but it may show +multiple results, or none at all. This behavior is useful if, for example, you wish to have the +user select an image file from a particular directory.

+

If the property allow_paths is FALSE, setting a path will yield no results when the dialog is opened.

+

xapp_icon_chooser_dialog_run (), xapp_icon_chooser_dialog_run_with_icon(), and +xapp_icon_chooser_dialog_run_with_category() may all be called multiple times. This is useful for +applications which use this dialog multiple times, as it may improve performance for subsequent +calls.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

dialog

a XAppIconChooserDialog

 

icon

a string representing the icon that should be selected

 
+
+
+

Returns

+

GTK_RESPONSE_OK if the user selected an icon, or GTK_RESPONSE_CANCEL otherwise

+
+
+
+
+

xapp_icon_chooser_dialog_run_with_category ()

+
gint
+xapp_icon_chooser_dialog_run_with_category
+                               (XAppIconChooserDialog *dialog,
+                                gchar *category);
+

Like xapp_icon_chooser_dialog_run but selects a particular category specified by category +. +This is used when there is a particular category of icon that is more appropriate than the +others. If the category does not exist, the first category in the list will be selected. To +get a list of possible categories, use gtk_icon_theme_list_contexts().

+

xapp_icon_chooser_dialog_run (), xapp_icon_chooser_dialog_run_with_icon(), and +xapp_icon_chooser_dialog_run_with_category() may all be called multiple times. This is useful for +applications which use this dialog multiple times, as it may improve performance for subsequent +calls.

+
+

Parameters

+
+++++ + + + + + +

dialog

a XAppIconChooserDialog

 
+
+
+

Returns

+

GTK_RESPONSE_OK if the user selected an icon, or GTK_RESPONSE_CANCEL otherwise

+
+
+
+
+

xapp_icon_chooser_dialog_get_icon_string ()

+
gchar *
+xapp_icon_chooser_dialog_get_icon_string
+                               (XAppIconChooserDialog *dialog);
+

Gets the currently selected icon from the dialog. If allow-paths is TRUE, this function may return +either an icon name or a path depending on what the user selects. Otherwise it will only return an +icon name.

+
+

Parameters

+
+++++ + + + + + +

dialog

a XAppIconChooserDialog

 
+
+
+

Returns

+

the string representation of the currently selected icon or NULL +if no icon is selected.

+

[transfer full]

+
+
+
+
+

xapp_icon_chooser_dialog_add_button ()

+
void
+xapp_icon_chooser_dialog_add_button (XAppIconChooserDialog *dialog,
+                                     GtkWidget *button,
+                                     GtkPackType packing,
+                                     GtkResponseType response_id);
+

Allows a button to be added to the GtkActionBar of the dialog with a custom +response id.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +

dialog

an XAppIconChooserDialog

 

button

a GtkButton to add

 

packing

the GtkPackType to specify start or end packing to the action bar

 

response_id

the dialog response id to return when this button is clicked.

 
+
+
+
+
+

xapp_icon_chooser_dialog_get_default_icon ()

+
gchar *
+xapp_icon_chooser_dialog_get_default_icon
+                               (XAppIconChooserDialog *dialog);
+

Returns the default icon (if set).

+
+

Returns

+

the default icon, or NULL if none is set.

+

[transfer full]

+
+
+
+
+

xapp_icon_chooser_dialog_set_default_icon ()

+
void
+xapp_icon_chooser_dialog_set_default_icon
+                               (XAppIconChooserDialog *dialog,
+                                const gchar *icon);
+

Sets the default icon. If icon + is not NULL, a button will be shown that +will reset the dialog to it's default value.

+
+

Parameters

+
+++++ + + + + + +

icon

the default icon, or NULL to unset

 
+
+
+
+
+

xapp_icon_chooser_dialog_add_custom_category ()

+
void
+xapp_icon_chooser_dialog_add_custom_category
+                               (XAppIconChooserDialog *dialog,
+                                const gchar *name,
+                                GList *icons);
+

Adds a custom category to the dialog.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

dialog

a XAppIconChooserDialog

 

name

the name of the category as it will be displayed in the category list

 

icons

a list of icon names to add to the new category.

[transfer full][element-type utf8]
+
+
+
+
+

Types and Values

+
+

XAPP_TYPE_ICON_CHOOSER_DIALOG

+
#define XAPP_TYPE_ICON_CHOOSER_DIALOG   (xapp_icon_chooser_dialog_get_type ())
+
+
+
+
+

enum XAppIconSize

+
+

Members

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

XAPP_ICON_SIZE_16

  

XAPP_ICON_SIZE_22

  

XAPP_ICON_SIZE_24

  

XAPP_ICON_SIZE_32

  

XAPP_ICON_SIZE_48

  

XAPP_ICON_SIZE_96

  
+
+
+
+
+

XAppIconChooserDialog

+
typedef struct _XAppIconChooserDialog XAppIconChooserDialog;
+
+
+
+

Property Details

+
+

The “allow-paths” property

+
  “allow-paths”              gboolean
+

Whether to allow paths to be searched and selected or only icon names.

+

Flags: Read / Write

+

Default value: TRUE

+
+
+
+

The “default-icon” property

+
  “default-icon”             gchar *
+

The icon to use by default.

+

Flags: Read / Write

+

Default value: NULL

+
+
+
+

The “icon-size” property

+
  “icon-size”                XAppIconSize
+

The preferred size to use when looking up icons. This only works with icon names. +Additionally, there is no guarantee that a selected icon name will exist in a +particular size.

+

Flags: Read / Write

+

Default value: XAPP_ICON_SIZE_32

+
+
+
+

Signal Details

+
+

The “close” signal

+
void
+user_function (XAppIconChooserDialog *xappiconchooserdialog,
+               gpointer               user_data)
+

Flags: Action

+
+
+
+

The “select” signal

+
void
+user_function (XAppIconChooserDialog *xappiconchooserdialog,
+               gpointer               user_data)
+

Flags: Action

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppKbdLayoutController.html b/docs/reference/XAppKbdLayoutController.html new file mode 100644 index 0000000..fd7e474 --- /dev/null +++ b/docs/reference/XAppKbdLayoutController.html @@ -0,0 +1,747 @@ + + + + +XAppKbdLayoutController: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppKbdLayoutController

+

XAppKbdLayoutController — Keyboard layout selection UI element provider.

+
+ +
+

Properties

+
+++++ + + + + + +
gbooleanenabledRead
+
+
+

Signals

+
+++++ + + + + + + + + + + + + +
voidconfig-changedRun Last
voidlayout-changedRun Last
+
+
+

Object Hierarchy

+
    GObject
+    ╰── XAppKbdLayoutController
+
+
+
+

Description

+

A GObject wrapper for Gkbd that provides additional UI element +support for keyboard layout flags and abbreviations, as well as +Wfacilities to distinguish regional and hardware-based variants +which might otherwise appear identical in a layout list.

+
+
+

Functions

+
+

xapp_kbd_layout_controller_new ()

+
XAppKbdLayoutController *
+xapp_kbd_layout_controller_new (void);
+

Creates a new XAppKbdLayoutController instance.

+
+

Returns

+

a new XAppKbdLayoutController instance.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_enabled ()

+
gboolean
+xapp_kbd_layout_controller_get_enabled
+                               (XAppKbdLayoutController *controller);
+

Returns whether or not the layout controller is enabled

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+
+
+

xapp_kbd_layout_controller_get_current_group ()

+
guint
+xapp_kbd_layout_controller_get_current_group
+                               (XAppKbdLayoutController *controller);
+

Selects the previous group in the group list.

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+
+
+

xapp_kbd_layout_controller_set_current_group ()

+
void
+xapp_kbd_layout_controller_set_current_group
+                               (XAppKbdLayoutController *controller,
+                                guint group);
+

Selects the given group number as active.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

controller

the XAppKbdLayoutController

 

group

the group number to make active

 
+
+
+
+
+

xapp_kbd_layout_controller_next_group ()

+
void
+xapp_kbd_layout_controller_next_group (XAppKbdLayoutController *controller);
+

Selects the next group in the group list.

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+
+
+

xapp_kbd_layout_controller_previous_group ()

+
void
+xapp_kbd_layout_controller_previous_group
+                               (XAppKbdLayoutController *controller);
+

Selects the previous group in the group list.

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+
+
+

xapp_kbd_layout_controller_get_current_name ()

+
gchar *
+xapp_kbd_layout_controller_get_current_name
+                               (XAppKbdLayoutController *controller);
+

Returns the full name of the current keyboard layout.

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

the newly created string or NULL +if something went wrong.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_all_names ()

+
gchar **
+xapp_kbd_layout_controller_get_all_names
+                               (XAppKbdLayoutController *controller);
+

Returns an array of all full layout names

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

array of names.

+

[transfer none][array zero-terminated=1]

+
+
+
+
+

xapp_kbd_layout_controller_get_current_icon_name ()

+
gchar *
+xapp_kbd_layout_controller_get_current_icon_name
+                               (XAppKbdLayoutController *controller);
+

Returns the icon file name (no path or extension) to use for the current layout

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

a new string with the icon name.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_icon_name_for_group ()

+
gchar *
+xapp_kbd_layout_controller_get_icon_name_for_group
+                               (XAppKbdLayoutController *controller,
+                                guint group);
+

Returns the icon file name (no path or extension) to use for the specified layout.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

controller

the XAppKbdLayoutController

 

group

a group number

 
+
+
+

Returns

+

a new string with the icon name.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_current_flag_id ()

+
gint
+xapp_kbd_layout_controller_get_current_flag_id
+                               (XAppKbdLayoutController *controller);
+

Returns the duplicate id for the current layout

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

the id

+
+
+
+
+

xapp_kbd_layout_controller_get_flag_id_for_group ()

+
gint
+xapp_kbd_layout_controller_get_flag_id_for_group
+                               (XAppKbdLayoutController *controller,
+                                guint group);
+
+
+
+

xapp_kbd_layout_controller_get_current_short_group_label ()

+
gchar *
+xapp_kbd_layout_controller_get_current_short_group_label
+                               (XAppKbdLayoutController *controller);
+

Returns the short group label (and subscript, if any) of the current layout

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

a new string or NULL.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_short_group_label_for_group ()

+
gchar *
+xapp_kbd_layout_controller_get_short_group_label_for_group
+                               (XAppKbdLayoutController *controller,
+                                guint group);
+

Returns the short group label and subscript of the specified layout.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

controller

the XAppKbdLayoutController

 

group

a group number

 
+
+
+

Returns

+

a new string or NULL.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_current_variant_label ()

+
gchar *
+xapp_kbd_layout_controller_get_current_variant_label
+                               (XAppKbdLayoutController *controller);
+

Returns the variant label (and subscript, if any) of the current layout

+
+

Parameters

+
+++++ + + + + + +

controller

the XAppKbdLayoutController

 
+
+
+

Returns

+

a new string or NULL.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_get_variant_label_for_group ()

+
gchar *
+xapp_kbd_layout_controller_get_variant_label_for_group
+                               (XAppKbdLayoutController *controller,
+                                guint group);
+

Returns the variant label and subscript of the specified layout.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

controller

the XAppKbdLayoutController

 

group

a group number

 
+
+
+

Returns

+

a new string or NULL.

+

[transfer full]

+
+
+
+
+

xapp_kbd_layout_controller_render_cairo_subscript ()

+
void
+xapp_kbd_layout_controller_render_cairo_subscript
+                               (cairo_t *cr,
+                                gdouble x,
+                                gdouble y,
+                                gdouble width,
+                                gdouble height,
+                                gint subscript);
+

Renders a subscript number in the given work area. This should +be called from within a "draw" or "paint" widget/actor function, +where a valid cairo_t is provided to draw with.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

cr

a cairo_t

 

x

the x position of the drawing area

 

y

the y position of the drawing area

 

width

the width of the drawing area

 

height

the height of the drawing area

 

subscript

the number to render

 
+
+
+
+
+

Types and Values

+
+
+

Property Details

+
+

The “enabled” property

+
  “enabled”                  gboolean
+

Whether we're enabled (more than one keyboard layout is installed).

+

Flags: Read

+

Default value: FALSE

+
+
+
+

Signal Details

+
+

The “config-changed” signal

+
void
+user_function (XAppKbdLayoutController *xappkbdlayoutcontroller,
+               gpointer                 user_data)
+

Flags: Run Last

+
+
+
+

The “layout-changed” signal

+
void
+user_function (XAppKbdLayoutController *xappkbdlayoutcontroller,
+               guint                    arg1,
+               gpointer                 user_data)
+

Flags: Run Last

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppMonitorBlanker.html b/docs/reference/XAppMonitorBlanker.html new file mode 100644 index 0000000..a1e81b3 --- /dev/null +++ b/docs/reference/XAppMonitorBlanker.html @@ -0,0 +1,193 @@ + + + + +XAppMonitorBlanker: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppMonitorBlanker

+

XAppMonitorBlanker — Blank and unblank unused monitors

+
+
+

Functions

+ +
+
+

Object Hierarchy

+
    GObject
+    ╰── XAppMonitorBlanker
+
+
+
+

Description

+

The XAppMonitorBlanker widget that creates one or more +POPUP type GtkWindows that are used to blank unused +monitors in multiple monitor setups.

+
+
+

Functions

+
+

xapp_monitor_blanker_new ()

+
XAppMonitorBlanker *
+xapp_monitor_blanker_new (void);
+

Creates a new XAppMonitorBlanker.

+
+

Returns

+

a newly created XAppMonitorBlanker

+
+
+
+
+

xapp_monitor_blanker_blank_other_monitors ()

+
void
+xapp_monitor_blanker_blank_other_monitors
+                               (XAppMonitorBlanker *self,
+                                GtkWindow *window);
+

Blanks monitors besides the one where the window + is.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

self

a XAppMonitorBlanker

 

window

a GtkWindow

 
+
+
+
+
+

xapp_monitor_blanker_unblank_monitors ()

+
void
+xapp_monitor_blanker_unblank_monitors (XAppMonitorBlanker *self);
+

Unblanks monitors that were blanked by +xapp_monitor_blanker_blank_other_monitors();

+
+

Parameters

+
+++++ + + + + + +

self

a XAppMonitorBlanker

 
+
+
+
+
+

xapp_monitor_blanker_are_monitors_blanked ()

+
gboolean
+xapp_monitor_blanker_are_monitors_blanked
+                               (XAppMonitorBlanker *self);
+

Returns whether monitors are currently blanked. +See xapp_monitor_blanker_blank_other_monitors().

+
+

Parameters

+
+++++ + + + + + +

self

a XAppMonitorBlanker

 
+
+
+

Returns

+

TRUE if monitors are blanked.

+
+
+
+
+

Types and Values

+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppPreferencesWindow.html b/docs/reference/XAppPreferencesWindow.html new file mode 100644 index 0000000..6e5787f --- /dev/null +++ b/docs/reference/XAppPreferencesWindow.html @@ -0,0 +1,268 @@ + + + + +XAppPreferencesWindow: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppPreferencesWindow

+

XAppPreferencesWindow — A base preferences window

+
+
+

Functions

+
++++ + + + + + + + + + + + + + + +
+XAppPreferencesWindow * + +xapp_preferences_window_new () +
+void + +xapp_preferences_window_add_page () +
+void + +xapp_preferences_window_add_button () +
+
+
+

Signals

+
+++++ + + + + + +
voidcloseAction
+
+
+

Types and Values

+
++++ + + + + + + + + + + + + + + +
#defineXAPP_TYPE_PREFERENCES_WINDOW
structXAppPreferencesWindowClass
 XAppPreferencesWindow
+
+
+

Object Hierarchy

+
    GObject
+    ╰── GInitiallyUnowned
+        ╰── GtkWidget
+            ╰── GtkContainer
+                ╰── GtkBin
+                    ╰── GtkWindow
+                        ╰── XAppPreferencesWindow
+
+
+
+

Implemented Interfaces

+

+XAppPreferencesWindow implements + AtkImplementorIface and GtkBuildable.

+
+
+

Description

+

The XAppPreferencesWindow sets up a simple dialog +window with a GtkStack, GtkSidebarSwitcher, and +GtkActionBar. The stack switcher and action bar only +show when needed.

+
+
+

Functions

+
+

xapp_preferences_window_new ()

+
XAppPreferencesWindow *
+xapp_preferences_window_new (void);
+

Creates a new XAppPreferencesWindow.

+
+

Returns

+

a newly created XAppPreferencesWindow

+
+
+
+
+

xapp_preferences_window_add_page ()

+
void
+xapp_preferences_window_add_page (XAppPreferencesWindow *window,
+                                  GtkWidget *widget,
+                                  const gchar *name,
+                                  const gchar *title);
+

Adds a page to the window. The page is identified by name. The +title will be used in the sidebar so should be short. The sidebar +will show automatically once at least two pages are added.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +

window

a XAppPreferencesWindow

 

widget

a GtkWidget to add

 

name

the name for the page

 

title

a human-readable title for the page

 
+
+
+
+
+

xapp_preferences_window_add_button ()

+
void
+xapp_preferences_window_add_button (XAppPreferencesWindow *window,
+                                    GtkWidget *button,
+                                    GtkPackType pack_type);
+

Adds a button to the bottom action bar of the window. Where +the button is place will be determined by the GtkPackType. The +action bar will show automatically once at least one button is +added.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

window

a XAppPreferencesWindow

 

button

a GtkWidget to add

 

pack_type

a GtkPackType to use

 
+
+
+
+
+

Types and Values

+
+

XAPP_TYPE_PREFERENCES_WINDOW

+
#define XAPP_TYPE_PREFERENCES_WINDOW (xapp_preferences_window_get_type ())
+
+
+
+
+

struct XAppPreferencesWindowClass

+
struct XAppPreferencesWindowClass {
+    GtkWindowClass parent_class;
+
+    /* Keybinding signals */
+    void (* close) (XAppPreferencesWindow *window);
+};
+
+
+
+
+

XAppPreferencesWindow

+
typedef struct _XAppPreferencesWindow XAppPreferencesWindow;
+
+
+
+

Signal Details

+
+

The “close” signal

+
void
+user_function (XAppPreferencesWindow *xapppreferenceswindow,
+               gpointer               user_data)
+

Flags: Action

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppStackSidebar.html b/docs/reference/XAppStackSidebar.html new file mode 100644 index 0000000..ecfd2ed --- /dev/null +++ b/docs/reference/XAppStackSidebar.html @@ -0,0 +1,241 @@ + + + + +XAppStackSidebar: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppStackSidebar

+

XAppStackSidebar — An automatic sidebar widget

+
+
+

Functions

+
++++ + + + + + + + + + + + + + + +
+XAppStackSidebar * + +xapp_stack_sidebar_new () +
+void + +xapp_stack_sidebar_set_stack () +
+GtkStack * + +xapp_stack_sidebar_get_stack () +
+
+
+

Properties

+
+++++ + + + + + +
+GtkStack *stackRead / Write
+
+
+

Types and Values

+
++++ + + + + + + + + + + +
#defineXAPP_TYPE_STACK_SIDEBAR
 XAppStackSidebar
+
+
+

Object Hierarchy

+
    GObject
+    ╰── GInitiallyUnowned
+        ╰── GtkWidget
+            ╰── GtkContainer
+                ╰── GtkBin
+                    ╰── XAppStackSidebar
+
+
+
+

Implemented Interfaces

+

+XAppStackSidebar implements + AtkImplementorIface and GtkBuildable.

+
+
+

Description

+

A XAppStackSidebar allows you to quickly and easily provide a +consistent "sidebar" object for your user interface

+

In order to use a XAppStackSidebar, you simply use a GtkStack to +organize your UI flow, and add the sidebar to your sidebar area. You +can use xapp_stack_sidebar_set_stack() to connect the XAppStackSidebar +to the GtkStack. The XAppStackSidebar is an extended version of the +the GtkStackSidebar that allows showing an icon in addition to the text.

+
+

CSS nodes

+

XAppStackSidebar has a single CSS node with the name stacksidebar and +style class .sidebar

+

When circumstances require it, XAppStackSidebar adds the +.needs-attention style class to the widgets representing the stack +pages.

+
+
+
+

Functions

+
+

xapp_stack_sidebar_new ()

+
XAppStackSidebar *
+xapp_stack_sidebar_new (void);
+

Creates a new sidebar.

+
+

Returns

+

the new XAppStackSidebar

+
+
+
+
+

xapp_stack_sidebar_set_stack ()

+
void
+xapp_stack_sidebar_set_stack (XAppStackSidebar *sidebar,
+                              GtkStack *stack);
+

Set the GtkStack associated with this XAppStackSidebar.

+

The sidebar widget will automatically update according to the order +(packing) and items within the given GtkStack.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

sidebar

a XAppStackSidebar

 

stack

a GtkStack

 
+
+
+
+
+

xapp_stack_sidebar_get_stack ()

+
GtkStack *
+xapp_stack_sidebar_get_stack (XAppStackSidebar *sidebar);
+

Retrieves the stack. +See xapp_stack_sidebar_set_stack().

+
+

Parameters

+
+++++ + + + + + +

sidebar

a XAppStackSidebar

 
+
+
+

Returns

+

the associated GtkStack or +NULL if none has been set explicitly.

+

[nullable][transfer none]

+
+
+
+
+

Types and Values

+
+

XAPP_TYPE_STACK_SIDEBAR

+
#define XAPP_TYPE_STACK_SIDEBAR (xapp_stack_sidebar_get_type ())
+
+
+
+
+

XAppStackSidebar

+
typedef struct _XAppStackSidebar XAppStackSidebar;
+
+
+
+

Property Details

+
+

The “stack” property

+
  “stack”                    GtkStack *
+

Associated stack for this XAppStackSidebar.

+

Flags: Read / Write

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppStatusIcon.html b/docs/reference/XAppStatusIcon.html new file mode 100644 index 0000000..b9e166a --- /dev/null +++ b/docs/reference/XAppStatusIcon.html @@ -0,0 +1,726 @@ + + + + +XAppStatusIcon: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppStatusIcon

+

XAppStatusIcon — Broadcasts status information over DBUS

+
+
+

Functions

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+XAppStatusIcon * + +xapp_status_icon_new () +
+void + +xapp_status_icon_set_name () +
+void + +xapp_status_icon_set_icon_name () +
+void + +xapp_status_icon_set_tooltip_text () +
+void + +xapp_status_icon_set_label () +
+void + +xapp_status_icon_set_visible () +
+void + +xapp_status_icon_set_primary_menu () +
+GtkWidget * + +xapp_status_icon_get_primary_menu () +
+void + +xapp_status_icon_set_secondary_menu () +
+GtkWidget * + +xapp_status_icon_get_secondary_menu () +
+
+
+

Properties

+
+++++ + + + + + + + + + + + + +
+GtkWidget *primary-menuRead / Write
+GtkWidget *secondary-menuRead / Write
+
+
+

Signals

+
+++++ + + + + + + + + + + + + + + + + + +
voidactivateAction
voidbutton-press-eventAction
voidbutton-release-eventAction
+
+
+

Types and Values

+
++++ + + + + + + + + + + +
#defineXAPP_TYPE_STATUS_ICON
 XAppStatusIcon
+
+
+

Object Hierarchy

+
    GObject
+    ╰── XAppStatusIcon
+
+
+
+

Description

+

The XAppStatusIcon allows applications to share status info +about themselves. It replaces the obsolete and very similar +Gtk.StatusIcon widget.

+

If used in an environment where no applet is handling XAppStatusIcons, +the XAppStatusIcon delegates its calls to a Gtk.StatusIcon.

+
+
+

Functions

+
+

xapp_status_icon_new ()

+
XAppStatusIcon *
+xapp_status_icon_new (void);
+

Creates a new XAppStatusIcon instance

+
+

Returns

+

a new XAppStatusIcon. Use g_object_unref when finished.

+

[transfer full]

+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_name ()

+
void
+xapp_status_icon_set_name (XAppStatusIcon *icon,
+                           const gchar *name);
+

Sets the status icon name. This is not shown to users.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

a XAppStatusIcon

 

name

a name (this defaults to the name of the application, if not set)

 
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_icon_name ()

+
void
+xapp_status_icon_set_icon_name (XAppStatusIcon *icon,
+                                const gchar *icon_name);
+

Sets the icon name or local path to use.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

a XAppStatusIcon

 

icon_name

An icon name or absolute path to an icon.

 
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_tooltip_text ()

+
void
+xapp_status_icon_set_tooltip_text (XAppStatusIcon *icon,
+                                   const gchar *tooltip_text);
+

Sets the tooltip text

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

a XAppStatusIcon

 

tooltip_text

the text to show in the tooltip

 
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_label ()

+
void
+xapp_status_icon_set_label (XAppStatusIcon *icon,
+                            const gchar *label);
+

Sets a label, shown beside the icon

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

a XAppStatusIcon

 

label

some text

 
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_visible ()

+
void
+xapp_status_icon_set_visible (XAppStatusIcon *icon,
+                              const gboolean visible);
+

Sets the visibility of the status icon

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

a XAppStatusIcon

 

visible

whether or not the status icon should be visible

 
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_primary_menu ()

+
void
+xapp_status_icon_set_primary_menu (XAppStatusIcon *icon,
+                                   GtkMenu *menu);
+

See the “primary-menu” property for details

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

an XAppStatusIcon

 

menu

A GtkMenu to display when the primary mouse button is released.

[nullable]
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_get_primary_menu ()

+
GtkWidget *
+xapp_status_icon_get_primary_menu (XAppStatusIcon *icon);
+

Returns a pointer to a GtkMenu that was set previously for the +primary mouse button. If no menu was set, this returns NULL.

+
+

Parameters

+
+++++ + + + + + +

icon

an XAppStatusIcon

 
+
+
+

Returns

+

the GtkMenu or NULL if none was set.

+

[transfer none]

+
+

Since: 1.6

+
+
+
+

xapp_status_icon_set_secondary_menu ()

+
void
+xapp_status_icon_set_secondary_menu (XAppStatusIcon *icon,
+                                     GtkMenu *menu);
+

See the “secondary-menu” property for details

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

icon

an XAppStatusIcon

 

menu

A GtkMenu to display when the primary mouse button is released.

[nullable]
+
+

Since: 1.6

+
+
+
+

xapp_status_icon_get_secondary_menu ()

+
GtkWidget *
+xapp_status_icon_get_secondary_menu (XAppStatusIcon *icon);
+

Returns a pointer to a GtkMenu that was set previously for the +secondary mouse button. If no menu was set, this returns NULL.

+
+

Parameters

+
+++++ + + + + + +

icon

an XAppStatusIcon

 
+
+
+

Returns

+

the GtkMenu or NULL if none was set.

+

[transfer none]

+
+

Since: 1.6

+
+
+
+

Types and Values

+
+

XAPP_TYPE_STATUS_ICON

+
#define XAPP_TYPE_STATUS_ICON            (xapp_status_icon_get_type ())
+
+
+
+
+

XAppStatusIcon

+
typedef struct _XAppStatusIcon XAppStatusIcon;
+
+
+
+

Property Details

+
+

The “primary-menu” property

+
  “primary-menu”             GtkWidget *
+

A GtkMenu to use when requested by the remote monitor via a left (or primary) click.

+

When this property is not NULL, the menu will be automatically positioned and +displayed during a primary button release.

+

When this property IS NULL, the “activate” will be sent for primary +button presses.

+

In both cases, the “button-press-event” and “button-release-events” +will be fired like normal.

+

Setting this will remove any floating reference to the menu and assume ownership. +As a result, it is not necessary to maintain a reference to it in the parent +application (or unref it when finished with it - if you wish to replace the menu, +simply call this method again with a new menu.

+

The same GtkMenu widget can be set as both the primary and secondary.

+

Flags: Read / Write

+
+
+
+

The “secondary-menu” property

+
  “secondary-menu”           GtkWidget *
+

A GtkMenu to use when requested by the remote monitor via a right (or secondary) click.

+

When this property is not NULL, the menu will be automatically positioned and +displayed during a secondary button release.

+

When this property IS NULL, the “activate” will be sent for secondary +button presses.

+

In both cases, the “button-press-event” and “button-release-events” +will be fired like normal.

+

Setting this will remove any floating reference to the menu and assume ownership. +As a result, it is not necessary to maintain a reference to it in the parent +application (or unref it when finished with it - if you wish to replace the menu, +simply call this method again with a new menu.

+

The same GtkMenu widget can be set as both the primary and secondary.

+

Flags: Read / Write

+
+
+
+

Signal Details

+
+

The “activate” signal

+
void
+user_function (XAppStatusIcon *icon,
+               guint           button,
+               guint           time,
+               gpointer        user_data)
+

Gets emitted when the user activates the status icon. If the XAppStatusIcon:primary-menu or +XAppStatusIcon:secondary-menu is not NULL, this signal is skipped for the respective button +presses. A middle button click will always send this signal when pressed.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + +

icon

The XAppStatusIcon

 

button

The button that was pressed

 

time

The time supplied by the event, or 0

 

user_data

user data set when the signal handler was connected.

 
+
+

Flags: Action

+
+
+
+

The “button-press-event” signal

+
void
+user_function (XAppStatusIcon *icon,
+               gint            x,
+               gint            y,
+               guint           button,
+               guint           time,
+               gint            panel_position,
+               gpointer        user_data)
+

Gets emitted when there is a button press received from an applet

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

icon

The XAppStatusIcon

 

x

The absolute x position to use for menu positioning

 

y

The absolute y position to use for menu positioning

 

button

The button that was pressed

 

time

The time supplied by the event, or 0

 

panel_position

The GtkPositionType to use for menu positioning

 

user_data

user data set when the signal handler was connected.

 
+
+

Flags: Action

+
+
+
+

The “button-release-event” signal

+
void
+user_function (XAppStatusIcon *icon,
+               gint            x,
+               gint            y,
+               guint           button,
+               guint           time,
+               gint            panel_position,
+               gpointer        user_data)
+

Gets emitted when there is a button release received from an applet

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

icon

The XAppStatusIcon

 

x

The absolute x position to use for menu positioning

 

y

The absolute y position to use for menu positioning

 

button

The button that was released

 

time

The time supplied by the event, or 0

 

panel_position

The GtkPositionType to use for menu positioning

 

user_data

user data set when the signal handler was connected.

 
+
+

Flags: Action

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppStatusIconInterfaceSkeleton.html b/docs/reference/XAppStatusIconInterfaceSkeleton.html new file mode 100644 index 0000000..58ea324 --- /dev/null +++ b/docs/reference/XAppStatusIconInterfaceSkeleton.html @@ -0,0 +1,1869 @@ + + + + +XAppStatusIconInterfaceSkeleton: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppStatusIconInterfaceSkeleton

+

XAppStatusIconInterfaceSkeleton

+
+
+

Functions

+
++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+GDBusInterfaceInfo * + +xapp_status_icon_interface_interface_info () +
+guint + +xapp_status_icon_interface_override_properties () +
+void + +xapp_status_icon_interface_complete_button_press () +
+void + +xapp_status_icon_interface_complete_button_release () +
+void + +xapp_status_icon_interface_call_button_press () +
+gboolean + +xapp_status_icon_interface_call_button_press_finish () +
+gboolean + +xapp_status_icon_interface_call_button_press_sync () +
+void + +xapp_status_icon_interface_call_button_release () +
+gboolean + +xapp_status_icon_interface_call_button_release_finish () +
+gboolean + +xapp_status_icon_interface_call_button_release_sync () +
const gchar * + +xapp_status_icon_interface_get_name () +
+gchar * + +xapp_status_icon_interface_dup_name () +
+void + +xapp_status_icon_interface_set_name () +
const gchar * + +xapp_status_icon_interface_get_icon_name () +
+gchar * + +xapp_status_icon_interface_dup_icon_name () +
+void + +xapp_status_icon_interface_set_icon_name () +
const gchar * + +xapp_status_icon_interface_get_tooltip_text () +
+gchar * + +xapp_status_icon_interface_dup_tooltip_text () +
+void + +xapp_status_icon_interface_set_tooltip_text () +
const gchar * + +xapp_status_icon_interface_get_label () +
+gchar * + +xapp_status_icon_interface_dup_label () +
+void + +xapp_status_icon_interface_set_label () +
+gboolean + +xapp_status_icon_interface_get_visible () +
+void + +xapp_status_icon_interface_set_visible () +
+void + +xapp_status_icon_interface_proxy_new () +
+XAppStatusIconInterface * + +xapp_status_icon_interface_proxy_new_finish () +
+XAppStatusIconInterface * + +xapp_status_icon_interface_proxy_new_sync () +
+void + +xapp_status_icon_interface_proxy_new_for_bus () +
+XAppStatusIconInterface * + +xapp_status_icon_interface_proxy_new_for_bus_finish () +
+XAppStatusIconInterface * + +xapp_status_icon_interface_proxy_new_for_bus_sync () +
+XAppStatusIconInterface * + +xapp_status_icon_interface_skeleton_new () +
+
+
+

Properties

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+gchar *icon-nameRead / Write
+gchar *labelRead / Write
+gchar *nameRead / Write
+gchar *tooltip-textRead / Write
gbooleanvisibleRead / Write
+
+ +
+

Object Hierarchy

+
    GInterface
+    ╰── XAppStatusIconInterface
+    GObject
+    ├── GDBusInterfaceSkeleton
+       ╰── XAppStatusIconInterfaceSkeleton
+    ╰── GDBusProxy
+        ╰── XAppStatusIconInterfaceProxy
+
+
+
+

Description

+
+
+

Functions

+
+

xapp_status_icon_interface_interface_info ()

+
GDBusInterfaceInfo *
+xapp_status_icon_interface_interface_info
+                               (void);
+

Gets a machine-readable description of the org.x.StatusIcon D-Bus interface.

+
+

Returns

+

A GDBusInterfaceInfo. Do not free.

+

[transfer none]

+
+
+
+
+

xapp_status_icon_interface_override_properties ()

+
guint
+xapp_status_icon_interface_override_properties
+                               (GObjectClass *klass,
+                                guint property_id_begin);
+

Overrides all GObject properties in the XAppStatusIconInterface interface for a concrete class. +The properties are overridden in the order they are defined.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

klass

The class structure for a GObject derived class.

 

property_id_begin

The property id to assign to the first overridden property.

 
+
+
+

Returns

+

The last property id.

+
+
+
+
+

xapp_status_icon_interface_complete_button_press ()

+
void
+xapp_status_icon_interface_complete_button_press
+                               (XAppStatusIconInterface *object,
+                                GDBusMethodInvocation *invocation);
+

Helper function used in service implementations to finish handling invocations of the ButtonPress() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.

+

This method will free invocation +, you cannot use it afterwards.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

invocation

A GDBusMethodInvocation.

[transfer full]
+
+
+
+
+

xapp_status_icon_interface_complete_button_release ()

+
void
+xapp_status_icon_interface_complete_button_release
+                               (XAppStatusIconInterface *object,
+                                GDBusMethodInvocation *invocation);
+

Helper function used in service implementations to finish handling invocations of the ButtonRelease() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.

+

This method will free invocation +, you cannot use it afterwards.

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

invocation

A GDBusMethodInvocation.

[transfer full]
+
+
+
+
+

xapp_status_icon_interface_call_button_press ()

+
void
+xapp_status_icon_interface_call_button_press
+                               (XAppStatusIconInterface *proxy,
+                                gint arg_x,
+                                gint arg_y,
+                                guint arg_button,
+                                guint arg_time,
+                                gint arg_panel_position,
+                                GCancellable *cancellable,
+                                GAsyncReadyCallback callback,
+                                gpointer user_data);
+

Asynchronously invokes the ButtonPress() D-Bus method on proxy +. +When the operation is finished, callback + will be invoked in the thread-default main loop of the thread you are calling this method from. +You can then call xapp_status_icon_interface_call_button_press_finish() to get the result of the operation.

+

See xapp_status_icon_interface_call_button_press_sync() for the synchronous, blocking version of this method.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

arg_x

Argument to pass with the method invocation.

 

arg_y

Argument to pass with the method invocation.

 

arg_button

Argument to pass with the method invocation.

 

arg_time

Argument to pass with the method invocation.

 

arg_panel_position

Argument to pass with the method invocation.

 

cancellable

A GCancellable or NULL.

[nullable]

callback

A GAsyncReadyCallback to call when the request is satisfied or NULL.

 

user_data

User data to pass to callback +.

 
+
+
+
+
+

xapp_status_icon_interface_call_button_press_finish ()

+
gboolean
+xapp_status_icon_interface_call_button_press_finish
+                               (XAppStatusIconInterface *proxy,
+                                GAsyncResult *res,
+                                GError **error);
+

Finishes an operation started with xapp_status_icon_interface_call_button_press().

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

res

The GAsyncResult obtained from the GAsyncReadyCallback passed to xapp_status_icon_interface_call_button_press().

 

error

Return location for error or NULL.

 
+
+
+

Returns

+

TRUE if the call succeded, FALSE if error +is set.

+

[skip]

+
+
+
+
+

xapp_status_icon_interface_call_button_press_sync ()

+
gboolean
+xapp_status_icon_interface_call_button_press_sync
+                               (XAppStatusIconInterface *proxy,
+                                gint arg_x,
+                                gint arg_y,
+                                guint arg_button,
+                                guint arg_time,
+                                gint arg_panel_position,
+                                GCancellable *cancellable,
+                                GError **error);
+

Synchronously invokes the ButtonPress() D-Bus method on proxy +. The calling thread is blocked until a reply is received.

+

See xapp_status_icon_interface_call_button_press() for the asynchronous version of this method.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

arg_x

Argument to pass with the method invocation.

 

arg_y

Argument to pass with the method invocation.

 

arg_button

Argument to pass with the method invocation.

 

arg_time

Argument to pass with the method invocation.

 

arg_panel_position

Argument to pass with the method invocation.

 

cancellable

A GCancellable or NULL.

[nullable]

error

Return location for error or NULL.

 
+
+
+

Returns

+

TRUE if the call succeded, FALSE if error +is set.

+

[skip]

+
+
+
+
+

xapp_status_icon_interface_call_button_release ()

+
void
+xapp_status_icon_interface_call_button_release
+                               (XAppStatusIconInterface *proxy,
+                                gint arg_x,
+                                gint arg_y,
+                                guint arg_button,
+                                guint arg_time,
+                                gint arg_panel_position,
+                                GCancellable *cancellable,
+                                GAsyncReadyCallback callback,
+                                gpointer user_data);
+

Asynchronously invokes the ButtonRelease() D-Bus method on proxy +. +When the operation is finished, callback + will be invoked in the thread-default main loop of the thread you are calling this method from. +You can then call xapp_status_icon_interface_call_button_release_finish() to get the result of the operation.

+

See xapp_status_icon_interface_call_button_release_sync() for the synchronous, blocking version of this method.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

arg_x

Argument to pass with the method invocation.

 

arg_y

Argument to pass with the method invocation.

 

arg_button

Argument to pass with the method invocation.

 

arg_time

Argument to pass with the method invocation.

 

arg_panel_position

Argument to pass with the method invocation.

 

cancellable

A GCancellable or NULL.

[nullable]

callback

A GAsyncReadyCallback to call when the request is satisfied or NULL.

 

user_data

User data to pass to callback +.

 
+
+
+
+
+

xapp_status_icon_interface_call_button_release_finish ()

+
gboolean
+xapp_status_icon_interface_call_button_release_finish
+                               (XAppStatusIconInterface *proxy,
+                                GAsyncResult *res,
+                                GError **error);
+

Finishes an operation started with xapp_status_icon_interface_call_button_release().

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

res

The GAsyncResult obtained from the GAsyncReadyCallback passed to xapp_status_icon_interface_call_button_release().

 

error

Return location for error or NULL.

 
+
+
+

Returns

+

TRUE if the call succeded, FALSE if error +is set.

+

[skip]

+
+
+
+
+

xapp_status_icon_interface_call_button_release_sync ()

+
gboolean
+xapp_status_icon_interface_call_button_release_sync
+                               (XAppStatusIconInterface *proxy,
+                                gint arg_x,
+                                gint arg_y,
+                                guint arg_button,
+                                guint arg_time,
+                                gint arg_panel_position,
+                                GCancellable *cancellable,
+                                GError **error);
+

Synchronously invokes the ButtonRelease() D-Bus method on proxy +. The calling thread is blocked until a reply is received.

+

See xapp_status_icon_interface_call_button_release() for the asynchronous version of this method.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

proxy

A XAppStatusIconInterfaceProxy.

 

arg_x

Argument to pass with the method invocation.

 

arg_y

Argument to pass with the method invocation.

 

arg_button

Argument to pass with the method invocation.

 

arg_time

Argument to pass with the method invocation.

 

arg_panel_position

Argument to pass with the method invocation.

 

cancellable

A GCancellable or NULL.

[nullable]

error

Return location for error or NULL.

 
+
+
+

Returns

+

TRUE if the call succeded, FALSE if error +is set.

+

[skip]

+
+
+
+
+

xapp_status_icon_interface_get_name ()

+
const gchar *
+xapp_status_icon_interface_get_name (XAppStatusIconInterface *object);
+

Gets the value of the "Name" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+
The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where object was constructed. Use xapp_status_icon_interface_dup_name() if on another thread.
+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. Do not free the returned value, it belongs to object +.

+

[transfer none]

+
+
+
+
+

xapp_status_icon_interface_dup_name ()

+
gchar *
+xapp_status_icon_interface_dup_name (XAppStatusIconInterface *object);
+

Gets a copy of the "Name" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. The returned value should be freed with g_free().

+

[transfer full]

+
+
+
+
+

xapp_status_icon_interface_set_name ()

+
void
+xapp_status_icon_interface_set_name (XAppStatusIconInterface *object,
+                                     const gchar *value);
+

Sets the "Name" D-Bus property to value +.

+

Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

value

The value to set.

 
+
+
+
+
+

xapp_status_icon_interface_get_icon_name ()

+
const gchar *
+xapp_status_icon_interface_get_icon_name
+                               (XAppStatusIconInterface *object);
+

Gets the value of the "IconName" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+
The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where object was constructed. Use xapp_status_icon_interface_dup_icon_name() if on another thread.
+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. Do not free the returned value, it belongs to object +.

+

[transfer none]

+
+
+
+
+

xapp_status_icon_interface_dup_icon_name ()

+
gchar *
+xapp_status_icon_interface_dup_icon_name
+                               (XAppStatusIconInterface *object);
+

Gets a copy of the "IconName" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. The returned value should be freed with g_free().

+

[transfer full]

+
+
+
+
+

xapp_status_icon_interface_set_icon_name ()

+
void
+xapp_status_icon_interface_set_icon_name
+                               (XAppStatusIconInterface *object,
+                                const gchar *value);
+

Sets the "IconName" D-Bus property to value +.

+

Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

value

The value to set.

 
+
+
+
+
+

xapp_status_icon_interface_get_tooltip_text ()

+
const gchar *
+xapp_status_icon_interface_get_tooltip_text
+                               (XAppStatusIconInterface *object);
+

Gets the value of the "TooltipText" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+
The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where object was constructed. Use xapp_status_icon_interface_dup_tooltip_text() if on another thread.
+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. Do not free the returned value, it belongs to object +.

+

[transfer none]

+
+
+
+
+

xapp_status_icon_interface_dup_tooltip_text ()

+
gchar *
+xapp_status_icon_interface_dup_tooltip_text
+                               (XAppStatusIconInterface *object);
+

Gets a copy of the "TooltipText" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. The returned value should be freed with g_free().

+

[transfer full]

+
+
+
+
+

xapp_status_icon_interface_set_tooltip_text ()

+
void
+xapp_status_icon_interface_set_tooltip_text
+                               (XAppStatusIconInterface *object,
+                                const gchar *value);
+

Sets the "TooltipText" D-Bus property to value +.

+

Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

value

The value to set.

 
+
+
+
+
+

xapp_status_icon_interface_get_label ()

+
const gchar *
+xapp_status_icon_interface_get_label (XAppStatusIconInterface *object);
+

Gets the value of the "Label" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+
The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where object was constructed. Use xapp_status_icon_interface_dup_label() if on another thread.
+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. Do not free the returned value, it belongs to object +.

+

[transfer none]

+
+
+
+
+

xapp_status_icon_interface_dup_label ()

+
gchar *
+xapp_status_icon_interface_dup_label (XAppStatusIconInterface *object);
+

Gets a copy of the "Label" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value or NULL if the property is not set. The returned value should be freed with g_free().

+

[transfer full]

+
+
+
+
+

xapp_status_icon_interface_set_label ()

+
void
+xapp_status_icon_interface_set_label (XAppStatusIconInterface *object,
+                                      const gchar *value);
+

Sets the "Label" D-Bus property to value +.

+

Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

value

The value to set.

 
+
+
+
+
+

xapp_status_icon_interface_get_visible ()

+
gboolean
+xapp_status_icon_interface_get_visible
+                               (XAppStatusIconInterface *object);
+

Gets the value of the "Visible" D-Bus property.

+

Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + +

object

A XAppStatusIconInterface.

 
+
+
+

Returns

+

The property value.

+
+
+
+
+

xapp_status_icon_interface_set_visible ()

+
void
+xapp_status_icon_interface_set_visible
+                               (XAppStatusIconInterface *object,
+                                gboolean value);
+

Sets the "Visible" D-Bus property to value +.

+

Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.

+

[skip]

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

value

The value to set.

 
+
+
+
+
+

xapp_status_icon_interface_proxy_new ()

+
void
+xapp_status_icon_interface_proxy_new (GDBusConnection *connection,
+                                      GDBusProxyFlags flags,
+                                      const gchar *name,
+                                      const gchar *object_path,
+                                      GCancellable *cancellable,
+                                      GAsyncReadyCallback callback,
+                                      gpointer user_data);
+

Asynchronously creates a proxy for the D-Bus interface org.x.StatusIcon. See g_dbus_proxy_new() for more details.

+

When the operation is finished, callback + will be invoked in the thread-default main loop of the thread you are calling this method from. +You can then call xapp_status_icon_interface_proxy_new_finish() to get the result of the operation.

+

See xapp_status_icon_interface_proxy_new_sync() for the synchronous, blocking version of this constructor.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

connection

A GDBusConnection.

 

flags

Flags from the GDBusProxyFlags enumeration.

 

name

A bus name (well-known or unique) or NULL if connection +is not a message bus connection.

[nullable]

object_path

An object path.

 

cancellable

A GCancellable or NULL.

[nullable]

callback

A GAsyncReadyCallback to call when the request is satisfied.

 

user_data

User data to pass to callback +.

 
+
+
+
+
+

xapp_status_icon_interface_proxy_new_finish ()

+
XAppStatusIconInterface *
+xapp_status_icon_interface_proxy_new_finish
+                               (GAsyncResult *res,
+                                GError **error);
+

Finishes an operation started with xapp_status_icon_interface_proxy_new().

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

res

The GAsyncResult obtained from the GAsyncReadyCallback passed to xapp_status_icon_interface_proxy_new().

 

error

Return location for error or NULL

 
+
+
+

Returns

+

The constructed proxy object or NULL if error +is set.

+

[transfer full][type XAppStatusIconInterfaceProxy]

+
+
+
+
+

xapp_status_icon_interface_proxy_new_sync ()

+
XAppStatusIconInterface *
+xapp_status_icon_interface_proxy_new_sync
+                               (GDBusConnection *connection,
+                                GDBusProxyFlags flags,
+                                const gchar *name,
+                                const gchar *object_path,
+                                GCancellable *cancellable,
+                                GError **error);
+

Synchronously creates a proxy for the D-Bus interface org.x.StatusIcon. See g_dbus_proxy_new_sync() for more details.

+

The calling thread is blocked until a reply is received.

+

See xapp_status_icon_interface_proxy_new() for the asynchronous version of this constructor.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

connection

A GDBusConnection.

 

flags

Flags from the GDBusProxyFlags enumeration.

 

name

A bus name (well-known or unique) or NULL if connection +is not a message bus connection.

[nullable]

object_path

An object path.

 

cancellable

A GCancellable or NULL.

[nullable]

error

Return location for error or NULL

 
+
+
+

Returns

+

The constructed proxy object or NULL if error +is set.

+

[transfer full][type XAppStatusIconInterfaceProxy]

+
+
+
+
+

xapp_status_icon_interface_proxy_new_for_bus ()

+
void
+xapp_status_icon_interface_proxy_new_for_bus
+                               (GBusType bus_type,
+                                GDBusProxyFlags flags,
+                                const gchar *name,
+                                const gchar *object_path,
+                                GCancellable *cancellable,
+                                GAsyncReadyCallback callback,
+                                gpointer user_data);
+

Like xapp_status_icon_interface_proxy_new() but takes a GBusType instead of a GDBusConnection.

+

When the operation is finished, callback + will be invoked in the thread-default main loop of the thread you are calling this method from. +You can then call xapp_status_icon_interface_proxy_new_for_bus_finish() to get the result of the operation.

+

See xapp_status_icon_interface_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

bus_type

A GBusType.

 

flags

Flags from the GDBusProxyFlags enumeration.

 

name

A bus name (well-known or unique).

 

object_path

An object path.

 

cancellable

A GCancellable or NULL.

[nullable]

callback

A GAsyncReadyCallback to call when the request is satisfied.

 

user_data

User data to pass to callback +.

 
+
+
+
+
+

xapp_status_icon_interface_proxy_new_for_bus_finish ()

+
XAppStatusIconInterface *
+xapp_status_icon_interface_proxy_new_for_bus_finish
+                               (GAsyncResult *res,
+                                GError **error);
+

Finishes an operation started with xapp_status_icon_interface_proxy_new_for_bus().

+
+

Parameters

+
+++++ + + + + + + + + + + + + +

res

The GAsyncResult obtained from the GAsyncReadyCallback passed to xapp_status_icon_interface_proxy_new_for_bus().

 

error

Return location for error or NULL

 
+
+
+

Returns

+

The constructed proxy object or NULL if error +is set.

+

[transfer full][type XAppStatusIconInterfaceProxy]

+
+
+
+
+

xapp_status_icon_interface_proxy_new_for_bus_sync ()

+
XAppStatusIconInterface *
+xapp_status_icon_interface_proxy_new_for_bus_sync
+                               (GBusType bus_type,
+                                GDBusProxyFlags flags,
+                                const gchar *name,
+                                const gchar *object_path,
+                                GCancellable *cancellable,
+                                GError **error);
+

Like xapp_status_icon_interface_proxy_new_sync() but takes a GBusType instead of a GDBusConnection.

+

The calling thread is blocked until a reply is received.

+

See xapp_status_icon_interface_proxy_new_for_bus() for the asynchronous version of this constructor.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

bus_type

A GBusType.

 

flags

Flags from the GDBusProxyFlags enumeration.

 

name

A bus name (well-known or unique).

 

object_path

An object path.

 

cancellable

A GCancellable or NULL.

[nullable]

error

Return location for error or NULL

 
+
+
+

Returns

+

The constructed proxy object or NULL if error +is set.

+

[transfer full][type XAppStatusIconInterfaceProxy]

+
+
+
+
+

xapp_status_icon_interface_skeleton_new ()

+
XAppStatusIconInterface *
+xapp_status_icon_interface_skeleton_new
+                               (void);
+

Creates a skeleton object for the D-Bus interface org.x.StatusIcon.

+
+

Returns

+

The skeleton object.

+

[transfer full][type XAppStatusIconInterfaceSkeleton]

+
+
+
+
+

Types and Values

+
+
+

Property Details

+
+

The “icon-name” property

+
  “icon-name”                gchar *
+

Represents the D-Bus property "IconName".

+

Since the D-Bus property for this GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.

+

Flags: Read / Write

+

Default value: NULL

+
+
+
+

The “label” property

+
  “label”                    gchar *
+

Represents the D-Bus property "Label".

+

Since the D-Bus property for this GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.

+

Flags: Read / Write

+

Default value: NULL

+
+
+
+

The “name” property

+
  “name”                     gchar *
+

Represents the D-Bus property "Name".

+

Since the D-Bus property for this GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.

+

Flags: Read / Write

+

Default value: NULL

+
+
+
+

The “tooltip-text” property

+
  “tooltip-text”             gchar *
+

Represents the D-Bus property "TooltipText".

+

Since the D-Bus property for this GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.

+

Flags: Read / Write

+

Default value: NULL

+
+
+
+

The “visible” property

+
  “visible”                  gboolean
+

Represents the D-Bus property "Visible".

+

Since the D-Bus property for this GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.

+

Flags: Read / Write

+

Default value: FALSE

+
+
+
+

Signal Details

+
+

The “handle-button-press” signal

+
gboolean
+user_function (XAppStatusIconInterface *object,
+               GDBusMethodInvocation   *invocation,
+               gint                     arg_x,
+               gint                     arg_y,
+               guint                    arg_button,
+               guint                    arg_time,
+               gint                     arg_panel_position,
+               gpointer                 user_data)
+

Signal emitted when a remote caller is invoking the ButtonPress() D-Bus method.

+

If a signal handler returns TRUE, it means the signal handler will handle the invocation (e.g. take a reference to invocation + and eventually call xapp_status_icon_interface_complete_button_press() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the G_DBUS_ERROR_UNKNOWN_METHOD error is returned.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

invocation

A GDBusMethodInvocation.

 

arg_x

Argument passed by remote caller.

 

arg_y

Argument passed by remote caller.

 

arg_button

Argument passed by remote caller.

 

arg_time

Argument passed by remote caller.

 

arg_panel_position

Argument passed by remote caller.

 

user_data

user data set when the signal handler was connected.

 
+
+
+

Returns

+

TRUE if the invocation was handled, FALSE to let other signal handlers run.

+
+

Flags: Run Last

+
+
+
+

The “handle-button-release” signal

+
gboolean
+user_function (XAppStatusIconInterface *object,
+               GDBusMethodInvocation   *invocation,
+               gint                     arg_x,
+               gint                     arg_y,
+               guint                    arg_button,
+               guint                    arg_time,
+               gint                     arg_panel_position,
+               gpointer                 user_data)
+

Signal emitted when a remote caller is invoking the ButtonRelease() D-Bus method.

+

If a signal handler returns TRUE, it means the signal handler will handle the invocation (e.g. take a reference to invocation + and eventually call xapp_status_icon_interface_complete_button_release() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the G_DBUS_ERROR_UNKNOWN_METHOD error is returned.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

object

A XAppStatusIconInterface.

 

invocation

A GDBusMethodInvocation.

 

arg_x

Argument passed by remote caller.

 

arg_y

Argument passed by remote caller.

 

arg_button

Argument passed by remote caller.

 

arg_time

Argument passed by remote caller.

 

arg_panel_position

Argument passed by remote caller.

 

user_data

user data set when the signal handler was connected.

 
+
+
+

Returns

+

TRUE if the invocation was handled, FALSE to let other signal handlers run.

+
+

Flags: Run Last

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/XAppStatusIconMonitor.html b/docs/reference/XAppStatusIconMonitor.html new file mode 100644 index 0000000..681c51c --- /dev/null +++ b/docs/reference/XAppStatusIconMonitor.html @@ -0,0 +1,261 @@ + + + + +XAppStatusIconMonitor: XApp Reference Manual + + + + + + + + + + + + + + + + +
+
+
+ + +
+

XAppStatusIconMonitor

+

XAppStatusIconMonitor — Looks for XAppStatusIcons on DBUS and communicates +info to an applet to represent the icons.

+
+
+

Functions

+ +
+
+

Signals

+
+++++ + + + + + + + + + + + + +
voidicon-addedAction
voidicon-removedAction
+
+
+

Types and Values

+
++++ + + + + + + + + + + +
#defineXAPP_TYPE_STATUS_ICON_MONITOR
 XAppStatusIconMonitor
+
+
+

Object Hierarchy

+
    GObject
+    ╰── XAppStatusIconMonitor
+
+
+
+

Description

+

The XAppStatusIconMonitor is intended to be utilized by some status applet +to display info about an app.

+

The simplest way to use is to make a new instance of this monitor, and connect +to the “icon-added” and “icon-removed” signals. +The received object for both of these signals is an XAppStatusIconInterfaceProxy. +It represents an application's XAppStatusIcon, and has properties available for +describing the icon name, tooltip, label and visibility.

+

The proxy also provides methods to handle clicks, which can be called by the applet, +to request that the app display its menu.

+
+
+

Functions

+
+

xapp_status_icon_monitor_new ()

+
XAppStatusIconMonitor *
+xapp_status_icon_monitor_new (void);
+

Creates a new monitor.

+
+

Returns

+

a new XAppStatusIconMonitor. Use g_object_unref when finished.

+

[transfer full]

+
+

Since: 1.6

+
+
+
+

xapp_status_icon_monitor_list_icons ()

+
GList *
+xapp_status_icon_monitor_list_icons (XAppStatusIconMonitor *monitor);
+

List known icon proxies.

+
+

Parameters

+
+++++ + + + + + +

monitor

a XAppStatusIconMonitor

 
+
+
+

Returns

+

a GList of icons.

+

[element-type XAppStatusIconMonitor][transfer container]

+
+

Since: 1.6

+
+
+
+

Types and Values

+
+

XAPP_TYPE_STATUS_ICON_MONITOR

+
#define XAPP_TYPE_STATUS_ICON_MONITOR   (xapp_status_icon_monitor_get_type ())
+
+
+
+
+

XAppStatusIconMonitor

+
typedef struct _XAppStatusIconMonitor XAppStatusIconMonitor;
+
+
+
+

Signal Details

+
+

The “icon-added” signal

+
void
+user_function (XAppStatusIconMonitor        *monitor,
+               XAppStatusIconInterfaceProxy *proxy,
+               gpointer                      user_data)
+

This signal is emitted by the monitor when it has discovered a new +XAppStatusIcon on the bus.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

monitor

the XAppStatusIconMonitor

 

proxy

the interface proxy for the XAppStatusIcon that has been added.

 

user_data

user data set when the signal handler was connected.

 
+
+

Flags: Action

+
+
+
+

The “icon-removed” signal

+
void
+user_function (XAppStatusIconMonitor        *monitor,
+               XAppStatusIconInterfaceProxy *proxy,
+               gpointer                      user_data)
+

This signal is emitted by the monitor when an XAppStatusIcon has disappeared +from the bus.

+
+

Parameters

+
+++++ + + + + + + + + + + + + + + + + + +

monitor

the XAppStatusIconMonitor

 

proxy

the XAppStatusIcon proxy that has been removed.

 

user_data

user data set when the signal handler was connected.

 
+
+

Flags: Action

+
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/annotation-glossary.html b/docs/reference/annotation-glossary.html new file mode 100644 index 0000000..380401d --- /dev/null +++ b/docs/reference/annotation-glossary.html @@ -0,0 +1,57 @@ + + + + +Annotation Glossary: XApp Reference Manual + + + + + + + + + + + + + + + +
+

+Annotation Glossary

+

A

+
array
+

Parameter points to an array of items.

+

E

+
element-type
+

Generics and defining elements of containers and arrays.

+

N

+
nullable
+

NULL may be passed as the value in, out, in-out; or as a return value.

+

S

+
skip
+

Exposed in C code, not necessarily available in other languages.

+

T

+
transfer container
+

Free data container after the code is done.

+
transfer full
+

Free data after the code is done.

+
transfer none
+

Don't free data after the code is done.

+
type
+

Override the parsed C type with given type.

+
+ + + \ No newline at end of file diff --git a/docs/reference/api-index-full.html b/docs/reference/api-index-full.html new file mode 100644 index 0000000..ff11d59 --- /dev/null +++ b/docs/reference/api-index-full.html @@ -0,0 +1,620 @@ + + + + +API Index: XApp Reference Manual + + + + + + + + + + + + + + + + +
+

+API Index

+

G

+
+XAppGtkWindow, struct in XAppGtkWindow +
+
+
+XAppGtkWindowClass, struct in XAppGtkWindow +
+
+
+xapp_gtk_window_new, function in XAppGtkWindow +
+
+
+xapp_gtk_window_set_icon_from_file, function in XAppGtkWindow +
+
+
+xapp_gtk_window_set_icon_name, function in XAppGtkWindow +
+
+
+xapp_gtk_window_set_progress, function in XAppGtkWindow +
+
+
+xapp_gtk_window_set_progress_pulse, function in XAppGtkWindow +
+
+

I

+
+XAppIconChooserButton, struct in XAppIconChooserButton +
+
+
+XAppIconChooserButton:category, object property in XAppIconChooserButton +
+
+
+XAppIconChooserButton:icon, object property in XAppIconChooserButton +
+
+
+XAppIconChooserButton:icon-size, object property in XAppIconChooserButton +
+
+
+XAppIconChooserDialog, struct in XAppIconChooserDialog +
+
+
+XAppIconChooserDialog::close, object signal in XAppIconChooserDialog +
+
+
+XAppIconChooserDialog::select, object signal in XAppIconChooserDialog +
+
+
+XAppIconChooserDialog:allow-paths, object property in XAppIconChooserDialog +
+
+
+XAppIconChooserDialog:default-icon, object property in XAppIconChooserDialog +
+
+
+XAppIconChooserDialog:icon-size, object property in XAppIconChooserDialog +
+
+
+XAppIconSize, enum in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_button_get_dialog, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_get_icon, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_new, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_new_with_size, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_set_default_category, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_set_icon, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_button_set_icon_size, function in XAppIconChooserButton +
+
+
+xapp_icon_chooser_dialog_add_button, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_add_custom_category, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_get_default_icon, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_get_icon_string, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_new, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_run, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_run_with_category, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_run_with_icon, function in XAppIconChooserDialog +
+
+
+xapp_icon_chooser_dialog_set_default_icon, function in XAppIconChooserDialog +
+
+

K

+
+XAppKbdLayoutController::config-changed, object signal in XAppKbdLayoutController +
+
+
+XAppKbdLayoutController::layout-changed, object signal in XAppKbdLayoutController +
+
+
+XAppKbdLayoutController:enabled, object property in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_all_names, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_flag_id, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_icon_name, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_name, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_short_group_label, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_current_variant_label, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_enabled, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_flag_id_for_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_icon_name_for_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_short_group_label_for_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_get_variant_label_for_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_new, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_next_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_previous_group, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_render_cairo_subscript, function in XAppKbdLayoutController +
+
+
+xapp_kbd_layout_controller_set_current_group, function in XAppKbdLayoutController +
+
+

M

+
+xapp_monitor_blanker_are_monitors_blanked, function in XAppMonitorBlanker +
+
+
+xapp_monitor_blanker_blank_other_monitors, function in XAppMonitorBlanker +
+
+
+xapp_monitor_blanker_new, function in XAppMonitorBlanker +
+
+
+xapp_monitor_blanker_unblank_monitors, function in XAppMonitorBlanker +
+
+

P

+
+XAppPreferencesWindow, struct in XAppPreferencesWindow +
+
+
+XAppPreferencesWindow::close, object signal in XAppPreferencesWindow +
+
+
+XAppPreferencesWindowClass, struct in XAppPreferencesWindow +
+
+
+xapp_preferences_window_add_button, function in XAppPreferencesWindow +
+
+
+xapp_preferences_window_add_page, function in XAppPreferencesWindow +
+
+
+xapp_preferences_window_new, function in XAppPreferencesWindow +
+
+

S

+
+xapp_set_window_icon_from_file, function in XAppGtkWindow +
+
+
+xapp_set_window_icon_name, function in XAppGtkWindow +
+
+
+xapp_set_window_progress, function in XAppGtkWindow +
+
+
+xapp_set_window_progress_pulse, function in XAppGtkWindow +
+
+
+xapp_set_xid_icon_from_file, function in XAppGtkWindow +
+
+
+xapp_set_xid_icon_name, function in XAppGtkWindow +
+
+
+xapp_set_xid_progress, function in XAppGtkWindow +
+
+
+xapp_set_xid_progress_pulse, function in XAppGtkWindow +
+
+
+XAppStackSidebar, struct in XAppStackSidebar +
+
+
+XAppStackSidebar:stack, object property in XAppStackSidebar +
+
+
+xapp_stack_sidebar_get_stack, function in XAppStackSidebar +
+
+
+xapp_stack_sidebar_new, function in XAppStackSidebar +
+
+
+xapp_stack_sidebar_set_stack, function in XAppStackSidebar +
+
+
+XAppStatusIcon, struct in XAppStatusIcon +
+
+
+XAppStatusIcon::activate, object signal in XAppStatusIcon +
+
+
+XAppStatusIcon::button-press-event, object signal in XAppStatusIcon +
+
+
+XAppStatusIcon::button-release-event, object signal in XAppStatusIcon +
+
+
+XAppStatusIcon:primary-menu, object property in XAppStatusIcon +
+
+
+XAppStatusIcon:secondary-menu, object property in XAppStatusIcon +
+
+
+XAppStatusIconInterface::handle-button-press, object signal in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface::handle-button-release, object signal in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface:icon-name, object property in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface:label, object property in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface:name, object property in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface:tooltip-text, object property in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconInterface:visible, object property in XAppStatusIconInterfaceSkeleton +
+
+
+XAppStatusIconMonitor, struct in XAppStatusIconMonitor +
+
+
+XAppStatusIconMonitor::icon-added, object signal in XAppStatusIconMonitor +
+
+
+XAppStatusIconMonitor::icon-removed, object signal in XAppStatusIconMonitor +
+
+
+xapp_status_icon_get_primary_menu, function in XAppStatusIcon +
+
+
+xapp_status_icon_get_secondary_menu, function in XAppStatusIcon +
+
+
+xapp_status_icon_interface_call_button_press, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_call_button_press_finish, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_call_button_press_sync, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_call_button_release, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_call_button_release_finish, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_call_button_release_sync, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_complete_button_press, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_complete_button_release, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_dup_icon_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_dup_label, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_dup_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_dup_tooltip_text, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_get_icon_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_get_label, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_get_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_get_tooltip_text, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_get_visible, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_interface_info, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_override_properties, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new_finish, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new_for_bus, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new_for_bus_finish, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new_for_bus_sync, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_proxy_new_sync, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_set_icon_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_set_label, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_set_name, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_set_tooltip_text, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_set_visible, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_interface_skeleton_new, function in XAppStatusIconInterfaceSkeleton +
+
+
+xapp_status_icon_monitor_list_icons, function in XAppStatusIconMonitor +
+
+
+xapp_status_icon_monitor_new, function in XAppStatusIconMonitor +
+
+
+xapp_status_icon_new, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_icon_name, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_label, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_name, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_primary_menu, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_secondary_menu, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_tooltip_text, function in XAppStatusIcon +
+
+
+xapp_status_icon_set_visible, function in XAppStatusIcon +
+
+

T

+
+XAPP_TYPE_GTK_WINDOW, macro in XAppGtkWindow +
+
+
+XAPP_TYPE_ICON_CHOOSER_BUTTON, macro in XAppIconChooserButton +
+
+
+XAPP_TYPE_ICON_CHOOSER_DIALOG, macro in XAppIconChooserDialog +
+
+
+XAPP_TYPE_PREFERENCES_WINDOW, macro in XAppPreferencesWindow +
+
+
+XAPP_TYPE_STACK_SIDEBAR, macro in XAppStackSidebar +
+
+
+XAPP_TYPE_STATUS_ICON, macro in XAppStatusIcon +
+
+
+XAPP_TYPE_STATUS_ICON_MONITOR, macro in XAppStatusIconMonitor +
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/ch01.html b/docs/reference/ch01.html new file mode 100644 index 0000000..d26320e --- /dev/null +++ b/docs/reference/ch01.html @@ -0,0 +1,63 @@ + + + + +API reference: XApp Reference Manual + + + + + + + + + + + + + + + + +
+

+API reference

+
+
+XAppGtkWindow — A subclass of GtkWindow that allows additional + communication with the window manager. +
+
+XAppIconChooserButton — A button for selecting an icon +
+
+XAppIconChooserDialog — A dialog for selecting an icon +
+
+XAppKbdLayoutController — Keyboard layout selection UI element provider. +
+
+XAppMonitorBlanker — Blank and unblank unused monitors +
+
+XAppPreferencesWindow — A base preferences window +
+
+XAppStackSidebar — An automatic sidebar widget +
+
+XAppStatusIcon — Broadcasts status information over DBUS +
+
+XAppStatusIconMonitor — Looks for XAppStatusIcons on DBUS and communicates +info to an applet to represent the icons. +
+
+XAppStatusIconInterfaceSkeleton +
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/deprecated-api-index.html b/docs/reference/deprecated-api-index.html new file mode 100644 index 0000000..e1b77fa --- /dev/null +++ b/docs/reference/deprecated-api-index.html @@ -0,0 +1,30 @@ + + + + +Index of deprecated API: XApp Reference Manual + + + + + + + + + + + + + + + + +
+

+Index of deprecated API

+ +
+ + + \ No newline at end of file diff --git a/docs/reference/home.png b/docs/reference/home.png new file mode 100644 index 0000000..b293af5 Binary files /dev/null and b/docs/reference/home.png differ diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..920d2e8 --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,68 @@ + + + + +XApp Reference Manual: XApp Reference Manual + + + + + + + +
+
+
+
+

+ xapp 1.5.0 +

+
+
+
+
+
API reference
+
+
+XAppGtkWindow — A subclass of GtkWindow that allows additional + communication with the window manager. +
+
+XAppIconChooserButton — A button for selecting an icon +
+
+XAppIconChooserDialog — A dialog for selecting an icon +
+
+XAppKbdLayoutController — Keyboard layout selection UI element provider. +
+
+XAppMonitorBlanker — Blank and unblank unused monitors +
+
+XAppPreferencesWindow — A base preferences window +
+
+XAppStackSidebar — An automatic sidebar widget +
+
+XAppStatusIcon — Broadcasts status information over DBUS +
+
+XAppStatusIconMonitor — Looks for XAppStatusIcons on DBUS and communicates +info to an applet to represent the icons. +
+
+XAppStatusIconInterfaceSkeleton +
+
+
Object Hierarchy
+
API Index
+
Index of deprecated API
+
Annotation Glossary
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/left-insensitive.png b/docs/reference/left-insensitive.png new file mode 100644 index 0000000..903790a Binary files /dev/null and b/docs/reference/left-insensitive.png differ diff --git a/docs/reference/left.png b/docs/reference/left.png new file mode 100644 index 0000000..21b31e3 Binary files /dev/null and b/docs/reference/left.png differ diff --git a/docs/reference/libxapp.devhelp2 b/docs/reference/libxapp.devhelp2 new file mode 100644 index 0000000..414d885 --- /dev/null +++ b/docs/reference/libxapp.devhelp2 @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/reference/object-tree.html b/docs/reference/object-tree.html new file mode 100644 index 0000000..a2f745d --- /dev/null +++ b/docs/reference/object-tree.html @@ -0,0 +1,55 @@ + + + + +Object Hierarchy: XApp Reference Manual + + + + + + + + + + + + + + + + +
+

+Object Hierarchy

+
+    GObject
+    ├── GInitiallyUnowned
+       ╰── GtkWidget
+           ╰── GtkContainer
+               ╰── GtkBin
+                   ├── GtkWindow
+                      ├── XAppGtkWindow
+                         ╰── XAppIconChooserDialog
+                      ╰── XAppPreferencesWindow
+                   ├── GtkButton
+                      ╰── XAppIconChooserButton
+                   ╰── XAppStackSidebar
+    ├── XAppKbdLayoutController
+    ├── XAppMonitorBlanker
+    ├── XAppStatusIcon
+    ├── GDBusProxy
+       ╰── XAppStatusIconInterfaceProxy
+    ├── GDBusInterfaceSkeleton
+       ╰── XAppStatusIconInterfaceSkeleton
+    ╰── XAppStatusIconMonitor
+    GInterface
+    ╰── XAppStatusIconInterface
+    GEnum
+    ╰── XAppIconSize
+
+
+ + + \ No newline at end of file diff --git a/docs/reference/right-insensitive.png b/docs/reference/right-insensitive.png new file mode 100644 index 0000000..a3696bf Binary files /dev/null and b/docs/reference/right-insensitive.png differ diff --git a/docs/reference/right.png b/docs/reference/right.png new file mode 100644 index 0000000..73d25da Binary files /dev/null and b/docs/reference/right.png differ diff --git a/docs/reference/style.css b/docs/reference/style.css new file mode 100644 index 0000000..3675420 --- /dev/null +++ b/docs/reference/style.css @@ -0,0 +1,479 @@ +body +{ + font-family: cantarell, sans-serif; +} +.synopsis, .classsynopsis +{ + /* tango:aluminium 1/2 */ + background: #eeeeec; + background: rgba(238, 238, 236, 0.5); + border: solid 1px rgb(238, 238, 236); + padding: 0.5em; +} +.programlisting +{ + /* tango:sky blue 0/1 */ + /* fallback for no rgba support */ + background: #e6f3ff; + border: solid 1px #729fcf; + background: rgba(114, 159, 207, 0.1); + border: solid 1px rgba(114, 159, 207, 0.2); + padding: 0.5em; +} +.variablelist +{ + padding: 4px; + margin-left: 3em; +} +.variablelist td:first-child +{ + vertical-align: top; +} + +div.gallery-float +{ + float: left; + padding: 10px; +} +div.gallery-float img +{ + border-style: none; +} +div.gallery-spacer +{ + clear: both; +} + +a, a:visited +{ + text-decoration: none; + /* tango:sky blue 2 */ + color: #3465a4; +} +a:hover +{ + text-decoration: underline; + /* tango:sky blue 1 */ + color: #729fcf; +} + +div.informaltable table +{ + border-collapse: separate; + border-spacing: 1em 0.3em; + border: none; +} + +div.informaltable table td, div.informaltable table th +{ + vertical-align: top; +} + +.function_type, +.variable_type, +.property_type, +.signal_type, +.parameter_name, +.struct_member_name, +.union_member_name, +.define_keyword, +.datatype_keyword, +.typedef_keyword +{ + text-align: right; +} + +/* dim non-primary columns */ +.c_punctuation, +.function_type, +.variable_type, +.property_type, +.signal_type, +.define_keyword, +.datatype_keyword, +.typedef_keyword, +.property_flags, +.signal_flags, +.parameter_annotations, +.enum_member_annotations, +.struct_member_annotations, +.union_member_annotations +{ + color: #888a85; +} + +.function_type a, +.function_type a:visited, +.function_type a:hover, +.property_type a, +.property_type a:visited, +.property_type a:hover, +.signal_type a, +.signal_type a:visited, +.signal_type a:hover, +.signal_flags a, +.signal_flags a:visited, +.signal_flags a:hover +{ + color: #729fcf; +} + +td p +{ + margin: 0.25em; +} + +div.table table +{ + border-collapse: collapse; + border-spacing: 0px; + /* tango:aluminium 3 */ + border: solid 1px #babdb6; +} + +div.table table td, div.table table th +{ + /* tango:aluminium 3 */ + border: solid 1px #babdb6; + padding: 3px; + vertical-align: top; +} + +div.table table th +{ + /* tango:aluminium 2 */ + background-color: #d3d7cf; +} + +h4 +{ + color: #555753; + margin-top: 1em; + margin-bottom: 1em; +} + +hr +{ + /* tango:aluminium 1 */ + color: #d3d7cf; + background: #d3d7cf; + border: none 0px; + height: 1px; + clear: both; + margin: 2.0em 0em 2.0em 0em; +} + +dl.toc dt +{ + padding-bottom: 0.25em; +} + +dl.toc > dt +{ + padding-top: 0.25em; + padding-bottom: 0.25em; + font-weight: bold; +} + +dl.toc > dl +{ + padding-bottom: 0.5em; +} + +.parameter +{ + font-style: normal; +} + +.footer +{ + padding-top: 3.5em; + /* tango:aluminium 3 */ + color: #babdb6; + text-align: center; + font-size: 80%; +} + +.informalfigure, +.figure +{ + margin: 1em; +} + +.informalexample, +.example +{ + margin-top: 1em; + margin-bottom: 1em; +} + +.warning +{ + /* tango:orange 0/1 */ + background: #ffeed9; + background: rgba(252, 175, 62, 0.1); + border-color: #ffb04f; + border-color: rgba(252, 175, 62, 0.2); +} +.note +{ + /* tango:chameleon 0/0.5 */ + background: #d8ffb2; + background: rgba(138, 226, 52, 0.1); + border-color: #abf562; + border-color: rgba(138, 226, 52, 0.2); +} +div.blockquote +{ + border-color: #eeeeec; +} +.note, .warning, div.blockquote +{ + padding: 0.5em; + border-width: 1px; + border-style: solid; + margin: 2em; +} +.note p, .warning p +{ + margin: 0; +} + +div.warning h3.title, +div.note h3.title +{ + display: none; +} + +p + div.section +{ + margin-top: 1em; +} + +div.refnamediv, +div.refsynopsisdiv, +div.refsect1, +div.refsect2, +div.toc, +div.section +{ + margin-bottom: 1em; +} + +/* blob links */ +h2 .extralinks, h3 .extralinks +{ + float: right; + /* tango:aluminium 3 */ + color: #babdb6; + font-size: 80%; + font-weight: normal; +} + +.lineart +{ + color: #d3d7cf; + font-weight: normal; +} + +.annotation +{ + /* tango:aluminium 5 */ + color: #555753; + font-weight: normal; +} + +.structfield +{ + font-style: normal; + font-weight: normal; +} + +acronym,abbr +{ + border-bottom: 1px dotted gray; +} + +/* code listings */ + +.listing_code .programlisting .normal, +.listing_code .programlisting .normal a, +.listing_code .programlisting .number, +.listing_code .programlisting .cbracket, +.listing_code .programlisting .symbol { color: #555753; } +.listing_code .programlisting .comment, +.listing_code .programlisting .linenum { color: #babdb6; } /* tango: aluminium 3 */ +.listing_code .programlisting .function, +.listing_code .programlisting .function a, +.listing_code .programlisting .preproc { color: #204a87; } /* tango: sky blue 3 */ +.listing_code .programlisting .string { color: #ad7fa8; } /* tango: plum */ +.listing_code .programlisting .keyword, +.listing_code .programlisting .usertype, +.listing_code .programlisting .type, +.listing_code .programlisting .type a { color: #4e9a06; } /* tango: chameleon 3 */ + +.listing_frame { + /* tango:sky blue 1 */ + border: solid 1px #729fcf; + border: solid 1px rgba(114, 159, 207, 0.2); + padding: 0px; +} + +.listing_lines, .listing_code { + margin-top: 0px; + margin-bottom: 0px; + padding: 0.5em; +} +.listing_lines { + /* tango:sky blue 0.5 */ + background: #a6c5e3; + background: rgba(114, 159, 207, 0.2); + /* tango:aluminium 6 */ + color: #2e3436; +} +.listing_code { + /* tango:sky blue 0 */ + background: #e6f3ff; + background: rgba(114, 159, 207, 0.1); +} +.listing_code .programlisting { + /* override from previous */ + border: none 0px; + padding: 0px; + background: none; +} +.listing_lines pre, .listing_code pre { + margin: 0px; +} + +@media screen { + /* these have a as a first child, but since there are no parent selectors + * we can't use that. */ + a.footnote + { + position: relative; + top: 0em ! important; + } + /* this is needed so that the local anchors are displayed below the naviagtion */ + div.footnote a[name], div.refnamediv a[name], div.refsect1 a[name], div.refsect2 a[name], div.index a[name], div.glossary a[name], div.sect1 a[name] + { + display: inline-block; + position: relative; + top:-5em; + } + /* this seems to be a bug in the xsl style sheets when generating indexes */ + div.index div.index + { + top: 0em; + } + /* make space for the fixed navigation bar and add space at the bottom so that + * link targets appear somewhat close to top + */ + body + { + padding-top: 2.5em; + padding-bottom: 500px; + max-width: 60em; + } + p + { + max-width: 60em; + } + /* style and size the navigation bar */ + table.navigation#top + { + position: fixed; + background: #e2e2e2; + border-bottom: solid 1px #babdb6; + border-spacing: 5px; + margin-top: 0; + margin-bottom: 0; + top: 0; + left: 0; + z-index: 10; + } + table.navigation#top td + { + padding-left: 6px; + padding-right: 6px; + } + .navigation a, .navigation a:visited + { + /* tango:sky blue 3 */ + color: #204a87; + } + .navigation a:hover + { + /* tango:sky blue 2 */ + color: #3465a4; + } + td.shortcuts + { + /* tango:sky blue 2 */ + color: #3465a4; + font-size: 80%; + white-space: nowrap; + } + td.shortcuts .dim + { + color: #babdb6; + } + .navigation .title + { + font-size: 80%; + max-width: none; + margin: 0px; + font-weight: normal; + } +} +@media screen and (min-width: 60em) { + /* screen larger than 60em */ + body { margin: auto; } +} +@media screen and (max-width: 60em) { + /* screen less than 60em */ + #nav_hierarchy { display: none; } + #nav_interfaces { display: none; } + #nav_prerequisites { display: none; } + #nav_derived_interfaces { display: none; } + #nav_implementations { display: none; } + #nav_child_properties { display: none; } + #nav_style_properties { display: none; } + #nav_index { display: none; } + #nav_glossary { display: none; } + .gallery_image { display: none; } + .property_flags { display: none; } + .signal_flags { display: none; } + .parameter_annotations { display: none; } + .enum_member_annotations { display: none; } + .struct_member_annotations { display: none; } + .union_member_annotations { display: none; } + /* now that a column is hidden, optimize space */ + col.parameters_name { width: auto; } + col.parameters_description { width: auto; } + col.struct_members_name { width: auto; } + col.struct_members_description { width: auto; } + col.enum_members_name { width: auto; } + col.enum_members_description { width: auto; } + col.union_members_name { width: auto; } + col.union_members_description { width: auto; } + .listing_lines { display: none; } +} +@media print { + table.navigation { + visibility: collapse; + display: none; + } + div.titlepage table.navigation { + visibility: visible; + display: table; + background: #e2e2e2; + border: solid 1px #babdb6; + margin-top: 0; + margin-bottom: 0; + top: 0; + left: 0; + height: 3em; + } +} + diff --git a/docs/reference/up-insensitive.png b/docs/reference/up-insensitive.png new file mode 100644 index 0000000..674be9c Binary files /dev/null and b/docs/reference/up-insensitive.png differ diff --git a/docs/reference/up.png b/docs/reference/up.png new file mode 100644 index 0000000..ae83f66 Binary files /dev/null and b/docs/reference/up.png differ diff --git a/docs/xapp-docs.xml b/docs/xapp-docs.xml index 9df733c..87d0d87 100644 --- a/docs/xapp-docs.xml +++ b/docs/xapp-docs.xml @@ -23,6 +23,9 @@ + + + diff --git a/libxapp/XApp-1.0.metadata b/libxapp/XApp-1.0.metadata index 3854317..eedba24 100644 --- a/libxapp/XApp-1.0.metadata +++ b/libxapp/XApp-1.0.metadata @@ -1,4 +1,5 @@ GtkWindow cheader_filename="libxapp/xapp-gtk-window.h" MonitorBlanker cheader_filename="libxapp/xapp-monitor-blanker.h" KbdLayoutController cheader_filename="libxapp/xapp-kbd-layout-controller.h" +StatusIcon cheader_filename="libxapp/xapp-status-icon.h" XApp cheader_filename="libxapp/xapp-gtk-window.h"diff --git a/libxapp/g-codegen.py b/libxapp/g-codegen.py new file mode 100755 index 0000000..bf2ceb6 --- /dev/null +++ b/libxapp/g-codegen.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +''' +FIXME + +This script is used only to call gdbus-codegen and simulate the +generation of the source code and header as different targets. + +Both are generated implicitly, so meson is not able to know how +many files are generated, so it does generate only one opaque +target that represents the two files. + +originally from: +https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/5924d72931a030b24554116a48140a661a99652b + +Please see: + https://bugzilla.gnome.org/show_bug.cgi?id=791015 + https://github.com/mesonbuild/meson/pull/2930 +''' + +import subprocess +import sys +import os + +subprocess.call([ + 'gdbus-codegen', + '--interface-prefix=' + sys.argv[1], + '--generate-c-code=' + os.path.join(sys.argv[4], sys.argv[2]), + '--c-namespace=XApp', + '--annotate', sys.argv[1], 'org.gtk.GDBus.C.Name', sys.argv[3], + sys.argv[5] +]) diff --git a/libxapp/install_generated_header.py b/libxapp/install_generated_header.py new file mode 100644 index 0000000..d487ad9 --- /dev/null +++ b/libxapp/install_generated_header.py @@ -0,0 +1,12 @@ +#!/usr/bin/python3 + +import os +import sys +import subprocess + +install_dir = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], 'include', 'xapp', 'libxapp') +header_path = os.path.join(os.environ['MESON_BUILD_ROOT'], 'libxapp', sys.argv[1]) + +print("\nInstalling generated header '%s' to %s\n" % (sys.argv[1], install_dir)) + +subprocess.call(['cp', header_path, install_dir]) diff --git a/libxapp/meson.build b/libxapp/meson.build index 706a632..30156b0 100644 --- a/libxapp/meson.build +++ b/libxapp/meson.build @@ -17,6 +17,8 @@ 'xapp-monitor-blanker.h', 'xapp-preferences-window.h', 'xapp-stack-sidebar.h', + 'xapp-status-icon.h', + 'xapp-status-icon-monitor.h' ] xapp_sources = [ @@ -28,7 +30,42 @@ 'xapp-monitor-blanker.c', 'xapp-preferences-window.c', 'xapp-stack-sidebar.c', + 'xapp-status-icon.c', + 'xapp-status-icon-monitor.c' ] + +codegen = find_program('g-codegen.py') + +dbus_headers = [] + +# FIXME: Ugly workaround that simulates the generation of +# two different targets, so headers can be included +# explicitly for introspection. +# +# This can be removed once all platforms use meson >=.46 +# and replaced with gnome.gdbus_codegen +generated_sources = custom_target( + 'xapp-statusicon-interface', + input: 'org.x.StatusIcon.xml', + output: ['xapp-statusicon-interface.h', 'xapp-statusicon-interface.c'], + command: [ + codegen, + 'org.x.StatusIcon', + 'xapp-statusicon-interface', + 'StatusIconInterface', + meson.current_build_dir(), + '@INPUT@', '@OUTPUT@' + ] +) + +# You can't actually access the generated header udring the install_header command below, +# because the command is evaluated prior to the files being generated. So we need to manually +# install the dbus header file (custom install scripts really *do* get evaluated after build, +# during the install phase.) +meson.add_install_script('install_generated_header.py', 'xapp-statusicon-interface.h') + +dbus_headers += generated_sources[0] +xapp_sources += generated_sources[1] xapp_enums = gnome.mkenums('xapp-enums', sources : xapp_headers, @@ -39,12 +76,12 @@ ) libxapp = library('xapp', - sources : xapp_headers + xapp_sources + xapp_enums, + sources : xapp_headers + xapp_sources + xapp_enums + dbus_headers, include_directories: [top_inc], version: meson.project_version(), soversion: '1', dependencies: libdeps, - c_args: ['-Wno-declaration-after-statement'], + c_args: ['-Wno-declaration-after-statement', '-DG_LOG_DOMAIN="XApp"'], link_args: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', '-lm'], install: true ) @@ -57,13 +94,13 @@ link_with: libxapp, include_directories: top_inc, dependencies: libdeps, - sources: [ xapp_headers ] + sources: [ xapp_headers, dbus_headers ] ) gir = gnome.generate_gir(libxapp, namespace: 'XApp', nsversion: '1.0', - sources: xapp_headers + xapp_sources, + sources: xapp_headers + xapp_sources + dbus_headers, identifier_prefix: 'XApp', symbol_prefix: 'xapp_', includes: ['GObject-2.0', 'Gtk-3.0'], diff --git a/libxapp/org.x.StatusIcon.xml b/libxapp/org.x.StatusIcon.xml new file mode 100644 index 0000000..29360a9 --- /dev/null +++ b/libxapp/org.x.StatusIcon.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libxapp/xapp-enums.c.template b/libxapp/xapp-enums.c.template index d974436..6847490 100644 --- a/libxapp/xapp-enums.c.template +++ b/libxapp/xapp-enums.c.template @@ -3,6 +3,7 @@ #include "config.h" #include "xapp-enums.h" #include "xapp-icon-chooser-dialog.h" +#include "xapp-status-icon.h" #define C_ENUM(v) ((gint) v) #define C_FLAGS(v) ((guint) v) diff --git a/libxapp/xapp-icon-chooser-button.c b/libxapp/xapp-icon-chooser-button.c index c553829..a14f858 100644 --- a/libxapp/xapp-icon-chooser-button.c +++ b/libxapp/xapp-icon-chooser-button.c @@ -21,6 +21,7 @@ XAppIconChooserDialog *dialog; GtkIconSize icon_size; gchar *icon_string; + gchar *category_string; } XAppIconChooserButtonPrivate; struct _XAppIconChooserButton @@ -33,6 +34,7 @@ PROP_0, PROP_ICON_SIZE, PROP_ICON, + PROP_CATEGORY, N_PROPERTIES }; @@ -70,13 +72,17 @@ gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), GTK_WINDOW (toplevel)); gtk_window_set_modal (GTK_WINDOW (priv->dialog), gtk_window_get_modal (GTK_WINDOW (toplevel))); - if (priv->icon_string == NULL) + if (priv->category_string) + { + response = xapp_icon_chooser_dialog_run_with_category (priv->dialog, priv->category_string); + } + else if (priv->icon_string) + { + response = xapp_icon_chooser_dialog_run_with_icon (priv->dialog, priv->icon_string); + } + else { response = xapp_icon_chooser_dialog_run (priv->dialog); - } - else - { - response = xapp_icon_chooser_dialog_run_with_icon (priv->dialog, priv->icon_string); } if (response == GTK_RESPONSE_OK) @@ -108,6 +114,9 @@ case PROP_ICON: g_value_set_string (value, priv->icon_string); break; + case PROP_CATEGORY: + g_value_set_string (value, priv->category_string); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -121,10 +130,8 @@ GParamSpec *pspec) { XAppIconChooserButton *button; - XAppIconChooserButtonPrivate *priv; button = XAPP_ICON_CHOOSER_BUTTON (object); - priv = xapp_icon_chooser_button_get_instance_private (button); switch (prop_id) { @@ -134,10 +141,28 @@ case PROP_ICON: xapp_icon_chooser_button_set_icon (button, g_value_get_string (value)); break; + case PROP_CATEGORY: + xapp_icon_chooser_button_set_default_category (button, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } +} + +void +xapp_icon_chooser_button_dispose (GObject *object) +{ + XAppIconChooserButtonPrivate *priv; + + priv = xapp_icon_chooser_button_get_instance_private (XAPP_ICON_CHOOSER_BUTTON (object)); + + g_clear_pointer (&priv->icon_string, g_free); + g_clear_pointer (&priv->category_string, g_free); + + g_clear_object (&priv->dialog); + + G_OBJECT_CLASS (xapp_icon_chooser_button_parent_class)->dispose (object); } static void @@ -163,12 +188,12 @@ static void xapp_icon_chooser_button_class_init (XAppIconChooserButtonClass *klass) { - GtkBindingSet *binding_set; GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass); object_class->get_property = xapp_icon_chooser_button_get_property; object_class->set_property = xapp_icon_chooser_button_set_property; + object_class->dispose = xapp_icon_chooser_button_dispose; button_class->clicked = on_clicked; @@ -199,6 +224,18 @@ "", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); + /** + * XAppIconChooserButton:category: + * + * The category selected by default. + */ + obj_properties[PROP_CATEGORY] = + g_param_spec_string ("category", + _("Category"), + _("The default category."), + "", + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); + g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties); } @@ -347,6 +384,29 @@ } /** + * xapp_icon_chooser_button_set_default_category: + * @button: a #XAppIconChooserButton + * @category: (nullable): a string representing the category selected by default. + * + * Sets the icon on the #XAppIconChooserButton. + */ +void +xapp_icon_chooser_button_set_default_category (XAppIconChooserButton *button, + const gchar *category) +{ + XAppIconChooserButtonPrivate *priv; + + priv = xapp_icon_chooser_button_get_instance_private (button); + + if (priv->category_string != NULL) + { + g_free (priv->category_string); + } + + priv->category_string = g_strdup (category); +} + +/** * xapp_icon_chooser_button_get_dialog: * @button: a #XAppIconChooserButton * diff --git a/libxapp/xapp-icon-chooser-button.h b/libxapp/xapp-icon-chooser-button.h index 3d8dfcc..418bf32 100644 --- a/libxapp/xapp-icon-chooser-button.h +++ b/libxapp/xapp-icon-chooser-button.h @@ -22,6 +22,9 @@ void xapp_icon_chooser_button_set_icon (XAppIconChooserButton *button, const gchar *icon); +void xapp_icon_chooser_button_set_default_category (XAppIconChooserButton *button, + const gchar *category); + const gchar* xapp_icon_chooser_button_get_icon (XAppIconChooserButton *button); XAppIconChooserDialog * xapp_icon_chooser_button_get_dialog (XAppIconChooserButton *button); diff --git a/libxapp/xapp-icon-chooser-dialog.c b/libxapp/xapp-icon-chooser-dialog.c index 5ec29ee..ab7ac95 100644 --- a/libxapp/xapp-icon-chooser-dialog.c +++ b/libxapp/xapp-icon-chooser-dialog.c @@ -33,7 +33,6 @@ { GtkResponseType response; XAppIconSize icon_size; - GtkListStore *category_list; GtkListStore *search_icon_store; GFileEnumerator *search_file_enumerator; GCancellable *cancellable; @@ -44,6 +43,7 @@ GtkWidget *search_bar; GtkWidget *icon_view; GtkWidget *list_box; + GtkWidget *default_button; GtkWidget *select_button; GtkWidget *browse_button; GtkWidget *action_area; @@ -52,6 +52,7 @@ gchar *current_text; gulong search_changed_id; gboolean allow_paths; + gchar *default_icon; IconCategoryInfo *current_category; } XAppIconChooserDialogPrivate; @@ -134,6 +135,7 @@ PROP_0, PROP_ICON_SIZE, PROP_ALLOW_PATHS, + PROP_DEFAULT_ICON, N_PROPERTIES }; @@ -173,15 +175,15 @@ static void on_cancel_button_clicked (GtkButton *button, gpointer user_data); +static gboolean on_default_button_clicked (GtkButton *button, + gpointer user_data); + static gboolean on_search_bar_key_pressed (GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean on_delete_event (GtkWidget *widget, GdkEventAny *event); - -static gboolean on_select_event (XAppIconChooserDialog *dialog, - GdkEventAny *event); static void on_icon_view_item_activated (GtkIconView *iconview, GtkTreePath *path, @@ -315,6 +317,9 @@ break; case PROP_ALLOW_PATHS: g_value_set_boolean (value, priv->allow_paths); + break; + case PROP_DEFAULT_ICON: + g_value_set_string (value, xapp_icon_chooser_dialog_get_default_icon(dialog)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -352,6 +357,9 @@ gtk_widget_set_no_show_all (priv->browse_button, TRUE); } break; + case PROP_DEFAULT_ICON: + xapp_icon_chooser_dialog_set_default_icon (dialog, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -380,6 +388,7 @@ } g_clear_pointer (&priv->icon_string, g_free); + g_clear_pointer (&priv->default_icon, g_free); g_clear_pointer (&priv->current_text, g_free); g_clear_object (&priv->cancellable); @@ -400,13 +409,10 @@ GtkToolItem *tool_item; GtkWidget *toolbar_box; GtkWidget *right_box; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; GtkStyleContext *style; GtkSizeGroup *button_size_group; GtkWidget *cancel_button; GtkWidget *button_area; - GtkWidget *selection; GtkWidget *scrolled_window; priv = xapp_icon_chooser_dialog_get_instance_private (dialog); @@ -550,6 +556,16 @@ gtk_box_pack_start (GTK_BOX (main_box), button_area, FALSE, FALSE, 0); button_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + + priv->default_button = gtk_button_new_with_label (_("Default")); + gtk_widget_set_no_show_all (priv->default_button, TRUE); + style = gtk_widget_get_style_context (GTK_WIDGET (priv->default_button)); + gtk_style_context_add_class (style, "text-button"); + gtk_size_group_add_widget (button_size_group, priv->default_button); + gtk_action_bar_pack_start (GTK_ACTION_BAR (button_area), priv->default_button); + + g_signal_connect (priv->default_button, "clicked", + G_CALLBACK (on_default_button_clicked), dialog); priv->select_button = gtk_button_new_with_label (_("Select")); style = gtk_widget_get_style_context (GTK_WIDGET (priv->select_button)); @@ -611,6 +627,18 @@ _("Whether to allow paths."), TRUE, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); + + /** + * XAppIconChooserDialog:default-icon: + * + * The icon to use by default. + */ + obj_properties[PROP_DEFAULT_ICON] = + g_param_spec_string ("default-icon", + _("Default Icon"), + _("The icon to use by default"), + NULL, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties); @@ -767,6 +795,91 @@ } /** + * xapp_icon_chooser_dialog_get_default_icon: + * + * Returns the default icon (if set). + * + * Returns: (transfer full): the default icon, or NULL if none is set + */ +gchar * +xapp_icon_chooser_dialog_get_default_icon (XAppIconChooserDialog *dialog) +{ + XAppIconChooserDialogPrivate *priv; + + priv = xapp_icon_chooser_dialog_get_instance_private (dialog); + + return g_strdup(priv->default_icon); +} + +/** + * xapp_icon_chooser_dialog_set_default_icon: + * @icon: the default icon, or NULL to unset + * + * Sets the default icon. If @icon is not NULL, a button will be shown that + * will reset the dialog to it's default value. + */ +void +xapp_icon_chooser_dialog_set_default_icon (XAppIconChooserDialog *dialog, + const gchar *icon) +{ + XAppIconChooserDialogPrivate *priv; + + priv = xapp_icon_chooser_dialog_get_instance_private (dialog); + + priv->default_icon = g_strdup (icon); + if (icon == NULL) + { + gtk_widget_hide (priv->default_button); + } + else + { + gtk_widget_show (priv->default_button); + } +} + +/** + * xapp_icon_chooser_dialog_add_custom_category: + * @dialog: a #XAppIconChooserDialog + * @name: the name of the category as it will be displayed in the category list + * @icons: (transfer full) (element-type utf8): a list of icon names to add to the new category + * + * Adds a custom category to the dialog. + */ +void +xapp_icon_chooser_dialog_add_custom_category (XAppIconChooserDialog *dialog, + const gchar *name, + GList *icons) +{ + XAppIconChooserDialogPrivate *priv; + IconCategoryInfo *category_info; + GtkWidget *row; + GtkWidget *label; + + priv = xapp_icon_chooser_dialog_get_instance_private (dialog); + + category_info = g_new0 (IconCategoryInfo, 1); + category_info->name = name; + category_info->icons = icons; + + category_info->model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF); + g_signal_connect (category_info->model, "row-inserted", + G_CALLBACK (on_icon_store_icons_added), dialog); + + category_info->icons = g_list_sort (category_info->icons, (GCompareFunc) g_utf8_collate); + + row = gtk_list_box_row_new (); + label = gtk_label_new (category_info->name); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + gtk_widget_set_margin_start (GTK_WIDGET (label), 6); + gtk_widget_set_margin_end (GTK_WIDGET (label), 6); + + gtk_container_add (GTK_CONTAINER (row), label); + gtk_container_add (GTK_CONTAINER (priv->list_box), row); + + g_hash_table_insert (priv->categories, row, category_info); +} + +/** * xapp_icon_chooser_dialog_get_icon_string: * @dialog: a #XAppIconChooserDialog * @@ -829,7 +942,6 @@ GtkResponseType response_id) { XAppIconChooserDialogPrivate *priv; - GtkWidget *action_area; priv = xapp_icon_chooser_dialog_get_instance_private (dialog); @@ -1071,7 +1183,7 @@ callback_info = (FileIconInfoLoadCallbackInfo*) user_data; priv = xapp_icon_chooser_dialog_get_instance_private (callback_info->dialog); - + if (g_cancellable_is_cancelled (callback_info->cancellable)) { free_file_info (callback_info); @@ -1096,7 +1208,7 @@ callback_info = (NamedIconInfoLoadCallbackInfo*) user_data; priv = xapp_icon_chooser_dialog_get_instance_private (callback_info->dialog); - + if (g_cancellable_is_cancelled (callback_info->cancellable)) { free_named_info (callback_info); @@ -1128,7 +1240,7 @@ return G_SOURCE_REMOVE; } - + search_icon_name (callback_info->dialog, priv->current_text, priv->search_icon_store); @@ -1147,7 +1259,6 @@ FileIconInfoLoadCallbackInfo *callback_info; GdkPixbuf *pixbuf, *final_pixbuf; GError *error = NULL; - GtkTreeIter iter; callback_info = (FileIconInfoLoadCallbackInfo *) user_data; priv = xapp_icon_chooser_dialog_get_instance_private (callback_info->dialog); @@ -1277,7 +1388,7 @@ callback_info = (NamedIconInfoLoadCallbackInfo*) user_data; priv = xapp_icon_chooser_dialog_get_instance_private (callback_info->dialog); - pixbuf = gtk_icon_info_load_icon_finish (GTK_ICON_INFO (info), res, &error); + pixbuf = gtk_icon_info_load_symbolic_for_context_finish (GTK_ICON_INFO (info), res, NULL, &error); g_object_unref (info); if (g_cancellable_is_cancelled (callback_info->cancellable)) @@ -1348,9 +1459,12 @@ XAppIconChooserDialogPrivate *priv; GtkIconTheme *theme; gint chunk_count; + gint scale; priv = xapp_icon_chooser_dialog_get_instance_private (dialog); theme = gtk_icon_theme_get_default (); + + scale = gtk_widget_get_scale_factor (GTK_WIDGET (dialog)); for (chunk_count = 0; chunk_count < CATEGORY_CHUNK_SIZE; chunk_count++) { @@ -1386,10 +1500,20 @@ } else { - GtkIconInfo *info; - - info = gtk_icon_theme_lookup_icon (theme, name, icon_size, GTK_ICON_LOOKUP_FORCE_SIZE); - gtk_icon_info_load_icon_async (info, NULL, (GAsyncReadyCallback) (finish_pixbuf_load_from_name), callback_info); + GtkIconInfo *info; + GtkStyleContext *context; + + info = gtk_icon_theme_lookup_icon_for_scale (theme, name, icon_size, scale, GTK_ICON_LOOKUP_FORCE_SIZE); + if (info == NULL) + { + // this shouldn't be the case most of the time, but if a custom category is defined it's possible + // the icon doesn't exist. In that case it's best to just skip over it since trying to load it will + // lead to a segfault. + continue; + } + + context = gtk_widget_get_style_context (priv->icon_view); + gtk_icon_info_load_symbolic_for_context_async (info, context, NULL, (GAsyncReadyCallback) (finish_pixbuf_load_from_name), callback_info); } } else @@ -1408,7 +1532,6 @@ GList *selection; GtkWidget *selected; IconCategoryInfo *category_info; - GtkTreePath *new_path; priv = xapp_icon_chooser_dialog_get_instance_private (dialog); @@ -1604,13 +1727,13 @@ XAppIconChooserDialogPrivate *priv; GtkIconTheme *theme; GList *icons; - GtkIconInfo *info; - NamedIconInfoLoadCallbackInfo *callback_info; gint chunk_count; + gint scale; priv = xapp_icon_chooser_dialog_get_instance_private (dialog); theme = gtk_icon_theme_get_default (); + scale = gtk_widget_get_scale_factor (GTK_WIDGET (dialog)); icons = priv->full_icon_list; @@ -1654,12 +1777,14 @@ } else { - GtkIconInfo *info; - - info = gtk_icon_theme_lookup_icon (theme, name, priv->icon_size, GTK_ICON_LOOKUP_FORCE_SIZE); - gtk_icon_info_load_icon_async (info, NULL, (GAsyncReadyCallback) (finish_pixbuf_load_from_name), callback_info); + GtkIconInfo *info; + GtkStyleContext *context; + + info = gtk_icon_theme_lookup_icon_for_scale (theme, name, priv->icon_size, scale, GTK_ICON_LOOKUP_FORCE_SIZE); + context = gtk_widget_get_style_context (priv->icon_view); + gtk_icon_info_load_symbolic_for_context_async (info, context, NULL, (GAsyncReadyCallback) (finish_pixbuf_load_from_name), callback_info); } - + chunk_count++; } } @@ -1864,20 +1989,6 @@ xapp_icon_chooser_dialog_close (XAPP_ICON_CHOOSER_DIALOG (widget), GTK_RESPONSE_CANCEL); return TRUE; -} - -static gboolean -on_select_event (XAppIconChooserDialog *dialog, - GdkEventAny *event) -{ - XAppIconChooserDialogPrivate *priv; - - priv = xapp_icon_chooser_dialog_get_instance_private (dialog); - - if (priv->icon_string != NULL) - { - xapp_icon_chooser_dialog_close (dialog, GTK_RESPONSE_OK); - } } static void @@ -1915,3 +2026,15 @@ return FALSE; } + +static gboolean +on_default_button_clicked (GtkButton *button, + gpointer user_data) +{ + XAppIconChooserDialogPrivate *priv; + + priv = xapp_icon_chooser_dialog_get_instance_private (user_data); + + gtk_entry_set_text (GTK_ENTRY (priv->search_bar), priv->default_icon); + +} diff --git a/libxapp/xapp-icon-chooser-dialog.h b/libxapp/xapp-icon-chooser-dialog.h index 86df393..439039b 100644 --- a/libxapp/xapp-icon-chooser-dialog.h +++ b/libxapp/xapp-icon-chooser-dialog.h @@ -38,6 +38,15 @@ GtkWidget *button, GtkPackType packing, GtkResponseType response_id); + +gchar * xapp_icon_chooser_dialog_get_default_icon (XAppIconChooserDialog *dialog); +void xapp_icon_chooser_dialog_set_default_icon (XAppIconChooserDialog *dialog, + const gchar *icon); + +void xapp_icon_chooser_dialog_add_custom_category (XAppIconChooserDialog *dialog, + const gchar *name, + GList *icons); + G_END_DECLS #endif /* _XAPP_ICON_CHOOSER_DIALOG_H_ */ diff --git a/libxapp/xapp-stack-sidebar.c b/libxapp/xapp-stack-sidebar.c index 9aef46e..e7463a9 100644 --- a/libxapp/xapp-stack-sidebar.c +++ b/libxapp/xapp-stack-sidebar.c @@ -54,8 +54,6 @@ const GValue *value, GParamSpec *pspec) { - XAppStackSidebar *sidebar = XAPP_STACK_SIDEBAR (object); - switch (prop_id) { case PROP_STACK: diff --git a/libxapp/xapp-status-icon-monitor.c b/libxapp/xapp-status-icon-monitor.c new file mode 100644 index 0000000..396ed0c --- /dev/null +++ b/libxapp/xapp-status-icon-monitor.c @@ -0,0 +1,545 @@ + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include "xapp-status-icon.h" +#include "xapp-status-icon-monitor.h" +#include "xapp-statusicon-interface.h" + +#define MONITOR_PATH "/org/x/StatusIconMonitor" +#define MONITOR_NAME "org.x.StatusIconMonitor" + +#define STATUS_ICON_MATCH "org.x.StatusIcon." + +#define STATUS_ICON_ID_FORMAT "org.x.StatusIcon.PID-%d-%d" +#define STATUS_ICON_PATH_PREFIX "/org/x/StatusIcon/" + +enum +{ + ICON_ADDED, + ICON_REMOVED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0, }; + +/** + * SECTION:xapp-status-icon-monitor + * @Short_description: Looks for XAppStatusIcons on DBUS and communicates + * info to an applet to represent the icons. + * @Title: XAppStatusIconMonitor + * + * The XAppStatusIconMonitor is intended to be utilized by some status applet + * to display info about an app. + * + * The simplest way to use is to make a new instance of this monitor, and connect + * to the #XAppStatusIconMonitor::icon-added and #XAppStatusIconMonitor::icon-removed signals. + * The received object for both of these signals is an #XAppStatusIconInterfaceProxy. + * It represents an application's #XAppStatusIcon, and has properties available for + * describing the icon name, tooltip, label and visibility. + * + * The proxy also provides methods to handle clicks, which can be called by the applet, + * to request that the app display its menu. + */ +typedef struct +{ + GDBusConnection *connection; + + GHashTable *icons; + gchar *name; + + guint owner_id; + guint listener_id; + +} XAppStatusIconMonitorPrivate; + +struct _XAppStatusIconMonitor +{ + GObject parent_instance; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (XAppStatusIconMonitor, xapp_status_icon_monitor, G_TYPE_OBJECT) + +static void remove_icon (XAppStatusIconMonitor *self, const gchar *name); + +static void +on_proxy_name_owner_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + + gchar *name_owner = NULL; + gchar *proxy_name = NULL; + + g_object_get (object, + "g-name-owner", &name_owner, + "g-name", &proxy_name, + NULL); + + g_debug("XAppStatusIconMonitor: proxy name owner changed - name owner '%s' is now '%s')", proxy_name, name_owner); + + if (name_owner == NULL) + { + remove_icon (self, proxy_name); + } + + g_free (name_owner); + g_free (proxy_name); +} + +static void +remove_icon (XAppStatusIconMonitor *self, + const gchar *name) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + XAppStatusIconInterface *proxy; + + proxy = g_hash_table_lookup (priv->icons, name); + + if (proxy) + { + g_object_ref (proxy); + + g_signal_handlers_disconnect_by_func (proxy, + on_proxy_name_owner_changed, + self); + + if (g_hash_table_remove (priv->icons, name)) + { + g_debug("XAppStatusIconMonitor: removing icon: '%s'", name); + + g_signal_emit (self, signals[ICON_REMOVED], 0, proxy); + } + else + { + g_assert_not_reached (); + } + + g_object_unref (proxy); + } +} + +static void +new_status_icon_proxy_complete (GObject *object, + GAsyncResult *res, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + XAppStatusIconInterface *proxy; + GError *error; + gchar *g_name; + + error = NULL; + + proxy = xapp_status_icon_interface_proxy_new_finish (res, + &error); + + if (error) + { + g_warning ("Couldn't add status icon: %s", error->message); + g_error_free (error); + return; + } + + g_signal_connect_object (proxy, + "notify::g-name-owner", + G_CALLBACK (on_proxy_name_owner_changed), + self, + 0); + + g_object_get (proxy, "g-name", &g_name, NULL); + + g_hash_table_insert (priv->icons, + g_name, + proxy); + + g_signal_emit (self, signals[ICON_ADDED], 0, proxy); +} + +static void +add_icon (XAppStatusIconMonitor *self, + const gchar *name) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + gchar *unique_path; + gint pid, id; + + if (sscanf (name, STATUS_ICON_ID_FORMAT, &pid, &id) == 2) + { + unique_path = g_strdup_printf (STATUS_ICON_PATH_PREFIX "%d", id); + + g_debug("XAppStatusIconMonitor: adding icon: '%s' with path '%s'", name, unique_path); + + xapp_status_icon_interface_proxy_new (priv->connection, + G_DBUS_PROXY_FLAGS_NONE, + name, + unique_path, + NULL, + new_status_icon_proxy_complete, + self); + + g_free (unique_path); + } + else + { + g_debug ("XAppStatusIconMonitor: adding icon failed, name '%s' is invalid", name); + } +} + +static void +on_list_names_completed (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + GVariant *result; + GVariantIter *iter; + gchar *str; + GError *error; + + error = NULL; + + result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), + res, + &error); + + if (error != NULL) + { + g_critical ("XAppStatusIconMonitor: attempt to ListNames failed: %s\n", error->message); + g_error_free (error); + return; + } + + g_variant_get (result, "(as)", &iter); + + while (g_variant_iter_loop (iter, "s", &str)) + { + /* the '.' at the end so we don't catch ourselves in this */ + if (g_str_has_prefix (str, STATUS_ICON_MATCH)) + { + g_debug ("XAppStatusIconMonitor: found icon: %s", str); + add_icon (self, str); + } + } + + g_variant_iter_free (iter); + g_variant_unref (result); +} + +static void +find_and_add_icons (XAppStatusIconMonitor *self) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + + g_debug("XAppStatusIconMonitor: looking for status icons on the bus"); + + /* If there are no monitors (applets) already running when this is set up, + * this won't find anything. The XAppStatusIcons will be in fallback mode, + * and will only attempt to switch back after seeing this monitor appear + * on the bus, which means they'll show up via our NameOwnerChanged handler. + * Basically, this will never find anything if we're the first monitor to appear + * on the bus. + */ + + g_dbus_connection_call (priv->connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "ListNames", + NULL, + G_VARIANT_TYPE ("(as)"), + G_DBUS_CALL_FLAGS_NONE, + 3000, /* 3 secs */ + NULL, + on_list_names_completed, + self); +} + +static void +status_icon_name_appeared (XAppStatusIconMonitor *self, + const gchar *name, + const gchar *owner) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + if (!g_str_has_prefix (name, STATUS_ICON_MATCH)) + { + return; + } + + if (g_hash_table_contains (priv->icons, name)) + { + return; + } + + g_debug ("XAppStatusIconMonitor: new icon appeared: %s", name); + + add_icon (self, name); +} + +static void +status_icon_name_vanished (XAppStatusIconMonitor *self, + const gchar *name) +{ + if (!g_str_has_prefix (name, STATUS_ICON_MATCH)) + { + return; + } + + g_debug ("XAppStatusIconMonitor: icon presence vanished: %s", name); + + remove_icon (self, name); +} + +static void +name_owner_changed (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + + const gchar *name; + const gchar *old_owner; + const gchar *new_owner; + + g_debug("XAppStatusIconMonitor: NameOwnerChanged signal received: %s)", sender_name); + + g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); + + if (old_owner[0] != '\0') + { + status_icon_name_vanished (self, name); + } + + if (new_owner[0] != '\0') + { + status_icon_name_appeared (self, name, new_owner); + } +} + + +static void +add_name_listener (XAppStatusIconMonitor *self) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + g_debug ("XAppStatusIconMonitor: Adding NameOwnerChanged listener for status icons"); + + priv->listener_id = g_dbus_connection_signal_subscribe (priv->connection, + "org.freedesktop.DBus", + "org.freedesktop.DBus", + "NameOwnerChanged", + "/org/freedesktop/DBus", + "org.x.StatusIcon", + G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE, + name_owner_changed, + self, + NULL); +} + +static void +on_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + if (connection == NULL) + { + g_warning ("error acquiring session bus"); + } +} + +static void +on_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + + g_debug ("XAppStatusIconMonitor: name acquired on dbus"); + + add_name_listener (self); + find_and_add_icons (self); +} + +static void +on_bus_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + g_debug ("XAppStatusIconMonitor: session bus connection acquired"); + + priv->connection = connection; +} + +static void +connect_to_bus (XAppStatusIconMonitor *self) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + static gint unique_id = 0; + + char *owner_name = g_strdup_printf("%s.PID-%d-%d", MONITOR_NAME, getpid (), unique_id); + + unique_id++; + + g_debug ("XAppStatusIconMonitor: Attempting to acquire presence on dbus as %s", owner_name); + + priv->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, + owner_name, + G_DBUS_CONNECTION_FLAGS_NONE, + on_bus_acquired, + on_name_acquired, + on_name_lost, + self, + NULL); + + g_free(owner_name); +} + +static void +xapp_status_icon_monitor_init (XAppStatusIconMonitor *self) +{ + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + priv->name = g_strdup_printf("%s", g_get_application_name()); + + priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, g_object_unref); + + connect_to_bus (self); +} + +static void +xapp_status_icon_monitor_dispose (GObject *object) +{ + XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (object); + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); + + g_debug ("XAppStatusIconMonitor dispose (%p)", object); + + if (priv->connection != NULL) + { + if (priv->listener_id > 0) + { + g_dbus_connection_signal_unsubscribe (priv->connection, priv->listener_id); + } + + if (priv->owner_id > 0) + { + g_bus_unown_name(priv->owner_id); + } + + g_clear_object (&priv->connection); + } + + g_free (priv->name); + g_clear_pointer (&priv->icons, g_hash_table_unref); + + G_OBJECT_CLASS (xapp_status_icon_monitor_parent_class)->dispose (object); +} + +static void +xapp_status_icon_monitor_finalize (GObject *object) +{ + g_debug ("XAppStatusIconMonitor finalize (%p)", object); + + G_OBJECT_CLASS (xapp_status_icon_monitor_parent_class)->dispose (object); +} + +static void +xapp_status_icon_monitor_class_init (XAppStatusIconMonitorClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->dispose = xapp_status_icon_monitor_dispose; + gobject_class->finalize = xapp_status_icon_monitor_finalize; + + /** + * XAppStatusIconMonitor::icon-added: + * @monitor: the #XAppStatusIconMonitor + * @proxy: the interface proxy for the #XAppStatusIcon that has been added. + * + * This signal is emitted by the monitor when it has discovered a new + * #XAppStatusIcon on the bus. + */ + signals[ICON_ADDED] = + g_signal_new ("icon-added", + XAPP_TYPE_STATUS_ICON_MONITOR, + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, XAPP_TYPE_STATUS_ICON_INTERFACE_PROXY); + + /** + * XAppStatusIconMonitor::icon-removed: + * @monitor: the #XAppStatusIconMonitor + * @proxy: the #XAppStatusIcon proxy that has been removed. + * + * This signal is emitted by the monitor when an #XAppStatusIcon has disappeared + * from the bus. + */ + signals[ICON_REMOVED] = + g_signal_new ("icon-removed", + XAPP_TYPE_STATUS_ICON_MONITOR, + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, XAPP_TYPE_STATUS_ICON_INTERFACE_PROXY); +} + +/** + * xapp_status_icon_monitor_list_icons: + * @monitor: a #XAppStatusIconMonitor + * + * List known icon proxies. + * + * Returns: (element-type XAppStatusIconMonitor) (transfer container): a #GList of icons + * + * Since: 1.6 + */ +GList * +xapp_status_icon_monitor_list_icons (XAppStatusIconMonitor *monitor) +{ + g_return_val_if_fail (XAPP_IS_STATUS_ICON_MONITOR (monitor), NULL); + + XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (monitor); + + return g_hash_table_get_values (priv->icons); +} + +/** + * xapp_status_icon_monitor_new: + * + * Creates a new monitor. + * + * Returns: (transfer full): a new #XAppStatusIconMonitor. Use g_object_unref when finished. + * + * Since: 1.6 + */ +XAppStatusIconMonitor * +xapp_status_icon_monitor_new (void) +{ + return g_object_new (XAPP_TYPE_STATUS_ICON_MONITOR, NULL); +} + diff --git a/libxapp/xapp-status-icon-monitor.h b/libxapp/xapp-status-icon-monitor.h new file mode 100644 index 0000000..1a8c38e --- /dev/null +++ b/libxapp/xapp-status-icon-monitor.h @@ -0,0 +1,20 @@ +#ifndef __XAPP_STATUS_ICON_MONITOR_H__ +#define __XAPP_STATUS_ICON_MONITOR_H__ + +#include +#include + +#include + +G_BEGIN_DECLS + +#define XAPP_TYPE_STATUS_ICON_MONITOR (xapp_status_icon_monitor_get_type ()) + +G_DECLARE_FINAL_TYPE (XAppStatusIconMonitor, xapp_status_icon_monitor, XAPP, STATUS_ICON_MONITOR, GObject) + +XAppStatusIconMonitor *xapp_status_icon_monitor_new (void); +GList *xapp_status_icon_monitor_list_icons (XAppStatusIconMonitor *monitor); + +G_END_DECLS + +#endif /* __XAPP_STATUS_ICON_MONITOR_H__ */ diff --git a/libxapp/xapp-status-icon.c b/libxapp/xapp-status-icon.c new file mode 100644 index 0000000..eff3743 --- /dev/null +++ b/libxapp/xapp-status-icon.c @@ -0,0 +1,1598 @@ + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include "xapp-status-icon.h" +#include "xapp-statusicon-interface.h" +#include "xapp-enums.h" + +#define FDO_DBUS_NAME "org.freedesktop.DBus" +#define FDO_DBUS_PATH "/org/freedesktop/DBus" + +#define ICON_PATH "/org/x/StatusIcon" +#define ICON_NAME "org.x.StatusIcon" + +#define STATUS_ICON_MONITOR_MATCH "org.x.StatusIconMonitor" + +#define MAX_NAME_FAILS 3 + +static gint unique_id = 0; + +enum +{ + BUTTON_PRESS, + BUTTON_RELEASE, + ACTIVATE, + STATE_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0, }; + +enum +{ + PROP_0, + PROP_PRIMARY_MENU, + PROP_SECONDARY_MENU, + N_PROPERTIES +}; + +/** + * SECTION:xapp-status-icon + * @Short_description: Broadcasts status information over DBUS + * @Title: XAppStatusIcon + * + * The XAppStatusIcon allows applications to share status info + * about themselves. It replaces the obsolete and very similar + * Gtk.StatusIcon widget. + * + * If used in an environment where no applet is handling XAppStatusIcons, + * the XAppStatusIcon delegates its calls to a Gtk.StatusIcon. + */ +typedef struct +{ + XAppStatusIconInterface *skeleton; + GDBusConnection *connection; + + GCancellable *cancellable; + + GtkStatusIcon *gtk_status_icon; + GtkWidget *primary_menu; + GtkWidget *secondary_menu; + + XAppStatusIconState state; + + gchar *name; + gchar *icon_name; + gchar *tooltip_text; + gchar *label; + gboolean visible; + + guint owner_id; + guint listener_id; + + gint fail_counter; + gboolean have_button_press; +} XAppStatusIconPrivate; + +struct _XAppStatusIcon +{ + GObject parent_instance; + XAppStatusIconPrivate *priv; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (XAppStatusIcon, xapp_status_icon, G_TYPE_OBJECT) + +static void refresh_icon (XAppStatusIcon *self); +static void use_gtk_status_icon (XAppStatusIcon *self); +static void tear_down_dbus (XAppStatusIcon *self); + +static void +cancellable_reset (XAppStatusIcon *self) +{ + if (self->priv->cancellable) + { + g_cancellable_cancel (self->priv->cancellable); + g_object_unref (self->priv->cancellable); + } + + self->priv->cancellable = g_cancellable_new (); +} + +static const gchar * +panel_position_to_str (GtkPositionType type) +{ + switch (type) + { + case GTK_POS_LEFT: + return "Left"; + case GTK_POS_RIGHT: + return "Right"; + case GTK_POS_TOP: + return "Top"; + case GTK_POS_BOTTOM: + default: + return "Bottom"; + } +} + +static const gchar * +button_to_str (guint button) +{ + switch (button) + { + case GDK_BUTTON_PRIMARY: + return "Left"; + case GDK_BUTTON_SECONDARY: + return "Right"; + case GDK_BUTTON_MIDDLE: + return "Middle"; + default: + return "Unknown"; + } +} + +static const gchar * +state_to_str (XAppStatusIconState state) +{ + switch (state) + { + case XAPP_STATUS_ICON_STATE_NATIVE: + return "Native"; + case XAPP_STATUS_ICON_STATE_FALLBACK: + return "Fallback"; + case XAPP_STATUS_ICON_STATE_NO_SUPPORT: + return "NoSupport"; + default: + return "Unknown"; + } +} + +typedef struct { + gint x; + gint y; + gint position; + guint32 t; +} PositionData; + +static void +position_menu_cb (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + gpointer user_data) +{ + GtkAllocation alloc; + PositionData *position_data = (PositionData *) user_data; + + *x = position_data->x; + *y = position_data->y; + + gtk_widget_get_allocation (GTK_WIDGET (menu), &alloc); + + switch (position_data->position) { + case GTK_POS_BOTTOM: + *y = *y - alloc.height; + break; + case GTK_POS_RIGHT: + *x = *x - alloc.width; + break; + } + + *push_in = TRUE; +} + +static void +popup_native_icon_menu (XAppStatusIcon *self, + GtkMenu *menu, + gint x, + gint y, + guint button, + guint _time, + gint panel_position) +{ + GdkDisplay *display; + GdkDevice *pointer; + + g_debug ("XAppStatusIcon: Popup menu on behalf of application"); + + PositionData position_data = { + x, y, panel_position, _time + }; + + display = gdk_display_get_default (); + pointer = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display)); + + gtk_menu_popup_for_device (menu, + pointer, + NULL, + NULL, + position_menu_cb, + &position_data, + NULL, + button, + _time); +} + +static gboolean +should_send_activate (XAppStatusIcon *icon, + guint button) +{ + gboolean do_activate = TRUE; + + switch (button) + { + case GDK_BUTTON_PRIMARY: + if (icon->priv->primary_menu) + { + do_activate = FALSE; + } + break; + case GDK_BUTTON_SECONDARY: + if (icon->priv->secondary_menu) + { + do_activate = FALSE; + } + break; + default: + break; + } + + return do_activate; +} + +static gboolean +handle_appindicator_button_press (XAppStatusIcon *icon, + guint button, + guint _time) +{ + if (g_object_get_data (G_OBJECT (icon), "app-indicator")) + { + if (button == GDK_BUTTON_MIDDLE) + { + g_debug ("XAppStatusIcon: sending activate for middle-click event (libappindicator)"); + + g_signal_emit (icon, signals[ACTIVATE], 0, + button, + _time); + } + else + { + g_debug ("XAppStatusIcon: GtkStatusIcon (app-indicator) ignoring %s button press.", button_to_str (button)); + } + + return TRUE; + } + + return FALSE; +} + +static GtkWidget * +get_menu_to_use (XAppStatusIcon *icon, + guint button) +{ + GtkWidget *menu_to_use = NULL; + + switch (button) + { + case GDK_BUTTON_PRIMARY: + menu_to_use = icon->priv->primary_menu; + break; + case GDK_BUTTON_SECONDARY: + /* Icons originated in app-indicator only set a primary menu, + * but expect it to be opened on left and right-clicks */ + + if (g_object_get_data (G_OBJECT (icon), "app-indicator")) + { + menu_to_use = icon->priv->primary_menu; + } + else + { + menu_to_use = icon->priv->secondary_menu; + } + break; + } + + return menu_to_use; +} + +static gboolean +handle_click_method (XAppStatusIconInterface *skeleton, + GDBusMethodInvocation *invocation, + gint x, + gint y, + guint button, + guint _time, + gint panel_position, + XAppStatusIcon *icon) +{ + const gchar *name = g_dbus_method_invocation_get_method_name (invocation); + + if (g_strcmp0 (name, "ButtonPress") == 0) + { + g_debug ("XAppStatusIcon: received ButtonPress from monitor %s: " + "pos:%d,%d , button: %s , time: %u , orientation: %s", + g_dbus_method_invocation_get_sender (invocation), + x, y, button_to_str (button), _time, panel_position_to_str (panel_position)); + + if (!handle_appindicator_button_press (icon, button, _time)) + { + if (should_send_activate (icon, button)) + { + g_debug ("XAppStatusIcon: native sending 'activate' for %s button", button_to_str (button)); + g_signal_emit (icon, signals[ACTIVATE], 0, + button, + _time); + } + } + + icon->priv->have_button_press = TRUE; + + g_signal_emit (icon, signals[BUTTON_PRESS], 0, + x, y, + button, + _time, + panel_position); + + xapp_status_icon_interface_complete_button_press (skeleton, + invocation); + } + else + if (g_strcmp0 (name, "ButtonRelease") == 0) + { + g_debug ("XAppStatusIcon: received ButtonRelease from monitor %s: " + "pos:%d,%d , button: %s , time: %u , orientation: %s", + g_dbus_method_invocation_get_sender (invocation), + x, y, button_to_str (button), _time, panel_position_to_str (panel_position)); + + if (icon->priv->have_button_press) + { + GtkWidget *menu_to_use = get_menu_to_use (icon, button); + + if (menu_to_use) + { + popup_native_icon_menu (icon, + GTK_MENU (menu_to_use), + x, y, + button, + _time, + panel_position); + } + + g_signal_emit (icon, signals[BUTTON_RELEASE], 0, + x, y, + button, + _time, + panel_position); + } + + icon->priv->have_button_press = FALSE; + + xapp_status_icon_interface_complete_button_release (skeleton, + invocation); + } + + return TRUE; +} + +static void +popup_gtk_status_icon_with_menu (XAppStatusIcon *icon, + GtkMenu *menu, + GtkStatusIcon *gtk_status_icon, + guint button, + guint activate_time) +{ + gtk_menu_popup (menu, + NULL, + NULL, + gtk_status_icon_position_menu, + gtk_status_icon, + button, + activate_time); +} + +static void +calculate_gtk_status_icon_position_and_orientation (XAppStatusIcon *icon, + GtkStatusIcon *status_icon, + gint *x, gint *y, gint *orientation) +{ + GdkScreen *screen; + GdkRectangle irect; + GtkOrientation iorientation; + gint final_x, final_y, final_o; + + final_x = 0; + final_y = 0; + final_o = 0; + + if (gtk_status_icon_get_geometry (status_icon, + &screen, + &irect, + &iorientation)) + { + GdkDisplay *display = gdk_screen_get_display (screen); + GdkMonitor *monitor; + GdkRectangle mrect; + + monitor = gdk_display_get_monitor_at_point (display, + irect.x + (irect.width / 2), + irect.y + (irect.height / 2)); + + gdk_monitor_get_workarea (monitor, &mrect); + + switch (iorientation) + { + case GTK_ORIENTATION_HORIZONTAL: + final_x = irect.x; + + if (irect.y + irect.height + 100 < mrect.y + mrect.height) + { + final_y = irect.y + irect.height; + final_o = GTK_POS_TOP; + } + else + { + final_y = irect.y; + final_o = GTK_POS_BOTTOM; + } + + break; + case GTK_ORIENTATION_VERTICAL: + final_y = irect.y; + + if (irect.x + irect.width + 100 < mrect.x + mrect.width) + { + final_x = irect.x + irect.width; + final_o = GTK_POS_LEFT; + } + else + { + final_x = irect.x; + final_o = GTK_POS_RIGHT; + } + } + } + + *x = final_x; + *y = final_y; + *orientation = final_o; +} + +static gboolean +on_gtk_status_icon_button_press (GtkStatusIcon *status_icon, + GdkEvent *event, + gpointer user_data) +{ + XAppStatusIcon *icon = user_data; + + guint _time; + guint button; + gint x, y, orientation; + + button = event->button.button; + _time = event->button.time; + + /* Button press equates to activate when there's no menu, + * but for appindicator, left click and right click will always + * bring up the same menu, and only a middle click should activate. */ + + g_debug ("XAppStatusIcon: GtkStatusIcon button-press-event with %s button", button_to_str (button)); + + if (!handle_appindicator_button_press (icon, button, _time)) + { + /* We always send 'activate' for a button that has no corresponding menu, + * and for middle clicks. */ + if (should_send_activate (icon, button)) + { + g_debug ("XAppStatusIcon: GtkStatusIcon activated by %s button", button_to_str (button)); + + g_signal_emit (icon, signals[ACTIVATE], 0, + button, + _time); + } + } + + calculate_gtk_status_icon_position_and_orientation (icon, + status_icon, + &x, + &y, + &orientation); + + icon->priv->have_button_press = TRUE; + + g_signal_emit (icon, signals[BUTTON_PRESS], 0, + x, y, + button, + _time, + orientation); +} + +static void +on_gtk_status_icon_button_release (GtkStatusIcon *status_icon, + GdkEvent *event, + gpointer user_data) +{ + XAppStatusIcon *icon = user_data; + guint _time; + guint button; + gint x, y, orientation; + + button = event->button.button; + _time = event->button.time; + + g_debug ("XAppStatusIcon: GtkStatusIcon button-release-event with %s button", button_to_str (button)); + + /* Icons originated in app-indicator have only a single menu, which displays on either + * right or left-click. */ + if (g_object_get_data (G_OBJECT (status_icon), "app-indicator")) + { + if (button == GDK_BUTTON_PRIMARY || button == GDK_BUTTON_SECONDARY) + { + popup_gtk_status_icon_with_menu (icon, + GTK_MENU (icon->priv->primary_menu), + status_icon, + button, + _time); + } + } + else + { + /* Native icons can have two menus, so we must determine which to use based + * on the gtk icon event's button. */ + GtkWidget *menu_to_use; + + menu_to_use = get_menu_to_use (icon, button); + + if (menu_to_use) + { + g_debug ("XAppStatusIcon: GtkStatusIcon popup menu for %s button", button_to_str (button)); + + popup_gtk_status_icon_with_menu (icon, + GTK_MENU (menu_to_use), + status_icon, + button, + _time); + } + } + + calculate_gtk_status_icon_position_and_orientation (icon, + status_icon, + &x, + &y, + &orientation); + + icon->priv->have_button_press = FALSE; + + g_signal_emit (icon, signals[BUTTON_RELEASE], 0, + x, y, + button, + _time, + orientation); +} + +static void +name_owner_changed (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); + g_debug("XAppStatusIcon: NameOwnerChanged signal received, refreshing icon"); + + refresh_icon (self); +} + +static void +add_name_listener (XAppStatusIcon *self) +{ + g_debug ("XAppStatusIcon: Adding NameOwnerChanged listener for status monitors"); + + self->priv->listener_id = g_dbus_connection_signal_subscribe (self->priv->connection, + FDO_DBUS_NAME, + FDO_DBUS_NAME, + "NameOwnerChanged", + FDO_DBUS_PATH, + STATUS_ICON_MONITOR_MATCH, + G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE, + name_owner_changed, + self, + NULL); +} + +static void +on_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); + + g_warning ("XAppStatusIcon: lost or could not acquire presence on dbus. Refreshing."); + + self->priv->fail_counter++; + + refresh_icon (self); +} + +static void +sync_skeleton (XAppStatusIcon *self) +{ + XAppStatusIconPrivate *priv = self->priv; + + priv->fail_counter = 0; + + g_clear_object (&self->priv->gtk_status_icon); + + g_object_set (G_OBJECT (priv->skeleton), + "name", priv->name, + "label", priv->label, + "icon-name", priv->icon_name, + "tooltip-text", priv->tooltip_text, + "visible", priv->visible, + NULL); + + g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (priv->skeleton)); +} + +static void +on_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); + + self->priv->state = XAPP_STATUS_ICON_STATE_NATIVE; + + sync_skeleton (self); + + g_debug ("XAppStatusIcon: name acquired on dbus, syncing icon properties. State is now: %s", + state_to_str (self->priv->state)); + g_signal_emit (self, signals[STATE_CHANGED], 0, self->priv->state); +} + +typedef struct +{ + const gchar *signal_name; + gpointer callback; +} SkeletonSignal; + +static SkeletonSignal skeleton_signals[] = { + // signal name callback + { "handle-button-press", handle_click_method }, + { "handle-button-release", handle_click_method } +}; + +static gboolean +export_icon_interface (XAppStatusIcon *self) +{ + GError *error = NULL; + gint i; + gchar *unique_path; + + if (self->priv->skeleton) { + return TRUE; + } + + self->priv->skeleton = xapp_status_icon_interface_skeleton_new (); + + unique_path = g_strdup_printf (ICON_PATH "/%d", unique_id); + + g_debug ("XAppStatusIcon: exporting StatusIcon dbus interface to %s", unique_path); + + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->skeleton), + self->priv->connection, + unique_path, + &error); + + g_free (unique_path); + + if (error != NULL) { + g_critical ("XAppStatusIcon: could not export StatusIcon interface: %s", error->message); + g_error_free (error); + + return FALSE; + } + + for (i = 0; i < G_N_ELEMENTS (skeleton_signals); i++) { + SkeletonSignal sig = skeleton_signals[i]; + + g_signal_connect (self->priv->skeleton, + sig.signal_name, + G_CALLBACK (sig.callback), + self); + } + + return TRUE; +} + +static void +connect_with_status_applet (XAppStatusIcon *self) +{ + + char *owner_name = g_strdup_printf("%s.PID-%d-%d", ICON_NAME, getpid (), unique_id); + + unique_id++; + + g_debug ("XAppStatusIcon: Attempting to acquire presence on dbus as %s", owner_name); + + self->priv->owner_id = g_bus_own_name_on_connection (self->priv->connection, + owner_name, + G_DBUS_CONNECTION_FLAGS_NONE, + on_name_acquired, + on_name_lost, + self, + NULL); + + g_free(owner_name); +} + +static void +update_fallback_icon (XAppStatusIcon *self, + const gchar *icon_name) +{ + if (g_path_is_absolute (icon_name)) + { + gtk_status_icon_set_from_file (self->priv->gtk_status_icon, icon_name); + } + else + { + gtk_status_icon_set_from_icon_name (self->priv->gtk_status_icon, icon_name); + } +} + +static void +on_gtk_status_icon_embedded_changed (GtkStatusIcon *icon, + GParamSpec *pspec, + gpointer user_data) +{ + g_return_if_fail (GTK_IS_STATUS_ICON (icon)); + + XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); + XAppStatusIconPrivate *priv = self->priv; + + if (gtk_status_icon_is_embedded (icon)) + { + priv->state = XAPP_STATUS_ICON_STATE_FALLBACK; + } + else + { + priv->state = XAPP_STATUS_ICON_STATE_NO_SUPPORT; + } + + g_debug ("XAppStatusIcon fallback icon embedded_changed. State is now %s", + state_to_str (priv->state)); + g_signal_emit (self, signals[STATE_CHANGED], 0, priv->state); +} + +static void +use_gtk_status_icon (XAppStatusIcon *self) +{ + XAppStatusIconPrivate *priv = self->priv; + + g_debug ("XAppStatusIcon: falling back to GtkStatusIcon"); + + tear_down_dbus (self); + + // Make sure there wasn't already one + g_clear_object (&self->priv->gtk_status_icon); + + self->priv->gtk_status_icon = gtk_status_icon_new (); + + g_signal_connect (priv->gtk_status_icon, + "button-press-event", + G_CALLBACK (on_gtk_status_icon_button_press), + self); + g_signal_connect (priv->gtk_status_icon, + "button-release-event", + G_CALLBACK (on_gtk_status_icon_button_release), + self); + g_signal_connect (priv->gtk_status_icon, + "notify::embedded", + G_CALLBACK (on_gtk_status_icon_embedded_changed), + self); + + update_fallback_icon (self, priv->icon_name ? priv->icon_name : ""); + gtk_status_icon_set_tooltip_text (self->priv->gtk_status_icon, priv->tooltip_text); +} + +static void +on_list_names_completed (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON(user_data); + GVariant *result; + GVariantIter *iter; + gchar *str; + GError *error; + gboolean found; + + error = NULL; + + result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), + res, + &error); + + if (error != NULL) + { + if (error->code != G_IO_ERROR_CANCELLED) + { + g_critical ("XAppStatusIcon: attempt to ListNames failed: %s\n", error->message); + use_gtk_status_icon (self); + } + else + { + g_debug ("XAppStatusIcon: attempt to ListNames cancelled"); + } + + g_error_free (error); + return; + } + + g_variant_get (result, "(as)", &iter); + + found = FALSE; + + while (g_variant_iter_loop (iter, "s", &str)) + { + if (g_str_has_prefix (str, STATUS_ICON_MONITOR_MATCH)) + { + g_debug ("XAppStatusIcon: Discovered active status monitor (%s)", str); + found = TRUE; + } + } + + g_variant_iter_free (iter); + g_variant_unref (result); + + if (found && export_icon_interface (self)) + { + if (self->priv->owner_id > 0) + { + g_debug ("XAppStatusIcon: We already exist on the bus, syncing icon properties"); + sync_skeleton (self); + } + else + { + connect_with_status_applet (self); + + return; + } + } + else + { + use_gtk_status_icon (self); + } +} + +static void +look_for_status_applet (XAppStatusIcon *self) +{ + // Check that there is at least one applet on DBUS + g_debug("XAppStatusIcon: Looking for status monitors"); + + cancellable_reset (self); + + g_dbus_connection_call (self->priv->connection, + FDO_DBUS_NAME, + FDO_DBUS_PATH, + FDO_DBUS_NAME, + "ListNames", + NULL, + G_VARIANT_TYPE ("(as)"), + G_DBUS_CALL_FLAGS_NONE, + 3000, /* 3 secs */ + self->priv->cancellable, + on_list_names_completed, + self); +} + +static void +complete_icon_setup (XAppStatusIcon *self) +{ + if (self->priv->listener_id == 0) + { + add_name_listener (self); + } + + /* There is a potential loop in the g_bus_own_name sequence - + * if we fail to acquire a name, we refresh again and potentially + * fail again. If we fail more than MAX_NAME_FAILS, then quit trying + * and just use the fallback icon It's pretty unlikely for*/ + if (self->priv->fail_counter == MAX_NAME_FAILS) + { + use_gtk_status_icon (self); + return; + } + + look_for_status_applet (self); +} + +static void +on_session_bus_connected (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); + GError *error; + + error = NULL; + + self->priv->connection = g_bus_get_finish (res, &error); + + if (error != NULL) + { + if (error->code != G_IO_ERROR_CANCELLED) + { + g_critical ("XAppStatusIcon: Unable to acquire session bus: %s", error->message); + + + /* If we never get a connection, we use the Gtk icon exclusively, and will never + * re-try. FIXME? this is unlikely to happen, so I don't see the point in trying + * later, as there are probably bigger problems in this case. */ + use_gtk_status_icon (self); + } + else + { + g_debug ("XAppStatusIcon: Cancelled session bus acquire"); + } + + g_error_free (error); + return; + } + + if (self->priv->connection) + { + complete_icon_setup (self); + return; + } + + use_gtk_status_icon (self); +} + +static void +refresh_icon (XAppStatusIcon *self) +{ + if (!self->priv->connection) + { + g_debug ("XAppStatusIcon: Trying to acquire session bus connection"); + + cancellable_reset (self); + + g_bus_get (G_BUS_TYPE_SESSION, + self->priv->cancellable, + on_session_bus_connected, + self); + } + else + { + complete_icon_setup (self); + } +} + +static void +xapp_status_icon_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_PRIMARY_MENU: + xapp_status_icon_set_primary_menu (XAPP_STATUS_ICON (object), g_value_get_object (value)); + break; + case PROP_SECONDARY_MENU: + xapp_status_icon_set_secondary_menu (XAPP_STATUS_ICON (object), g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +xapp_status_icon_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + XAppStatusIcon *icon = XAPP_STATUS_ICON (object); + + switch (prop_id) + { + case PROP_PRIMARY_MENU: + g_value_set_object (value, icon->priv->primary_menu); + break; + case PROP_SECONDARY_MENU: + g_value_set_object (value, icon->priv->secondary_menu); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +xapp_status_icon_init (XAppStatusIcon *self) +{ + self->priv = xapp_status_icon_get_instance_private (self); + + self->priv->name = g_strdup_printf("%s", g_get_application_name()); + self->priv->state = XAPP_STATUS_ICON_STATE_NO_SUPPORT; + + g_debug ("XAppStatusIcon: init: application name: '%s'", self->priv->name); + + // Default to visible (the same behavior as GtkStatusIcon) + self->priv->visible = TRUE; + + refresh_icon (self); +} + +static void +tear_down_dbus (XAppStatusIcon *self) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (self)); + + if (self->priv->owner_id > 0) + { + g_debug ("XAppStatusIcon: removing dbus presence (%p)", self); + + g_bus_unown_name(self->priv->owner_id); + self->priv->owner_id = 0; + } + + if (self->priv->skeleton) + { + g_debug ("XAppStatusIcon: removing dbus interface (%p)", self); + + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->priv->skeleton)); + g_object_unref (self->priv->skeleton); + self->priv->skeleton = NULL; + } +} + +static void +xapp_status_icon_dispose (GObject *object) +{ + XAppStatusIcon *self = XAPP_STATUS_ICON (object); + + g_debug ("XAppStatusIcon dispose (%p)", object); + + g_free (self->priv->name); + g_free (self->priv->icon_name); + g_free (self->priv->tooltip_text); + g_free (self->priv->label); + + g_clear_object (&self->priv->cancellable); + + g_clear_object (&self->priv->primary_menu); + g_clear_object (&self->priv->secondary_menu); + + g_signal_handlers_disconnect_by_func (self->priv->gtk_status_icon, on_gtk_status_icon_button_press, self); + g_signal_handlers_disconnect_by_func (self->priv->gtk_status_icon, on_gtk_status_icon_button_release, self); + g_clear_object (&self->priv->gtk_status_icon); + + tear_down_dbus (self); + + if (self->priv->listener_id > 0) + { + g_dbus_connection_signal_unsubscribe (self->priv->connection, self->priv->listener_id); + } + + g_clear_object (&self->priv->connection); + + G_OBJECT_CLASS (xapp_status_icon_parent_class)->dispose (object); +} + +static void +xapp_status_icon_finalize (GObject *object) +{ + g_debug ("XAppStatusIcon finalize (%p)", object); + + g_clear_object (&XAPP_STATUS_ICON (object)->priv->cancellable); + + G_OBJECT_CLASS (xapp_status_icon_parent_class)->finalize (object); +} + +static void +xapp_status_icon_class_init (XAppStatusIconClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->dispose = xapp_status_icon_dispose; + gobject_class->finalize = xapp_status_icon_finalize; + gobject_class->set_property = xapp_status_icon_set_property; + gobject_class->get_property = xapp_status_icon_get_property; + + /** + * XAppStatusIcon:primary-menu: + * + * A #GtkMenu to use when requested by the remote monitor via a left (or primary) click. + * + * When this property is not %NULL, the menu will be automatically positioned and + * displayed during a primary button release. + * + * When this property IS %NULL, the #XAppStatusIcon::activate will be sent for primary + * button presses. + * + * In both cases, the #XAppStatusIcon::button-press-event and #XAppStatusIcon::button-release-events + * will be fired like normal. + * + * Setting this will remove any floating reference to the menu and assume ownership. + * As a result, it is not necessary to maintain a reference to it in the parent + * application (or unref it when finished with it - if you wish to replace the menu, + * simply call this method again with a new menu. + * + * The same #GtkMenu widget can be set as both the primary and secondary. + */ + g_object_class_install_property (gobject_class, PROP_PRIMARY_MENU, + g_param_spec_object ("primary-menu", + "Status icon primary (left-click) menu", + "A menu to bring up when the status icon is left-clicked", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE)); + + /** + * XAppStatusIcon:secondary-menu: + * + * A #GtkMenu to use when requested by the remote monitor via a right (or secondary) click. + * + * When this property is not %NULL, the menu will be automatically positioned and + * displayed during a secondary button release. + * + * When this property IS %NULL, the #XAppStatusIcon::activate will be sent for secondary + * button presses. + * + * In both cases, the #XAppStatusIcon::button-press-event and #XAppStatusIcon::button-release-events + * will be fired like normal. + * + * Setting this will remove any floating reference to the menu and assume ownership. + * As a result, it is not necessary to maintain a reference to it in the parent + * application (or unref it when finished with it - if you wish to replace the menu, + * simply call this method again with a new menu. + * + * The same #GtkMenu widget can be set as both the primary and secondary. + */ + g_object_class_install_property (gobject_class, PROP_SECONDARY_MENU, + g_param_spec_object ("secondary-menu", + "Status icon secondary (right-click) menu", + "A menu to bring up when the status icon is right-clicked", + GTK_TYPE_WIDGET, + G_PARAM_READWRITE)); + + + /** + * XAppStatusIcon::button-press-event: + * @icon: The #XAppStatusIcon + * @x: The absolute x position to use for menu positioning + * @y: The absolute y position to use for menu positioning + * @button: The button that was pressed + * @time: The time supplied by the event, or 0 + * @panel_position: The #GtkPositionType to use for menu positioning + * + * Gets emitted when there is a button press received from an applet + */ + signals[BUTTON_PRESS] = + g_signal_new ("button-press-event", + XAPP_TYPE_STATUS_ICON, + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 5, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT); + + /** + * XAppStatusIcon::button-release-event: + * @icon: The #XAppStatusIcon + * @x: The absolute x position to use for menu positioning + * @y: The absolute y position to use for menu positioning + * @button: The button that was released + * @time: The time supplied by the event, or 0 + * @panel_position: The #GtkPositionType to use for menu positioning + * + * Gets emitted when there is a button release received from an applet + */ + signals[BUTTON_RELEASE] = + g_signal_new ("button-release-event", + XAPP_TYPE_STATUS_ICON, + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 5, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INT); + + /** + * XAppStatusIcon::activate: + * @icon: The #XAppStatusIcon + * @button: The button that was pressed + * @time: The time supplied by the event, or 0 + * + * Gets emitted when the user activates the status icon. If the XAppStatusIcon:primary-menu or + * XAppStatusIcon:secondary-menu is not %NULL, this signal is skipped for the respective button + * presses. A middle button click will always send this signal when pressed. + */ + signals [ACTIVATE] = + g_signal_new ("activate", + XAPP_TYPE_STATUS_ICON, + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + + /** + * XAppStatusIcon::state-changed: + * @icon: The #XAppStatusIcon + * @new_state: The new #XAppStatusIconState of the icon + * + * Gets emitted when the state of the icon changes. If you wish + * to react to changes in how the status icon is being handled + * (perhaps to alter the menu or other click behavior), you should + * connect to this - see #XAppStatusIconState for more details. + */ + signals [STATE_CHANGED] = + g_signal_new ("state-changed", + XAPP_TYPE_STATUS_ICON, + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, XAPP_TYPE_STATUS_ICON_STATE); +} + +/** + * xapp_status_icon_set_name: + * @icon: a #XAppStatusIcon + * @name: a name (this defaults to the name of the application, if not set) + * + * Sets the status icon name. This is not shown to users. + * + * Since: 1.6 + */ +void +xapp_status_icon_set_name (XAppStatusIcon *icon, const gchar *name) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + g_clear_pointer (&icon->priv->name, g_free); + icon->priv->name = g_strdup (name); + + g_debug ("XAppStatusIcon set_name: %s", name); + + if (icon->priv->skeleton) + { + xapp_status_icon_interface_set_name (icon->priv->skeleton, name); + } + + if (icon->priv->gtk_status_icon != NULL) + { + gtk_status_icon_set_name (icon->priv->gtk_status_icon, name); + } +} + +/** + * xapp_status_icon_set_icon_name: + * @icon: a #XAppStatusIcon + * @icon_name: An icon name or absolute path to an icon. + * + * Sets the icon name or local path to use. + * + * Since: 1.6 + */ +void +xapp_status_icon_set_icon_name (XAppStatusIcon *icon, const gchar *icon_name) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + g_clear_pointer (&icon->priv->icon_name, g_free); + icon->priv->icon_name = g_strdup (icon_name); + + g_debug ("XAppStatusIcon set_icon_name: %s", icon_name); + + if (icon->priv->skeleton) + { + xapp_status_icon_interface_set_icon_name (icon->priv->skeleton, icon_name); + } + + if (icon->priv->gtk_status_icon != NULL) + { + update_fallback_icon (icon, icon_name); + } +} + +/** + * xapp_status_icon_set_tooltip_text: + * @icon: a #XAppStatusIcon + * @tooltip_text: the text to show in the tooltip + * + * Sets the tooltip text + * + * Since: 1.6 + */ +void +xapp_status_icon_set_tooltip_text (XAppStatusIcon *icon, const gchar *tooltip_text) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + g_clear_pointer (&icon->priv->tooltip_text, g_free); + icon->priv->tooltip_text = g_strdup (tooltip_text); + + g_debug ("XAppStatusIcon set_tooltip_text: %s", tooltip_text); + + if (icon->priv->skeleton) + { + xapp_status_icon_interface_set_tooltip_text (icon->priv->skeleton, tooltip_text); + } + + if (icon->priv->gtk_status_icon != NULL) + { + gtk_status_icon_set_tooltip_text (icon->priv->gtk_status_icon, tooltip_text); + } +} + +/** + * xapp_status_icon_set_label: + * @icon: a #XAppStatusIcon + * @label: some text + * + * Sets a label, shown beside the icon + * + * Since: 1.6 + */ +void +xapp_status_icon_set_label (XAppStatusIcon *icon, const gchar *label) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + g_clear_pointer (&icon->priv->label, g_free); + icon->priv->label = g_strdup (label); + + g_debug ("XAppStatusIcon set_label: '%s'", label); + + if (icon->priv->skeleton) + { + xapp_status_icon_interface_set_label (icon->priv->skeleton, label); + } +} + +/** + * xapp_status_icon_set_visible: + * @icon: a #XAppStatusIcon + * @visible: whether or not the status icon should be visible + * + * Sets the visibility of the status icon + * + * Since: 1.6 + */ +void +xapp_status_icon_set_visible (XAppStatusIcon *icon, const gboolean visible) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + icon->priv->visible = visible; + + g_debug ("XAppStatusIcon set_visible: %s", visible ? "TRUE" : "FALSE"); + + if (icon->priv->skeleton) + { + xapp_status_icon_interface_set_visible (icon->priv->skeleton, visible); + } + + if (icon->priv->gtk_status_icon != NULL) + { + gtk_status_icon_set_visible (icon->priv->gtk_status_icon, visible); + } +} + +/** + * xapp_status_icon_set_primary_menu: + * @icon: an #XAppStatusIcon + * @menu: (nullable): A #GtkMenu to display when the primary mouse button is released. + * + * See the #XAppStatusIcon:primary-menu property for details + * + * Since: 1.6 + */ +void +xapp_status_icon_set_primary_menu (XAppStatusIcon *icon, + GtkMenu *menu) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + + g_clear_object (&icon->priv->primary_menu); + + g_debug ("XAppStatusIcon set_primary_menu: %p", menu); + + if (menu) + { + icon->priv->primary_menu = GTK_WIDGET (g_object_ref_sink (menu)); + } +} + +/** + * xapp_status_icon_get_primary_menu: + * @icon: an #XAppStatusIcon + * + * Returns a pointer to a #GtkMenu that was set previously for the + * primary mouse button. If no menu was set, this returns %NULL. + * + * Returns: (transfer none): the #GtkMenu or %NULL if none was set. + + * Since: 1.6 + */ +GtkWidget * +xapp_status_icon_get_primary_menu (XAppStatusIcon *icon) +{ + g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), NULL); + + g_debug ("XAppStatusIcon get_menu: %p", icon->priv->primary_menu); + + return icon->priv->primary_menu; +} + +/** + * xapp_status_icon_set_secondary_menu: + * @icon: an #XAppStatusIcon + * @menu: (nullable): A #GtkMenu to display when the primary mouse button is released. + * + * See the #XAppStatusIcon:secondary-menu property for details + * + * Since: 1.6 + */ +void +xapp_status_icon_set_secondary_menu (XAppStatusIcon *icon, + GtkMenu *menu) +{ + g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); + + g_clear_object (&icon->priv->secondary_menu); + + g_debug ("XAppStatusIcon set_secondary_menu: %p", menu); + + if (menu) + { + icon->priv->secondary_menu = GTK_WIDGET (g_object_ref_sink (menu)); + } +} + +/** + * xapp_status_icon_get_secondary_menu: + * @icon: an #XAppStatusIcon + * + * Returns a pointer to a #GtkMenu that was set previously for the + * secondary mouse button. If no menu was set, this returns %NULL. + * + * Returns: (transfer none): the #GtkMenu or %NULL if none was set. + + * Since: 1.6 + */ +GtkWidget * +xapp_status_icon_get_secondary_menu (XAppStatusIcon *icon) +{ + g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), NULL); + + g_debug ("XAppStatusIcon get_menu: %p", icon->priv->secondary_menu); + + return icon->priv->secondary_menu; +} + +/** + * xapp_status_icon_new: + * + * Creates a new #XAppStatusIcon instance + * + * Returns: (transfer full): a new #XAppStatusIcon. Use g_object_unref when finished. + * + * Since: 1.6 + */ +XAppStatusIcon * +xapp_status_icon_new (void) +{ + return g_object_new (XAPP_TYPE_STATUS_ICON, NULL); +} + +/** + * xapp_status_icon_get_state: + * @icon: an #XAppStatusIcon + * + * Gets the current #XAppStatusIconState of icon. The state is determined by whether + * the icon is being displayed by an #XAppStatusMonitor client, a fallback tray icon, + * or not being displayed at all. + * + * See #XAppStatusIconState for more details. + * + * Returns: the icon's state. + * + * Since: 1.6 + */ +XAppStatusIconState +xapp_status_icon_get_state (XAppStatusIcon *icon) +{ + g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), XAPP_STATUS_ICON_STATE_NO_SUPPORT); + + g_debug ("XAppStatusIcon get_state: %s", state_to_str (icon->priv->state)); + + return icon->priv->state; +} + +/** + * xapp_status_icon_any_monitors: + * + * Looks for the existence of any active #XAppStatusIconMonitors on the bus. + * + * Returns: %TRUE if at least one monitor was found. + * + * Since: 1.6 + */ +gboolean +xapp_status_icon_any_monitors (void) +{ + GDBusConnection *connection; + GError *error; + gboolean found; + + g_debug("XAppStatusIcon: any_monitors: Looking for status monitors"); + + error = NULL; + found = FALSE; + + connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + + if (connection) + { + GVariant *result; + + result = g_dbus_connection_call_sync (connection, + FDO_DBUS_NAME, + FDO_DBUS_PATH, + FDO_DBUS_NAME, + "ListNames", + NULL, + G_VARIANT_TYPE ("(as)"), + G_DBUS_CALL_FLAGS_NONE, + 2, NULL, &error); + + if (result) + { + GVariantIter *iter; + gchar *str; + + g_variant_get (result, "(as)", &iter); + + found = FALSE; + + while (g_variant_iter_loop (iter, "s", &str)) + { + if (g_str_has_prefix (str, STATUS_ICON_MONITOR_MATCH)) + { + g_debug ("XAppStatusIcon: any_monitors: discovered active status monitor (%s)", str); + + found = TRUE; + + g_free (str); + break; + } + } + + g_variant_iter_free (iter); + g_variant_unref (result); + } + + g_object_unref (connection); + } + + if (error) + { + g_warning ("XAppStatusIcon: any_monitors: Unable to check for monitors: %s", error->message); + g_error_free (error); + } + + g_debug ("XAppStatusIcon: any_monitors: %s", found ? "TRUE" : "FALSE"); + + return found; +} + diff --git a/libxapp/xapp-status-icon.h b/libxapp/xapp-status-icon.h new file mode 100644 index 0000000..60d1d67 --- /dev/null +++ b/libxapp/xapp-status-icon.h @@ -0,0 +1,47 @@ +#ifndef __XAPP_STATUS_ICON_H__ +#define __XAPP_STATUS_ICON_H__ + +#include +#include + +#include + +G_BEGIN_DECLS + +#define XAPP_TYPE_STATUS_ICON (xapp_status_icon_get_type ()) + +G_DECLARE_FINAL_TYPE (XAppStatusIcon, xapp_status_icon, XAPP, STATUS_ICON, GObject) + +/** + * XAppStatusIconState: + * @XAPP_STATUS_ICON_STATE_NATIVE: The #XAppStatusIcon is currently being handled + * by an #XAppStatusIconMonitor (usually in an applet). + * @XAPP_STATUS_ICON_STATE_FALLBACK: The #XAppStatusIcon is currently being handled + * by a legacy system tray implementation (using GtkStatusIcon). + * @XAPP_STATUS_ICON_STATE_NO_SUPPORT: The #XAppStatusIcon is not currently being handled by any + * kind of status icon implementation. + */ +typedef enum +{ + XAPP_STATUS_ICON_STATE_NATIVE, + XAPP_STATUS_ICON_STATE_FALLBACK, + XAPP_STATUS_ICON_STATE_NO_SUPPORT +} XAppStatusIconState; + +XAppStatusIcon *xapp_status_icon_new (void); +void xapp_status_icon_set_name (XAppStatusIcon *icon, const gchar *name); +void xapp_status_icon_set_icon_name (XAppStatusIcon *icon, const gchar *icon_name); +void xapp_status_icon_set_tooltip_text (XAppStatusIcon *icon, const gchar *tooltip_text); +void xapp_status_icon_set_label (XAppStatusIcon *icon, const gchar *label); +void xapp_status_icon_set_visible (XAppStatusIcon *icon, const gboolean visible); +void xapp_status_icon_set_primary_menu (XAppStatusIcon *icon, GtkMenu *menu); +GtkWidget *xapp_status_icon_get_primary_menu (XAppStatusIcon *icon); +void xapp_status_icon_set_secondary_menu (XAppStatusIcon *icon, GtkMenu *menu); +GtkWidget *xapp_status_icon_get_secondary_menu (XAppStatusIcon *icon); +XAppStatusIconState xapp_status_icon_get_state (XAppStatusIcon *icon); + +/* static */ +gboolean xapp_status_icon_any_monitors (void); +G_END_DECLS + +#endif /* __XAPP_STATUS_ICON_H__ */ diff --git a/makedoc b/makedoc new file mode 100755 index 0000000..2b41ed2 --- /dev/null +++ b/makedoc @@ -0,0 +1,18 @@ +#!/usr/bin/python3 + +# This script is used to update the docs in docs/reference +# which are served at http://developer.linuxmint.com/xapps/reference/index.html. + +import os +import sys + +SRC="debian/tmp/usr/share/gtk-doc/html/libxapp/" + +if not os.path.exists(SRC): + print("Build first, with dpkg-buildpackage") + sys.exit(1) + +os.system("rm -rf docs/reference/*") +os.system("cp -R %s/* docs/reference/" % SRC) + +print ("Docs updated, you can now commit and push.") diff --git a/makepot b/makepot index 69f9a22..8b97ab5 100755 --- a/makepot +++ b/makepot @@ -1,4 +1,9 @@ #!/bin/bash -xgettext --language=C --keyword=_ --keyword=N_ --output=xapp.pot libxapp/*.c +rm -f xapp.pot +touch xapp.pot +xgettext --language=C --add-comments --keyword=_ --keyword=N_ --output=xapp.pot libxapp/*.c +xgettext --language=Python --add-comments --keyword=_ --join-existing --output=xapp.pot status-applets/*/*.py +xgettext --language=Desktop --join-existing --add-comments \ + -k --keyword=Name --keyword=Description --output=xapp.pot status-applets/*/*.in diff --git a/meson.build b/meson.build index 216523c..6db3fc8 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('xapp', 'c', - version : '1.4.9' + version : '1.6.2' ) gnome = import('gnome') @@ -9,6 +9,13 @@ cdata = configuration_data() cdata.set('GETTEXT_PACKAGE', '"xapp"') + +add_global_arguments([ + '-Wunused', + '-Wimplicit-function-declaration' + ], + language: 'c' +) if not get_option('deprecated_warnings') add_global_arguments([ @@ -31,6 +38,7 @@ subdir('pygobject') subdir('files') subdir('schemas') +subdir('status-applets') if get_option('docs') subdir('docs') diff --git a/status-applets/mate/applet_constants.py.in b/status-applets/mate/applet_constants.py.in new file mode 100644 index 0000000..c485123 --- /dev/null +++ b/status-applets/mate/applet_constants.py.in @@ -0,0 +1,2 @@ +LOCALEDIR = "@locale@" +PKGVERSION = "@pkgversion@" \ No newline at end of file diff --git a/status-applets/mate/mate-xapp-status-applet.py b/status-applets/mate/mate-xapp-status-applet.py new file mode 100755 index 0000000..a0c4eda --- /dev/null +++ b/status-applets/mate/mate-xapp-status-applet.py @@ -0,0 +1,389 @@ +#!/usr/bin/python3 + +import locale +import gettext +import os +import sys +import setproctitle + +import gi +gi.require_version("Gtk", "3.0") +gi.require_version("XApp", "1.0") +gi.require_version('MatePanelApplet', '4.0') +from gi.repository import Gtk, GdkPixbuf, Gdk, GObject, Gio, XApp, GLib, MatePanelApplet + +import applet_constants + +# Rename the process +setproctitle.setproctitle('mate-xapp-status-applet') + +# i18n +gettext.install("xapp", applet_constants.LOCALEDIR) +locale.bindtextdomain("xapp", applet_constants.LOCALEDIR) +locale.textdomain("xapp") + +ICON_SIZE_REDUCTION = 2 +VISIBLE_LABEL_MARGIN = 5 # When an icon has a label, add a margin between icon and label + +statusicon_css_string = """ +.statuswidget-horizontal { + border: none; + padding-top: 0; + padding-left: 2px; + padding-bottom: 0; + padding-right: 2px; +} + +.statuswidget-vertical { + border: none; + padding-top: 2px; + padding-left: 0; + padding-bottom: 2px; + padding-right: 0; +} +""" + +def translate_applet_orientation_to_xapp(mate_applet_orientation): + # wtf...mate panel's orientation is.. the direction to center of monitor? + if mate_applet_orientation == MatePanelApplet.AppletOrient.UP: + return Gtk.PositionType.BOTTOM + elif mate_applet_orientation == MatePanelApplet.AppletOrient.DOWN: + return Gtk.PositionType.TOP + elif mate_applet_orientation == MatePanelApplet.AppletOrient.LEFT: + return Gtk.PositionType.RIGHT + elif mate_applet_orientation == MatePanelApplet.AppletOrient.RIGHT: + return Gtk.PositionType.LEFT + +class StatusWidget(Gtk.ToggleButton): + def __init__(self, icon, orientation, size): + super(Gtk.Button, self).__init__() + self.theme = Gtk.IconTheme.get_default() + self.orientation = orientation + self.size = size + + self.proxy = icon + + # this is the bus owned name + self.name = self.proxy.get_name() + + # this is (usually) the name of the remote process + self.proc_name = self.proxy.props.name + + self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) + + self.image = Gtk.Image(hexpand=True) + self.image.show() + self.label = Gtk.Label(no_show_all=True) + self.box.pack_start(self.image, True, False, 0) + self.box.pack_start(self.label, False, False, 0) + self.add(self.box) + + self.set_can_default(False) + self.set_can_focus(False) + self.set_relief(Gtk.ReliefStyle.NONE) + self.set_focus_on_click(False) + + flags = GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE + + self.proxy.bind_property("label", self.label, "label", flags) + self.proxy.bind_property("tooltip-text", self, "tooltip-text", flags) + self.proxy.bind_property("visible", self, "visible", flags) + + self.proxy.connect("notify::icon-name", self._on_icon_name_changed) + + self.in_widget = False + self.plain_surface = None + self.saturated_surface = None + + self.connect("button-press-event", self.on_button_press) + self.connect("button-release-event", self.on_button_release) + self.connect("enter-notify-event", self.on_enter_notify) + self.connect("leave-notify-event", self.on_leave_notify) + + self.update_orientation() + self.update_icon() + + self.show_all() + + def _on_icon_name_changed(self, proxy, gparamspec, data=None): + self.update_icon() + + def update_icon(self): + string = self.proxy.props.icon_name + + self.set_icon(string) + + def update_style(self, orientation): + ctx = self.get_style_context() + + if orientation == Gtk.Orientation.HORIZONTAL: + ctx.remove_class("statuswidget-vertical") + ctx.add_class("statuswidget-horizontal") + else: + ctx.remove_class("statuswidget-horizontal") + ctx.add_class("statuswidget-vertical") + + def update_orientation(self): + if self.orientation in (MatePanelApplet.AppletOrient.UP, MatePanelApplet.AppletOrient.DOWN): + box_orientation = Gtk.Orientation.HORIZONTAL + else: + box_orientation = Gtk.Orientation.VERTICAL + + self.update_style(box_orientation) + self.box.set_orientation(box_orientation) + + if len(self.label.props.label) > 0 and box_orientation == Gtk.Orientation.HORIZONTAL: + self.label.set_visible(True) + self.label.set_margin_start(VISIBLE_LABEL_MARGIN) + else: + self.label.set_visible(False) + self.label.set_margin_start(0) + + def set_icon(self, string): + size = self.size - ICON_SIZE_REDUCTION + + self.image.set_pixel_size(size) + + fallback = True + + if string: + try: + if os.path.exists(string): + icon_file = Gio.File.new_for_path(string) + icon = Gio.FileIcon.new(icon_file) + self.image.set_from_gicon(icon, Gtk.IconSize.MENU) + else: + if self.theme.has_icon(string): + icon = Gio.ThemedIcon.new(string) + self.image.set_from_gicon(icon, Gtk.IconSize.MENU) + + fallback = False + except GLib.Error as e: + print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, e.message)) + except TypeError as e: + print("MateXAppStatusApplet: Could not load icon '%s' for '%s': %s" % (string, self.proc_name, str(e))) + + #fallback + if fallback: + self.image.set_from_icon_name("image-missing", Gtk.IconSize.MENU) + + # TODO? + def on_enter_notify(self, widget, event): + self.in_widget = True + + return Gdk.EVENT_PROPAGATE + + def on_leave_notify(self, widget, event): + self.in_widget = False + + return Gdk.EVENT_PROPAGATE + # /TODO + + def after_release_idle(self, data=None): + self.set_active(False) + + return GLib.SOURCE_REMOVE + + def on_button_press(self, widget, event): + orientation = translate_applet_orientation_to_xapp(self.orientation) + + x, y = self.calc_menu_origin(widget, orientation) + self.proxy.call_button_press(x, y, event.button, event.time, orientation, None, None) + + if event.button != Gdk.BUTTON_PRIMARY: + self.set_active(True) + + if event.button in (Gdk.BUTTON_MIDDLE, Gdk.BUTTON_SECONDARY): + # Block the 'remove from panel' menu, and the middle-click drag. + # They can still accomplish these things along the edges of the applet + return Gdk.EVENT_STOP + + return Gdk.EVENT_PROPAGATE + + def on_button_release(self, widget, event): + orientation = translate_applet_orientation_to_xapp(self.orientation) + + x, y = self.calc_menu_origin(widget, orientation) + self.proxy.call_button_release(x, y, event.button, event.time, orientation, None, None) + + GObject.timeout_add(200, self.after_release_idle) + + return Gdk.EVENT_PROPAGATE + + def calc_menu_origin(self, widget, orientation): + alloc = widget.get_allocation() + ignore, x, y = widget.get_window().get_origin() + rx = 0 + ry = 0 + + if orientation == Gtk.PositionType.TOP: + rx = x + alloc.x + ry = y + alloc.y + alloc.height + elif orientation == Gtk.PositionType.BOTTOM: + rx = x + alloc.x + ry = y + alloc.y + elif orientation == Gtk.PositionType.LEFT: + rx = x + alloc.x + alloc.width + ry = y + alloc.y + elif orientation == Gtk.PositionType.RIGHT: + rx = x + alloc.x + ry = y + alloc.y + else: + rx = x + ry = y + + return rx, ry + +class MateXAppStatusApplet(object): + def __init__(self, applet, iid): + self.applet = applet + self.applet.set_flags(MatePanelApplet.AppletFlags.EXPAND_MINOR | + MatePanelApplet.AppletFlags.HAS_HANDLE) + self.applet.set_can_focus(False) + self.applet.set_background_widget(self.applet) + + self.add_about() + + button_css = Gtk.CssProvider() + + if button_css.load_from_data(statusicon_css_string.encode()): + Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), button_css, 600) + + self.applet.connect("realize", self.on_applet_realized) + self.applet.connect("destroy", self.on_applet_destroy) + + self.indicators = {} + self.monitor = None + + def add_about(self): + group = Gtk.ActionGroup(name="xapp-status-applet-group") + group.set_translation_domain("xapp") + + about_action = Gtk.Action(name="ShowAbout", + icon_name="info", + label=_("About"), + visible=True) + + about_action.connect("activate", self.show_about) + group.add_action(about_action) + + xml = '\ + \ + ' + + self.applet.setup_menu(xml, group) + + def show_about(self, action, data=None): + dialog = Gtk.AboutDialog.new() + + dialog.set_program_name("XApp Status Applet") + dialog.set_version(applet_constants.PKGVERSION) + dialog.set_license_type(Gtk.License.GPL_3_0) + dialog.set_website("https://github.com/linuxmint/xapps") + dialog.set_logo_icon_name("panel-applets") + dialog.set_comments(_("Area where XApp status icons appear")) + + dialog.run() + dialog.destroy() + + def on_applet_realized(self, widget, data=None): + self.indicator_box = Gtk.Box(visible=True) + + self.applet.add(self.indicator_box) + self.applet.connect("change-size", self.on_applet_size_changed) + self.applet.connect("change-orient", self.on_applet_orientation_changed) + self.update_orientation() + + if not self.monitor: + self.setup_monitor() + + def on_applet_destroy(self, widget, data=None): + self.destroy_monitor() + Gtk.main_quit() + + def setup_monitor (self): + self.monitor = XApp.StatusIconMonitor() + self.monitor.connect("icon-added", self.on_icon_added) + self.monitor.connect("icon-removed", self.on_icon_removed) + + def destroy_monitor (self): + for key in self.indicators.keys(): + self.indicator_box.remove(self.indicators[key]) + + self.monitor = None + self.indicators = {} + + def on_icon_added(self, monitor, proxy): + name = proxy.get_name() + + self.indicators[name] = StatusWidget(proxy, self.applet.get_orient(), self.applet.get_size()) + self.indicator_box.add(self.indicators[name]) + + self.sort_icons() + + def on_icon_removed(self, monitor, proxy): + name = proxy.get_name() + + self.indicator_box.remove(self.indicators[name]) + del(self.indicators[name]) + + self.sort_icons() + + def update_orientation(self): + self.on_applet_orientation_changed(self, self.applet.get_orient()) + + def on_applet_size_changed(self, applet, size, data=None): + for key in self.indicators.keys(): + indicator = self.indicators[key] + + indicator.size = applet.get_size() + indicator.update_icon() + + self.applet.queue_resize() + + def on_applet_orientation_changed(self, applet, applet_orient, data=None): + orient = self.applet.get_orient() + + for key in self.indicators.keys(): + indicator = self.indicators[key] + + indicator.orientation = orient + indicator.update_orientation() + + box_orientation = Gtk.Orientation.HORIZONTAL + + if orient in (MatePanelApplet.AppletOrient.LEFT, MatePanelApplet.AppletOrient.RIGHT): + box_orientation = Gtk.Orientation.VERTICAL + + self.indicator_box.set_orientation(box_orientation) + self.indicator_box.queue_resize() + + def sort_icons(self): + icon_list = list(self.indicators.values()) + + # for i in icon_list: + # print("before: ", i.proxy.props.icon_name, i.proxy.props.name.lower()) + + icon_list.sort(key=lambda icon: icon.proxy.props.name.lower()) + icon_list.sort(key=lambda icon: icon.proxy.props.icon_name.lower().endswith("symbolic")) + + # for i in icon_list: + # print("after: ", i.proxy.props.icon_name, i.proxy.props.name.lower()) + + icon_list.reverse() + + for icon in icon_list: + self.indicator_box.reorder_child(icon, 0) + +def applet_factory(applet, iid, data): + MateXAppStatusApplet(applet, iid) + applet.show() + return True + +def quit_all(widget): + Gtk.main_quit() + sys.exit(0) + +MatePanelApplet.Applet.factory_main("MateXAppStatusAppletFactory", True, + MatePanelApplet.Applet.__gtype__, + applet_factory, None) diff --git a/status-applets/mate/meson.build b/status-applets/mate/meson.build new file mode 100644 index 0000000..1b6a66b --- /dev/null +++ b/status-applets/mate/meson.build @@ -0,0 +1,57 @@ +## Applet file + +conf = configuration_data() +conf.set('locale', join_paths(get_option('prefix'), get_option('localedir'))) +conf.set('pkgversion', meson.project_version()) + +# Put replacements in a separate file, and import the file into the applet. +# This is mainly to make testing/dev easier - if you put the conf replacement +# strings inside the applet itself, you have to build each time to get a valid +# file (with all replacements made). With this, you can just copy from source, +# and your replacements are already there in this file. +constants_file = configure_file( + input : 'applet_constants.py.in', + output: 'applet_constants.py', + configuration: conf, +) + +libexec_files = [ + constants_file, + 'mate-xapp-status-applet.py' +] + +install_data(libexec_files, + install_dir: join_paths(get_option('libexecdir'), 'xapps') +) + +## DBus service file + +conf = configuration_data() +conf.set('libexec', join_paths(get_option('prefix'), get_option('libexecdir'))) + +service_file = configure_file( + input : 'org.mate.panel.applet.MateXAppStatusAppletFactory.service.in', + output: 'org.mate.panel.applet.MateXAppStatusAppletFactory.service', + configuration: conf, +) + +install_data(service_file, + install_dir: join_paths(get_option('datadir'), 'dbus-1', 'services') +) + +## Applet definition file + +def_file = configure_file( + input: 'org.x.MateXAppStatusApplet.mate-panel-applet.in.in', + output: 'org.x.MateXAppStatusApplet.mate-panel-applet.in', + configuration: conf, +) + +i18n.merge_file( + input: def_file, + output: 'org.x.MateXAppStatusApplet.mate-panel-applet', + type: 'desktop', + po_dir: join_paths(meson.source_root(), 'po'), + install: true, + install_dir: join_paths(get_option('datadir'), 'mate-panel', 'applets') +) diff --git a/status-applets/mate/org.mate.panel.applet.MateXAppStatusAppletFactory.service.in b/status-applets/mate/org.mate.panel.applet.MateXAppStatusAppletFactory.service.in new file mode 100644 index 0000000..78a4827 --- /dev/null +++ b/status-applets/mate/org.mate.panel.applet.MateXAppStatusAppletFactory.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.mate.panel.applet.MateXAppStatusAppletFactory +Exec=@libexec@/xapps/mate-xapp-status-applet.py diff --git a/status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in.in b/status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in.in new file mode 100644 index 0000000..b1476cb --- /dev/null +++ b/status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in.in @@ -0,0 +1,13 @@ +[Applet Factory] +Id=MateXAppStatusAppletFactory +InProcess=false +Location=@libexec@/xapps/mate-xapp-status-applet.py +Name=XApp Status Applet Factory +Description=Area where XApp status icons appear + +[MateXAppStatusApplet] +Name=XApp Status Applet +Description=Area where XApp status icons appear +Icon=panel-applets +MateComponentId=OAFIID:MATE_MateXAppStatusApplet; + diff --git a/status-applets/meson.build b/status-applets/meson.build new file mode 100644 index 0000000..979682e --- /dev/null +++ b/status-applets/meson.build @@ -0,0 +1 @@ +subdir('mate') diff --git a/test-scripts/xapp-icon-chooser-dialog b/test-scripts/xapp-icon-chooser-dialog index d264553..b316edb 100755 --- a/test-scripts/xapp-icon-chooser-dialog +++ b/test-scripts/xapp-icon-chooser-dialog @@ -28,7 +28,7 @@ args = parser.parse_args() - dialog = XApp.IconChooserDialog(allow_paths=args.paths) + dialog = XApp.IconChooserDialog(allow_paths=args.paths, default_icon='folder') dialog.set_skip_taskbar_hint(False) if args.category: response = dialog.run_with_category(args.category) diff --git a/test-scripts/xapp-status-applet b/test-scripts/xapp-status-applet new file mode 100755 index 0000000..8d0fd9e --- /dev/null +++ b/test-scripts/xapp-status-applet @@ -0,0 +1,169 @@ +#!/usr/bin/python3 +import gi +gi.require_version('Gtk', '3.0') +gi.require_version('XApp', '1.0') +from gi.repository import Gio, GLib, GObject, Gtk, XApp +import os +import sys + +DBUS_NAME = "org.x.StatusIcon" +DBUS_PATH = "/org/x/StatusIcon" + +class StatusWidget(Gtk.Button): + + def __init__(self, icon): + super(Gtk.Button, self).__init__() + + self.proxy = icon + self.name = self.proxy.get_name() + + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) + + self.image = Gtk.Image() + self.label = Gtk.Label() + box.pack_start(self.image, False, False, 6) + box.add(self.label) + self.add(box) + + flags = GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE + + self.image.props.icon_size = Gtk.IconSize.DIALOG + self.set_icon(self.proxy.props.icon_name) + self.proxy.bind_property("label", self.label, "label", flags) + self.proxy.bind_property("tooltip-text", self, "tooltip-text", flags) + self.proxy.bind_property("visible", self, "visible", flags) + + self.proxy.connect("notify::icon-name", self.on_icon_name_changed) + + self.connect("button-press-event", self.on_button_press) + self.connect("button-release-event", self.on_button_release) + + def on_icon_name_changed(self, proxy, gparamspec, data=None): + string = self.proxy.props.icon_name + + self.set_icon(string) + + def set_icon(self, string): + if string: + if string and os.path.exists(string): + self.image.set_from_file(string) + else: + self.image.set_from_icon_name(string, Gtk.IconSize.DIALOG) + else: + self.image.set_from_icon_name("image-missing", Gtk.IconSize.DIALOG) + + def on_button_press(self, widget, event): + # We're simulating a top panel here + alloc = widget.get_allocation() + ignore, x, y = widget.get_window().get_origin() + + x += alloc.x + y += alloc.y + alloc.height + time = event.time + print ("Button press : %d:%d" % (x, y)) + self.proxy.call_button_press_sync(x, y, event.button, event.time, Gtk.PositionType.TOP, None) + + def on_button_release(self, widget, event): + # We're simulating a top panel here + alloc = widget.get_allocation() + ignore, x, y = widget.get_window().get_origin() + + x += alloc.x + y += alloc.y + alloc.height + time = event.time + print ("Button release : %d:%d" % (x, y)) + self.proxy.call_button_release_sync(x, y, event.button, event.time, Gtk.PositionType.TOP, None) + +class StatusApplet(GObject.Object): + + def __init__(self): + super(StatusApplet, self).__init__() + + self.window = Gtk.Window() + self.window.set_accept_focus (False) + self.window.connect("destroy", self.on_window_destroy) + + self.main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, + margin=6, + spacing=6) + self.window.add(self.main_box) + + self.disco_button = Gtk.Button() + self.main_box.pack_start(self.disco_button, False, False, 0) + self.disco_button.connect("clicked", self.on_disco_button_clicked) + + self.indicator_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, + spacing=6) + self.main_box.pack_start(self.indicator_box, False, False, 0) + + self.indicators = {} + + self.monitor = None + self.setup_monitor() + + self.window.show_all() + + def on_window_destroy(self, widget, data=None): + self.destroy_monitor() + Gtk.main_quit() + + def on_disco_button_clicked(self, widget, data=None): + if self.monitor == None: + self.setup_monitor () + else: + self.destroy_monitor() + + def setup_monitor (self): + self.monitor = XApp.StatusIconMonitor() + self.monitor.connect("icon-added", self.on_icon_added) + self.monitor.connect("icon-removed", self.on_icon_removed) + + self.disco_button.set_label("Disconnect monitor") + + def destroy_monitor (self): + for key in self.indicators.keys(): + self.indicator_box.remove(self.indicators[key]) + + self.monitor = None + self.indicators = {} + + self.disco_button.set_label("Connect monitor") + + def on_icon_added(self, monitor, proxy): + name = proxy.get_name() + + self.indicators[name] = StatusWidget(proxy) + self.indicator_box.add(self.indicators[name]) + self.window.show_all() + + self.sort_icons() + + def on_icon_removed(self, monitor, proxy): + name = proxy.get_name() + + self.indicator_box.remove(self.indicators[name]) + del(self.indicators[name]) + + self.sort_icons() + + def sort_icons(self, status_icon=None): + icon_list = list(self.indicators.values()) + + # for i in icon_list: + # print("before: ", i.proxy.props.icon_name, i.proxy.props.name.lower()) + + icon_list.sort(key=lambda icon: icon.proxy.props.name.lower()) + icon_list.sort(key=lambda icon: icon.proxy.props.icon_name.lower().endswith("symbolic")) + + # for i in icon_list: + # print("after: ", i.proxy.props.icon_name, i.proxy.props.name.lower()) + + icon_list.reverse() + + for icon in icon_list: + self.indicator_box.reorder_child(icon, 0) + +if __name__ == '__main__': + applet = StatusApplet() + Gtk.main() + sys.exit(0) \ No newline at end of file diff --git a/test-scripts/xapp-status-icon-variants/xapp-status-icon-activate-and-menu b/test-scripts/xapp-status-icon-variants/xapp-status-icon-activate-and-menu new file mode 100755 index 0000000..164739c --- /dev/null +++ b/test-scripts/xapp-status-icon-variants/xapp-status-icon-activate-and-menu @@ -0,0 +1,59 @@ +#!/usr/bin/python3 + +import gi +gi.require_version('XApp', '1.0') +from gi.repository import XApp, Gtk, Gdk +from gi.repository import GLib, GObject +import sys + +""" +This variant tests behavior of giving a only a secondary menu to the StatusIcon instance. +This results in 'activate' signals being sent for primary clicks only. +""" + +class App(GObject.Object): + + def __init__(self): + super(App, self).__init__() + self.status_icon = XApp.StatusIcon() + self.status_icon.connect("state-changed", self.on_icon_state_changed) + + self.status_icon.set_icon_name("folder-symbolic") + self.status_icon.set_tooltip_text("Testing primary activate and secondary menu") + self.status_icon.set_label("label 1") + self.status_icon.set_visible(True) + + self.counter = 1 + + menu = Gtk.Menu() + menu.append(Gtk.MenuItem.new_with_label("Hi, secondary menu here!")) + menu.append(Gtk.SeparatorMenuItem()) + menu.append(Gtk.MenuItem.new_with_label("Help me!")) + menu.show_all() + + self.status_icon.set_secondary_menu(menu) + self.status_icon.connect("activate", self.on_status_icon_activate) + + GLib.timeout_add_seconds(2, self.on_timeout_cb) + + def on_icon_state_changed(self, icon, new_state): + print("Icon state changed - the state is now: %s" % new_state) + + def on_timeout_cb(self): + self.counter += 1 + self.status_icon.set_label("label %d" % self.counter) + return True + + def on_status_icon_activate(self, icon, button, time): + print("Activated via button %d" % button) + self.counter = 0 + self.status_icon.set_label("label %d" % self.counter) + +if __name__ == '__main__': + GLib.setenv ("G_MESSAGES_DEBUG", "all", True) + app = App() + try: + GLib.MainLoop().run() + except KeyboardInterrupt: + pass + sys.exit(0) diff --git a/test-scripts/xapp-status-icon-variants/xapp-status-icon-ai b/test-scripts/xapp-status-icon-variants/xapp-status-icon-ai new file mode 100755 index 0000000..c5680ca --- /dev/null +++ b/test-scripts/xapp-status-icon-variants/xapp-status-icon-ai @@ -0,0 +1,63 @@ +#!/usr/bin/python3 + +import gi +gi.require_version('AppIndicator3', '0.1') +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk, Gdk, AppIndicator3 +from gi.repository import GLib, GObject +import sys + +""" +This variant tests behavior of a program using mint-patched AppIndicator, which will fall +back to XAppStatusIcon if there is no AppIndicator support in the desktop environment. +AppIndicator expects both left- and right-click to display the menu, so internally, AppIndicator +sets both primary and secondary menus on the XAppStatusIcon. +""" + +class App(GObject.Object): + def __init__(self): + super(App, self).__init__() + self.indicator = AppIndicator3.Indicator.new("xapp-status-icon-via-libappindicator", + "info", + AppIndicator3.IndicatorCategory.SYSTEM_SERVICES) + self.indicator.set_icon_full("info", "Everything is fine.") + self.indicator.set_label("AppIndicator3 1", "AppIndicator3 1000") + self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) + self.indicator.set_title("Testing patched appindicator fallback to XApp.StatusIcon") + self.counter = 1 + + self.menu = Gtk.Menu() + secondary_activation_item = Gtk.MenuItem.new_with_label("Activate target (middle click)") + secondary_activation_item.connect("activate", self.activate_window) + self.indicator.set_secondary_activate_target(secondary_activation_item) + + self.menu.append(secondary_activation_item) + self.menu.append(Gtk.MenuItem.new_with_label("Engage the hyperdrive")) + self.menu.append(Gtk.SeparatorMenuItem()) + self.menu.append(Gtk.MenuItem.new_with_label("It's a trap!")) + self.menu.show_all() + + self.indicator.set_menu(self.menu) + + GLib.timeout_add_seconds(2, self.on_timeout_cb) + + def activate_window(self, item, data=None): + w = Gtk.Window(default_width=300, default_height=130) + b = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + w.add(b) + b.pack_start(Gtk.Label("How can I help you?"), True, True, 0) + w.show_all() + + def on_timeout_cb(self): + self.counter += 1 + self.indicator.set_label("AppIndicator3 %d" % self.counter, "AppIndicator3 1000") + return True + +if __name__ == '__main__': + GLib.setenv ("G_MESSAGES_DEBUG", "all", True) + app = App() + try: + GLib.MainLoop().run() + except KeyboardInterrupt: + pass + sys.exit(0) diff --git a/test-scripts/xapp-status-icon-variants/xapp-status-icon-all-menus b/test-scripts/xapp-status-icon-variants/xapp-status-icon-all-menus new file mode 100755 index 0000000..2da0a02 --- /dev/null +++ b/test-scripts/xapp-status-icon-variants/xapp-status-icon-all-menus @@ -0,0 +1,61 @@ +#!/usr/bin/python3 + +import gi +gi.require_version('XApp', '1.0') +from gi.repository import XApp, Gtk, Gdk +from gi.repository import GLib, GObject +import sys + +""" +This variant tests behavior of giving primary and secondary menus to the StatusIcon instance. +The instance handles all menu-related things internally. There is no activation signal. +""" + +class App(GObject.Object): + + def __init__(self): + super(App, self).__init__() + self.status_icon = XApp.StatusIcon() + self.status_icon.connect("state-changed", self.on_icon_state_changed) + + self.status_icon.set_icon_name("folder-symbolic") + self.status_icon.set_tooltip_text("Testing primary and secondary menus") + self.status_icon.set_label("label 1") + self.status_icon.set_visible(True) + + self.counter = 1 + + menu = Gtk.Menu() + menu.append(Gtk.MenuItem.new_with_label("Engage the hyperdrive")) + menu.append(Gtk.SeparatorMenuItem()) + menu.append(Gtk.MenuItem.new_with_label("It's a trap!")) + menu.show_all() + + self.status_icon.set_primary_menu(menu) + + menu = Gtk.Menu() + menu.append(Gtk.MenuItem.new_with_label("Hi, secondary menu here!")) + menu.append(Gtk.SeparatorMenuItem()) + menu.append(Gtk.MenuItem.new_with_label("Help me!")) + menu.show_all() + + self.status_icon.set_secondary_menu(menu) + + GLib.timeout_add_seconds(2, self.on_timeout_cb) + + def on_icon_state_changed(self, icon, new_state): + print("Icon state changed - the state is now: %s" % new_state) + + def on_timeout_cb(self): + self.counter += 1 + self.status_icon.set_label("label %d" % self.counter) + return True + +if __name__ == '__main__': + GLib.setenv ("G_MESSAGES_DEBUG", "all", True) + app = App() + try: + GLib.MainLoop().run() + except KeyboardInterrupt: + pass + sys.exit(0) diff --git a/test-scripts/xapp-status-icon-variants/xapp-status-icon-no-menus b/test-scripts/xapp-status-icon-variants/xapp-status-icon-no-menus new file mode 100755 index 0000000..fc21f26 --- /dev/null +++ b/test-scripts/xapp-status-icon-variants/xapp-status-icon-no-menus @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +import gi +gi.require_version('XApp', '1.0') +from gi.repository import XApp, Gtk, Gdk +from gi.repository import GLib, GObject +import sys + +""" +This variant tests behavior of providing no menus to the StatusIcon instance. +This results in 'activate' signals being sent for all button presses. +""" + +class App(GObject.Object): + + def __init__(self): + super(App, self).__init__() + self.status_icon = XApp.StatusIcon() + self.status_icon.connect("state-changed", self.on_icon_state_changed) + + self.status_icon.set_icon_name("folder-symbolic") + self.status_icon.set_tooltip_text("Testing primary activate and secondary menu") + self.status_icon.set_label("label 1") + self.status_icon.set_visible(True) + + self.counter = 1 + + self.status_icon.connect("activate", self.on_status_icon_activate) + + GLib.timeout_add_seconds(2, self.on_timeout_cb) + + def on_icon_state_changed(self, icon, new_state): + print("Icon state changed - the state is now: %s" % new_state) + + def on_timeout_cb(self): + self.counter += 1 + self.status_icon.set_label("label %d" % self.counter) + return True + + def on_status_icon_activate(self, icon, button, time): + print("Activated via button %d" % button) + self.counter = 0 + self.status_icon.set_label("label %d" % self.counter) + +if __name__ == '__main__': + GLib.setenv ("G_MESSAGES_DEBUG", "all", True) + app = App() + try: + GLib.MainLoop().run() + except KeyboardInterrupt: + pass + sys.exit(0) diff --git a/test-scripts/xapp-status-icon-variants/xapp-status-icon-raw-events b/test-scripts/xapp-status-icon-variants/xapp-status-icon-raw-events new file mode 100755 index 0000000..6ac352d --- /dev/null +++ b/test-scripts/xapp-status-icon-variants/xapp-status-icon-raw-events @@ -0,0 +1,74 @@ +#!/usr/bin/python3 + +import gi +gi.require_version('XApp', '1.0') +from gi.repository import XApp, Gtk, Gdk +from gi.repository import GLib, GObject +import sys + +""" +This variant tests button-press-event and button-release-event with no menus assigned - +it must do all menu handling itself. +""" + +class App(GObject.Object): + + def __init__(self): + super(App, self).__init__() + self.status_icon = XApp.StatusIcon() + self.status_icon.connect("state-changed", self.on_icon_state_changed) + + self.status_icon.set_icon_name("folder-symbolic") + self.status_icon.set_tooltip_text("Testing raw button press and release events") + self.status_icon.set_label("label 1") + self.status_icon.set_visible(True) + + self.counter = 1 + + self.menu = Gtk.Menu() + self.menu.append(Gtk.MenuItem.new_with_label("Engage the hyperdrive")) + self.menu.append(Gtk.SeparatorMenuItem()) + self.menu.append(Gtk.MenuItem.new_with_label("It's a trap!")) + self.menu.show_all() + + self.status_icon.connect("button-press-event", self.on_button_press) + self.status_icon.connect("button-release-event", self.on_button_release) + + GLib.timeout_add_seconds(2, self.on_timeout_cb) + + def on_icon_state_changed(self, icon, new_state): + print("Icon state changed - the state is now: %s" % new_state) + + def on_timeout_cb(self): + self.counter += 1 + self.status_icon.set_label("label %d" % self.counter) + return True + + def on_button_press(self, status_icon, x, y, button, time, position_type): + print("Mouse button %d was pressed at %d %d" % (button, x, y)) + self.counter = 0 + self.status_icon.set_label("label %d" % self.counter) + + def on_button_release(self, status_icon, x, y, button, time, position_type): + print("Mouse button %d was released at %d %d" % (button, x, y)) + if button == 3: + def position_menu_cb(menu, pointer_x, pointer_y, user_data): + [x, y, position] = user_data; + if (position_type == Gtk.PositionType.BOTTOM): + y = y - menu.get_allocation().height; + if (position_type == Gtk.PositionType.RIGHT): + x = x - menu.get_allocation().width; + return (x, y, False) + + device = Gdk.Display.get_default().get_device_manager().get_client_pointer() + + self.menu.popup_for_device(device, None, None, position_menu_cb, [x, y, position_type], button, 0) + +if __name__ == '__main__': + GLib.setenv ("G_MESSAGES_DEBUG", "all", True) + app = App() + try: + GLib.MainLoop().run() + except KeyboardInterrupt: + pass + sys.exit(0) diff --git a/xapp.pot b/xapp.pot index d9e0f11..1e787cd 100644 --- a/xapp.pot +++ b/xapp.pot @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-11-15 10:11+0000\n" +"POT-Creation-Date: 2019-11-12 11:04+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,105 +17,143 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: libxapp/xapp-icon-chooser-button.c:162 -#: libxapp/xapp-icon-chooser-dialog.c:601 +#: libxapp/xapp-icon-chooser-button.c:207 +#: libxapp/xapp-icon-chooser-dialog.c:613 msgid "Icon size" msgstr "" -#: libxapp/xapp-icon-chooser-button.c:163 -#: libxapp/xapp-icon-chooser-dialog.c:602 +#: libxapp/xapp-icon-chooser-button.c:208 +#: libxapp/xapp-icon-chooser-dialog.c:614 msgid "The preferred icon size." msgstr "" -#: libxapp/xapp-icon-chooser-button.c:177 +#: libxapp/xapp-icon-chooser-button.c:222 msgid "Icon" msgstr "" -#: libxapp/xapp-icon-chooser-button.c:178 +#: libxapp/xapp-icon-chooser-button.c:223 msgid "The string representing the icon." msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:93 +#: libxapp/xapp-icon-chooser-button.c:234 +msgid "Category" +msgstr "" + +#: libxapp/xapp-icon-chooser-button.c:235 +msgid "The default category." +msgstr "" + +#: libxapp/xapp-icon-chooser-dialog.c:95 msgid "Actions" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:96 +#: libxapp/xapp-icon-chooser-dialog.c:98 msgid "Applications" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:99 +#: libxapp/xapp-icon-chooser-dialog.c:101 msgid "Categories" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:102 +#: libxapp/xapp-icon-chooser-dialog.c:104 msgid "Devices" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:105 +#: libxapp/xapp-icon-chooser-dialog.c:107 msgid "Emblems" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:108 +#: libxapp/xapp-icon-chooser-dialog.c:110 msgid "Emoji" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:111 +#: libxapp/xapp-icon-chooser-dialog.c:113 msgid "Mime types" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:114 +#: libxapp/xapp-icon-chooser-dialog.c:116 msgid "Places" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:117 +#: libxapp/xapp-icon-chooser-dialog.c:119 msgid "Status" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:120 +#: libxapp/xapp-icon-chooser-dialog.c:122 msgid "Other" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:449 +#: libxapp/xapp-icon-chooser-dialog.c:451 msgid "Choose an icon" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:471 +#: libxapp/xapp-icon-chooser-dialog.c:473 msgid "Search" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:478 +#: libxapp/xapp-icon-chooser-dialog.c:480 msgid "Browse" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:534 +#: libxapp/xapp-icon-chooser-dialog.c:536 msgid "Loading..." msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:558 +#: libxapp/xapp-icon-chooser-dialog.c:560 +msgid "Default" +msgstr "" + +#: libxapp/xapp-icon-chooser-dialog.c:570 msgid "Select" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:567 -#: libxapp/xapp-icon-chooser-dialog.c:1787 +#: libxapp/xapp-icon-chooser-dialog.c:579 +#: libxapp/xapp-icon-chooser-dialog.c:1937 msgid "Cancel" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:614 +#: libxapp/xapp-icon-chooser-dialog.c:626 msgid "Allow Paths" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:615 +#: libxapp/xapp-icon-chooser-dialog.c:627 msgid "Whether to allow paths." msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:1784 +#: libxapp/xapp-icon-chooser-dialog.c:638 +msgid "Default Icon" +msgstr "" + +#: libxapp/xapp-icon-chooser-dialog.c:639 +msgid "The icon to use by default" +msgstr "" + +#: libxapp/xapp-icon-chooser-dialog.c:1934 msgid "Select image file" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:1789 +#: libxapp/xapp-icon-chooser-dialog.c:1939 msgid "Open" msgstr "" -#: libxapp/xapp-icon-chooser-dialog.c:1804 +#: libxapp/xapp-icon-chooser-dialog.c:1954 msgid "Image" msgstr "" + +#: status-applets/mate/mate-xapp-status-applet.py:260 +msgid "About" +msgstr "" + +#: status-applets/mate/mate-xapp-status-applet.py:280 +#: status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in:7 +#: status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in:11 +msgid "Area where XApp status icons appear" +msgstr "" + +#: status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in:6 +msgid "XApp Status Applet Factory" +msgstr "" + +#: status-applets/mate/org.x.MateXAppStatusApplet.mate-panel-applet.in:10 +msgid "XApp Status Applet" +msgstr ""