Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace deprecated Gtk image menu item* #391

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ requires:
- upower
- which
- yelp-tools
# mate-desktop dependencies
- iso-codes
- gobject-introspection
- dconf

debian:
# Useful URL: https://github.com/mate-desktop/debian-packages
Expand Down Expand Up @@ -52,6 +56,11 @@ requires:
- pkg-config
- xmlto
- yelp-tools
# mate-desktop dependencies
- iso-codes
- gobject-introspection
- libgirepository1.0-dev
- libdconf-dev

fedora:
# Useful URL: https://src.fedoraproject.org/cgit/rpms/mate-power-manager.git
Expand All @@ -78,6 +87,10 @@ requires:
- popt-devel
- redhat-rpm-config
- upower-devel
# mate-desktop dependencies
- iso-codes-devel
- gobject-introspection-devel
- dconf-devel

ubuntu:
- autoconf-archive
Expand Down Expand Up @@ -105,6 +118,11 @@ requires:
- pkg-config
- xmlto
- yelp-tools
# mate-desktop dependencies
- iso-codes
- gobject-introspection
- libgirepository1.0-dev
- libdconf-dev

variables:
- 'CHECKERS="
Expand All @@ -123,8 +141,25 @@ variables:
-enable-checker alpha.unix.cstring.OutOfBounds
-enable-checker alpha.core.FixedAddr
-enable-checker security.insecureAPI.strcpy"'
- MATE_DESKTOP_VERSION=1.27.1

before_scripts:
- cd ${START_DIR}
- if [ ! -f mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz ];then
- curl -Ls -o mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz https://github.com/mate-desktop/mate-desktop/releases/download/v${MATE_DESKTOP_VERSION}/mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz
- fi
- tar xf mate-desktop-${MATE_DESKTOP_VERSION}.tar.xz
- cd mate-desktop-${MATE_DESKTOP_VERSION}
- if [ ${DISTRO_NAME} == "debian" -o ${DISTRO_NAME} == "ubuntu" ];then
- ./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu
- else
- ./autogen.sh --prefix=/usr
- fi
- if [ ${TRAVIS} == "false" ]; then
- make clean
- fi
- make
- make install

build_scripts:
- if [ ${DISTRO_NAME} == "debian" ];then
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ DBUS_REQUIRED=1.0
DBUS_GLIB_REQUIRED=0.70
LIBNOTIFY_REQUIRED=0.7.0
CAIRO_REQUIRED=1.0.0
MATE_DESKTOP_REQUIRED=1.27.1
LIBPANEL_REQUIRED=1.17.0
XRANDR_REQUIRED=1.3.0
XPROTO_REQUIRED=7.0.15
Expand All @@ -101,6 +102,9 @@ PKG_CHECK_MODULES(GDK, [
gdk-3.0 >= $GDK_REQUIRED
gdk-x11-3.0 >= $GDK_REQUIRED])

PKG_CHECK_MODULES(MATE_DESKTOP, [
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED])

PKG_CHECK_MODULES(X11, [
xrandr >= $XRANDR_REQUIRED
x11 xext xproto >= $XPROTO_REQUIRED])
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(LIBSECRET_CFLAGS) \
$(MATE_DESKTOP_CFLAGS) \
$(KEYRING_CFLAGS) \
$(X11_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
Expand Down Expand Up @@ -198,6 +199,7 @@ mate_power_manager_LDADD = \
$(X11_LIBS) \
$(GSTREAMER_LIBS) \
$(CAIRO_LIBS) \
$(MATE_DESKTOP_LIBS) \
$(LIBSECRET_LIBS) \
$(KEYRING_LIBS) \
$(DBUS_LIBS) \
Expand Down Expand Up @@ -261,6 +263,7 @@ mate_power_self_test_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(CAIRO_LIBS) \
$(MATE_DESKTOP_LIBS) \
$(LIBSECRET_LIBS) \
$(KEYRING_LIBS) \
$(GSTREAMER_LIBS) \
Expand Down
17 changes: 10 additions & 7 deletions src/gpm-tray-icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <gtk/gtk.h>
#include <libupower-glib/upower.h>

#include <libmate-desktop/mate-image-menu-item.h>

#include "gpm-upower.h"
#include "gpm-engine.h"
#include "gpm-common.h"
Expand Down Expand Up @@ -275,13 +277,12 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
else {
label = g_strdup_printf ("%s (%.1f%%)", gpm_device_kind_to_localised_string (kind, 1), percentage);
}
item = gtk_image_menu_item_new_with_label (label);
item = mate_image_menu_item_new_with_label (label);

/* generate the image */
icon_name = gpm_upower_get_device_icon (device);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);

/* set callback and add the menu */
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (gpm_tray_icon_show_info_cb), icon);
Expand Down Expand Up @@ -317,7 +318,7 @@ gpm_tray_icon_add_primary_device (GpmTrayIcon *icon, GtkMenu *menu, UpDevice *de

/* TRANSLATORS: % is a timestring, e.g. "6 hours 10 minutes" */
string = g_strdup_printf (_("%s remaining"), time_str);
item = gtk_image_menu_item_new_with_label (string);
item = mate_image_menu_item_new_with_label (string);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_free (time_str);
g_free (string);
Expand Down Expand Up @@ -371,9 +372,9 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon)
}

/* preferences */
item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
item = mate_image_menu_item_new_with_mnemonic (_("_Preferences"));
image = gtk_image_new_from_icon_name ("preferences-system", GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (gpm_tray_icon_show_preferences_cb), icon);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
Expand All @@ -391,7 +392,9 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon)
gtk_style_context_add_class(context,"mate-panel-menu-bar");

/* about */
item = gtk_image_menu_item_new_from_stock ("gtk-about", NULL);
item = mate_image_menu_item_new_with_mnemonic (_("_About"));
image = gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_MENU);
mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
g_signal_connect (G_OBJECT (item), "activate",
G_CALLBACK (gpm_tray_icon_show_about_cb), icon);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
Expand Down