diff options
author | Sergios - Anestis Kefalidis <sergioskefalidis@gmail.com> | 2022-02-24 18:56:17 +0200 |
---|---|---|
committer | Alexander Schwinn <alexxcons@xfce.org> | 2022-02-24 20:58:21 +0000 |
commit | 8959a150d067dfcb0dbf89d0fec1da14002c01a1 (patch) | |
tree | ebe1bd1e0425f97ec6d81b38b201f39ae3dd03e0 | |
parent | bd06688363ced819078d7bb0cb222924900ebcbe (diff) | |
download | libxfce4ui-8959a150d067dfcb0dbf89d0fec1da14002c01a1.tar.gz |
XfceShortcutsDialog: New function for centering the dialog on the parent window
-rw-r--r-- | libxfce4kbd-private/xfce-shortcuts-editor-dialog.c | 47 | ||||
-rw-r--r-- | libxfce4kbd-private/xfce-shortcuts-editor-dialog.h | 4 |
2 files changed, 47 insertions, 4 deletions
diff --git a/libxfce4kbd-private/xfce-shortcuts-editor-dialog.c b/libxfce4kbd-private/xfce-shortcuts-editor-dialog.c index 4fc1778..b13e213 100644 --- a/libxfce4kbd-private/xfce-shortcuts-editor-dialog.c +++ b/libxfce4kbd-private/xfce-shortcuts-editor-dialog.c @@ -84,18 +84,57 @@ xfce_shortcuts_editor_dialog_new (int argument_count, ...) { XfceShortcutsEditorDialog *dialog; va_list argument_list; - GdkGeometry windowProperties; va_start (argument_list, argument_count); dialog = g_object_new (XFCE_TYPE_SHORTCUTS_EDITOR_DIALOG, NULL); gtk_window_set_title (GTK_WINDOW (dialog), _("Shortcuts Editor")); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), xfce_shortcuts_editor_new_variadic (argument_count, argument_list), TRUE, TRUE, 0); + + /* set a reasonable default size */ + gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 600); + gtk_widget_show (GTK_WIDGET (dialog)); - windowProperties.min_width = 500; - windowProperties.min_height = 600; - gtk_window_set_geometry_hints(GTK_WINDOW(dialog), NULL, &windowProperties, GDK_HINT_MIN_SIZE); + va_end (argument_list); + + return GTK_WIDGET (dialog); +} + + + +/** + * xfce_shortcuts_editor_dialog_new_with_parent: + * @parent : #GtkWindow, the parent window of the dialog, used in gtk_window_set_transient_for (can be NULL). + * @argument_count : #int, the number of arguments, including this one. + * + * Returns a dialog that includes a XfceShortcutsEditor. + * See xfce_shortcuts_editor_new_variadic for the expected types of the variable argument list. + * + * Since: 4.17.5 + **/ +GtkWidget* +xfce_shortcuts_editor_dialog_new_with_parent (GtkWindow *parent, + int argument_count, + ... ) +{ + XfceShortcutsEditorDialog *dialog; + va_list argument_list; + + va_start (argument_list, argument_count); + + /* create the dialog and its content */ + dialog = g_object_new (XFCE_TYPE_SHORTCUTS_EDITOR_DIALOG, NULL); + gtk_window_set_title (GTK_WINDOW (dialog), _("Shortcuts Editor")); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), xfce_shortcuts_editor_new_variadic (argument_count, argument_list), TRUE, TRUE, 0); + + /* set a reasonable default size */ + gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 600); + + /* center the dialog on top of the parent widget */ + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); + + gtk_widget_show (GTK_WIDGET (dialog)); va_end (argument_list); diff --git a/libxfce4kbd-private/xfce-shortcuts-editor-dialog.h b/libxfce4kbd-private/xfce-shortcuts-editor-dialog.h index 172d7a4..73bbffc 100644 --- a/libxfce4kbd-private/xfce-shortcuts-editor-dialog.h +++ b/libxfce4kbd-private/xfce-shortcuts-editor-dialog.h @@ -41,6 +41,10 @@ GType xfce_shortcuts_editor_dialog_get_type (void) G_GNUC_CONST; GtkWidget *xfce_shortcuts_editor_dialog_new (int argument_count, ...) G_GNUC_MALLOC; +GtkWidget *xfce_shortcuts_editor_dialog_new_with_parent (GtkWindow *parent, + int argument_count, + ... ) G_GNUC_MALLOC; + G_END_DECLS #endif /* !__XFCE_SHORTCUTS_EDITOR_DIALOG_H__ */ |