Skip to content
Permalink
Browse files

cpu-freq: replace deprecated gtk_menu_popup

  • Loading branch information...
raveit65 committed Jul 7, 2018
1 parent d3bf8fd commit 3cd2d150036b7a3d5286bae02e7c45e4f689c4d5
Showing with 5 additions and 52 deletions.
  1. +5 −52 cpufreq/src/cpufreq-applet.c
@@ -301,54 +301,6 @@ get_max_text_width (GtkWidget *widget,
return logical_rect.width;
}

static void
cpufreq_applet_popup_position_menu (GtkMenu *menu,
int *x,
int *y,
gboolean *push_in,
gpointer gdata)
{
GtkWidget *widget;
GtkRequisition requisition;
GtkAllocation allocation;
gint menu_xpos;
gint menu_ypos;

widget = GTK_WIDGET (gdata);

gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);

gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos);

gtk_widget_get_allocation (widget, &allocation);

menu_xpos += allocation.x;
menu_ypos += allocation.y;

switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (widget))) {
case MATE_PANEL_APPLET_ORIENT_DOWN:
case MATE_PANEL_APPLET_ORIENT_UP:
if (menu_ypos > HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget))) / 2)
menu_ypos -= requisition.height;
else
menu_ypos += allocation.height;
break;
case MATE_PANEL_APPLET_ORIENT_RIGHT:
case MATE_PANEL_APPLET_ORIENT_LEFT:
if (menu_xpos > WidthOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget))) / 2)
menu_xpos -= requisition.width;
else
menu_xpos += allocation.width;
break;
default:
g_assert_not_reached ();
}

*x = menu_xpos;
*y = menu_ypos;
if (push_in) *push_in = FALSE; /*fix bottom panel menu rendering in gtk3*/
}

static void
cpufreq_applet_menu_popup (CPUFreqApplet *applet,
guint32 time)
@@ -381,10 +333,11 @@ cpufreq_applet_menu_popup (CPUFreqApplet *applet,
gtk_style_context_add_class(context,"gnome-panel-menu-bar");
gtk_style_context_add_class(context,"mate-panel-menu-bar");

gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
cpufreq_applet_popup_position_menu,
(gpointer) applet,
1, time);
gtk_menu_popup_at_widget (GTK_MENU (menu),
GTK_WIDGET (applet),
GDK_GRAVITY_SOUTH_WEST,
GDK_GRAVITY_NORTH_WEST,
NULL);
}

static gboolean

0 comments on commit 3cd2d15

Please sign in to comment.
You can’t perform that action at this time.