fix: bugs in new gtk runtime, adaptive tray icon
This commit is contained in:
@@ -245,12 +245,8 @@ GVariant *sni_get_property(G_GNUC_UNUSED GDBusConnection *connection,
|
||||
return g_variant_new_string("MoeMoji");
|
||||
if (g_strcmp0(property_name, "Status") == 0)
|
||||
return g_variant_new_string("Active");
|
||||
if (g_strcmp0(property_name, "IconName") == 0) {
|
||||
MoeMojiApplication *self = MOEMOJI_APPLICATION(user_data);
|
||||
return g_variant_new_string(self->tray_icon_name
|
||||
? self->tray_icon_name
|
||||
: "jp.angeltech.MoeMoji-tray-dark");
|
||||
}
|
||||
if (g_strcmp0(property_name, "IconName") == 0)
|
||||
return g_variant_new_string("jp.angeltech.MoeMoji-tray-symbolic");
|
||||
if (g_strcmp0(property_name, "ItemIsMenu") == 0)
|
||||
return g_variant_new_boolean(FALSE);
|
||||
if (g_strcmp0(property_name, "Menu") == 0)
|
||||
@@ -269,25 +265,6 @@ static const GDBusInterfaceVTable sni_vtable = {
|
||||
.set_property = NULL,
|
||||
};
|
||||
|
||||
static void update_tray_icon(MoeMojiApplication *self) {
|
||||
AdwStyleManager *sm = adw_style_manager_get_default();
|
||||
gboolean dark = adw_style_manager_get_dark(sm);
|
||||
self->tray_icon_name = dark ? "jp.angeltech.MoeMoji-tray-dark"
|
||||
: "jp.angeltech.MoeMoji-tray-light";
|
||||
|
||||
if (self->dbus_conn && self->sni_registration_id > 0) {
|
||||
g_dbus_connection_emit_signal(self->dbus_conn, NULL, "/StatusNotifierItem",
|
||||
"org.kde.StatusNotifierItem", "NewIcon", NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_dark_changed(G_GNUC_UNUSED GObject *obj,
|
||||
G_GNUC_UNUSED GParamSpec *pspec,
|
||||
gpointer user_data) {
|
||||
update_tray_icon(MOEMOJI_APPLICATION(user_data));
|
||||
}
|
||||
|
||||
static void setup_sni(MoeMojiApplication *self) {
|
||||
GError *error = NULL;
|
||||
self->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
|
||||
@@ -547,9 +524,6 @@ static void moemoji_application_startup(GApplication *app) {
|
||||
}
|
||||
}
|
||||
setup_sni(self);
|
||||
update_tray_icon(self);
|
||||
g_signal_connect(adw_style_manager_get_default(), "notify::dark",
|
||||
G_CALLBACK(on_dark_changed), self);
|
||||
setup_global_shortcuts(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ struct _MoeMojiApplication {
|
||||
guint sni_registration_id;
|
||||
guint menu_registration_id;
|
||||
gchar *icon_theme_path;
|
||||
const gchar *tray_icon_name;
|
||||
GDBusProxy *shortcuts_proxy;
|
||||
gchar *shortcuts_session_path;
|
||||
gboolean has_tray;
|
||||
|
||||
@@ -329,6 +329,7 @@ static void add_kaomoji_button(MoeMojiWindow *self, GtkFlowBox *flow,
|
||||
GtkWidget *button = gtk_button_new_with_label(label_text);
|
||||
gtk_widget_set_halign(button, GTK_ALIGN_FILL);
|
||||
GtkWidget *label = gtk_button_get_child(GTK_BUTTON(button));
|
||||
gtk_widget_add_css_class(label, "kaomoji-label");
|
||||
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
|
||||
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
|
||||
gtk_widget_add_css_class(button, "kaomoji-button");
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.kaomoji-button label {
|
||||
.kaomoji-label {
|
||||
text-align: left;
|
||||
text-shadow:
|
||||
-1px -1px 0 rgba(0, 0, 0, 0.6),
|
||||
|
||||
Reference in New Issue
Block a user