X-Git-Url: http://gitweb.michael.orlitzky.com/?p=xfce4-hdaps.git;a=blobdiff_plain;f=panel-plugin%2Fxfce4-hdaps.c;h=c9d9cb5fe54b659ed4316f597d2fdce6fa2f3945;hp=6f7bcfc4abc9910136a57fa3eead658987970039;hb=6aa7cd4dd55e09b88c6fbd85ed2e9fd7cbe833c2;hpb=7152cba26f7c0d37bb56adc4ab2fa2eae9baa97e diff --git a/panel-plugin/xfce4-hdaps.c b/panel-plugin/xfce4-hdaps.c index 6f7bcfc..c9d9cb5 100644 --- a/panel-plugin/xfce4-hdaps.c +++ b/panel-plugin/xfce4-hdaps.c @@ -69,10 +69,10 @@ void hdaps_set_icon(HdapsPlugin *hdaps, int status) { size = xfce_panel_plugin_get_size(hdaps->plugin) - 6; /* Try to load an icon from the current icon theme. */ - if (status < HDAPS_OFF) { + if (status == HDAPS_ERROR) { /* Error */ icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), - "dialog-error", + "emblem-noread", size, 0, NULL); } else if (status == HDAPS_OFF) { @@ -107,6 +107,21 @@ void hdaps_set_icon(HdapsPlugin *hdaps, int status) { } + +void hdaps_set_tooltip(HdapsPlugin *hdaps, int status) { + + if (status == HDAPS_ERROR) { + gtk_tooltips_set_tip(hdaps->tooltip, hdaps->eventbox, "HDAPS Error", NULL); + } + else if (status == HDAPS_OFF) { + gtk_tooltips_set_tip(hdaps->tooltip, hdaps->eventbox, "HDAPS Off", NULL); + } + else { + gtk_tooltips_set_tip(hdaps->tooltip, hdaps->eventbox, "HDAPS On", NULL); + } +} + + static void hdaps_set_defaults(HdapsPlugin *hdaps) { DBG("Configuring all settings to defaults."); hdaps->device_name = g_strdup(DEFAULT_DEVICE_NAME); @@ -205,6 +220,15 @@ static HdapsPlugin *hdaps_new(XfcePanelPlugin *plugin) { so it's important that they start out n*sync. */ hdaps->previous_status = HDAPS_OFF; hdaps_set_icon(hdaps, HDAPS_OFF); + + /* Create the tooltip widget, and set its initial value. + * The first couple of lines are stolen from the battery + * status plugin. I make no claim as to their correctness. + */ + hdaps->tooltip = gtk_tooltips_new(); + g_object_ref(G_OBJECT(hdaps->tooltip)); + gtk_object_sink(GTK_OBJECT(hdaps->tooltip)); + hdaps_set_tooltip(hdaps, HDAPS_OFF); return hdaps; } @@ -238,6 +262,10 @@ static void hdaps_free(XfcePanelPlugin *plugin, if (G_LIKELY(hdaps->device_name != NULL)) { g_free(hdaps->device_name); } + + /* Goodbye, tooltips. */ + gtk_tooltips_set_tip(hdaps->tooltip, hdaps->eventbox, NULL, NULL); + g_object_unref(G_OBJECT(hdaps->tooltip)); /* ...and finally free the plugin structure. */ panel_slice_free(HdapsPlugin, hdaps); @@ -289,6 +317,7 @@ static gboolean hdaps_update_status(HdapsPlugin *hdaps) { if (status != hdaps->previous_status) { /* And we only update the icon if we need to. */ hdaps_set_icon(hdaps, status); + hdaps_set_tooltip(hdaps, status); hdaps->previous_status = status; }