Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
squeekboard
Commits
4253bf12
Commit
4253bf12
authored
Oct 03, 2020
by
Benjamin Schaaf
Browse files
Add settings option to popover
Fixes #154
parent
50fb124b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/meson.build
View file @
4253bf12
...
...
@@ -14,6 +14,7 @@ sources = [
config_h,
'dbus.c',
'imservice.c',
'popover.c',
'server-context-service.c',
'wayland.c',
'../eek/eek.c',
...
...
src/popover.c
0 → 100644
View file @
4253bf12
#include
<gio/gio.h>
static
void
call_dbus_cb
(
GDBusProxy
*
proxy
,
GAsyncResult
*
res
,
gpointer
user_data
)
{
g_autoptr
(
GError
)
err
=
NULL
;
g_autoptr
(
GVariant
)
output
=
NULL
;
output
=
g_dbus_proxy_call_finish
(
proxy
,
res
,
&
err
);
if
(
err
)
{
g_warning
(
"Can't open panel %s"
,
err
->
message
);
}
g_object_unref
(
proxy
);
}
static
void
create_dbus_proxy_cb
(
GObject
*
source_object
,
GAsyncResult
*
res
,
char
*
panel
)
{
GDBusProxy
*
proxy
;
g_autoptr
(
GError
)
err
=
NULL
;
GVariantBuilder
builder
;
GVariant
*
params
[
3
];
GVariant
*
array
[
1
];
proxy
=
g_dbus_proxy_new_for_bus_finish
(
res
,
&
err
);
if
(
err
!=
NULL
)
{
g_warning
(
"Can't open panel %s: %s"
,
panel
,
err
->
message
);
g_free
(
panel
);
return
;
}
g_variant_builder_init
(
&
builder
,
G_VARIANT_TYPE
(
"av"
));
g_variant_builder_add
(
&
builder
,
"v"
,
g_variant_new_string
(
""
));
array
[
0
]
=
g_variant_new
(
"v"
,
g_variant_new
(
"(sav)"
,
panel
,
&
builder
));
params
[
0
]
=
g_variant_new_string
(
"launch-panel"
);
params
[
1
]
=
g_variant_new_array
(
G_VARIANT_TYPE
(
"v"
),
array
,
1
);
params
[
2
]
=
g_variant_new_array
(
G_VARIANT_TYPE
(
"{sv}"
),
NULL
,
0
);
g_dbus_proxy_call
(
proxy
,
"Activate"
,
g_variant_new_tuple
(
params
,
3
),
G_DBUS_CALL_FLAGS_NONE
,
-
1
,
NULL
,
(
GAsyncReadyCallback
)
call_dbus_cb
,
NULL
);
g_free
(
panel
);
}
void
popover_open_settings_panel
(
char
*
panel
)
{
g_dbus_proxy_new_for_bus
(
G_BUS_TYPE_SESSION
,
G_DBUS_PROXY_FLAGS_NONE
,
NULL
,
"org.gnome.ControlCenter"
,
"/org/gnome/ControlCenter"
,
"org.gtk.Actions"
,
NULL
,
(
GAsyncReadyCallback
)
create_dbus_proxy_cb
,
g_strdup
(
panel
));
}
src/popover.rs
View file @
4253bf12
...
...
@@ -25,6 +25,15 @@ use gtk::WidgetExt;
use
std
::
io
::
Write
;
use
::
logging
::
Warn
;
mod
c
{
use
std
::
os
::
raw
::
c_char
;
#[no_mangle]
extern
"C"
{
pub
fn
popover_open_settings_panel
(
panel
:
*
const
c_char
);
}
}
mod
variants
{
use
glib
;
use
glib
::
Variant
;
...
...
@@ -128,6 +137,12 @@ fn make_menu_builder(inputs: Vec<(&str, OwnedTranslation)>) -> gtk::Builder {
xml
,
"
</section>
<section>
<item>
<attribute name=
\"
label
\"
translatable=
\"
yes
\"
>Keyboard Settings</attribute>
<attribute name=
\"
action
\"
>settings</attribute>
</item>
</section>
</menu>
</interface>"
)
.unwrap
();
...
...
@@ -414,8 +429,14 @@ pub fn show(
menu_inner
.popdown
();
});
let
settings_action
=
gio
::
SimpleAction
::
new
(
"settings"
,
None
);
settings_action
.connect_activate
(
move
|
_
,
_
|
{
unsafe
{
c
::
popover_open_settings_panel
(
CString
::
new
(
"region"
)
.unwrap
()
.as_ptr
())
};
});
let
action_group
=
gio
::
SimpleActionGroup
::
new
();
action_group
.add_action
(
&
layout_action
);
action_group
.add_action
(
&
settings_action
);
menu
.insert_action_group
(
"popup"
,
Some
(
&
action_group
));
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment