コード例 #1
0
ファイル: sidebar.c プロジェクト: BYC/geany-plugins
/* delay updating popup menu until the selection has been set */
static gboolean on_button_release(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event,
									G_GNUC_UNUSED gpointer user_data)
{
	if (event->button == 3)
	{
		static GtkWidget *popup_menu = NULL;

		if (popup_menu == NULL)
			popup_menu = create_popup_menu();

		update_popup_menu(popup_menu);

		gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, NULL, NULL,
			       event->button, event->time);
	}
	return FALSE;
}
コード例 #2
0
ファイル: tray_icon.c プロジェクト: andmal/pa-applet
void update_tray_icon(void)
{
    // Yes, we've been updated once now
    updated_once = TRUE;

    // Get the new tray icon name and tooltip text format
    audio_status *as = shared_audio_status();
    gchar *icon_name, *tooltip_text_format;
    if (as->muted) {
        icon_name = "audio-volume-muted";
        tooltip_text_format = "Volume: %d%% (muted)";
    }
    else {
        if (as->volume < 100.0 / 3)
            icon_name = "audio-volume-low";
        else if (as->volume < 100.0 / 3 * 2)
            icon_name = "audio-volume-medium";
        else
            icon_name = "audio-volume-high";
        tooltip_text_format = "Volume: %d%%";
    }

    // Update the icon name
    gtk_status_icon_set_from_icon_name(tray_icon, icon_name);

    // Update the tooltip
    gsize buffer_size = (strlen(tooltip_text_format) + 5) * sizeof(gchar);
    gchar *tooltip_text = g_malloc0(buffer_size);
    if (tooltip_text) {
        g_snprintf(tooltip_text, buffer_size, tooltip_text_format, (int)(as->volume));
        gtk_status_icon_set_tooltip_text(tray_icon, tooltip_text);
        g_free(tooltip_text);
    }

    // Update the volume scale or the popup menu if needed
    if (is_volume_scale_visible())
        update_volume_scale();
    else if (is_popup_menu_visible())
        update_popup_menu();
}