Beispiel #1
0
//
// Custom the tooltip
//
static gboolean qq_tray_on_show_tooltip(GtkWidget* widget
                                            , int x
                                            , int y
                                            , gboolean keybord_mode
                                            , GtkTooltip* tip
                                            , gpointer data)
{
    GdkPixbuf *pb;
    if(info -> me -> qqnumber == NULL || info -> me -> qqnumber -> len <=0){
        // Not login. 
        pb = gdk_pixbuf_new_from_file_at_size(IMGDIR"/webqq_icon.png"
                                                , 35, 35, NULL);
        gtk_tooltip_set_markup(tip, "<b>GtkQQ</b>"); 
        gtk_tooltip_set_icon(tip, pb);
        g_object_unref(pb);
        return TRUE;
    }
    gchar buf[500];
    g_snprintf(buf, 500, CONFIGDIR"/faces/%s", info -> me -> qqnumber -> str);
    pb = gdk_pixbuf_new_from_file_at_size(buf, 35, 35, NULL);
    gtk_tooltip_set_icon(tip, pb);
    g_object_unref(pb);
    g_snprintf(buf, 500, "<b>%s</b><span color='blue'>(%s)</span>"
                                    , info -> me -> nick -> str
                                    , info -> me -> qqnumber -> str);
    gtk_tooltip_set_markup(tip, buf); 
    return TRUE;
}
Beispiel #2
0
static gboolean gtkQueryTooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, Ihandle* ih)
{
  char* value = iupAttribGet(ih, "TIPRECT");
  if (value && !keyboard_mode)
  {
    GdkRectangle rect;
    int x1, x2, y1, y2;
    sscanf(value, "%d %d %d %d", &x1, &y1, &x2, &y2);
    rect.x = x1;
    rect.y = y1;
    rect.width = x2-x1+1;
    rect.height = y2-y1+1;
    gtk_tooltip_set_tip_area(tooltip, &rect);
  }
  else
    gtk_tooltip_set_tip_area(tooltip, NULL);

  value = iupAttribGet(ih, "TIPICON");
  if (!value)
    gtk_tooltip_set_icon(tooltip, NULL);
  else
  {
    GdkPixbuf* icon = (GdkPixbuf*)iupImageGetIcon(value);
    if (icon)
      gtk_tooltip_set_icon(tooltip, icon);
  }

  (void)y;
  (void)x;
  (void)widget;
  return FALSE;
}
Beispiel #3
0
static gboolean
windows_menu_display_query_tooltip (GtkWidget  *widget,
                                    gint        x,
                                    gint        y,
                                    gboolean    keyboard_mode,
                                    GtkTooltip *tooltip,
                                    GimpAction *action)
{
  GimpImage *image = GIMP_IMAGE (action->viewable);
  gchar     *text;
  gdouble    xres;
  gdouble    yres;
  gint       width;
  gint       height;

  text = gtk_widget_get_tooltip_text (widget);
  gtk_tooltip_set_text (tooltip, text);
  g_free (text);

  gimp_image_get_resolution (image, &xres, &yres);

  gimp_viewable_calc_preview_size (gimp_image_get_width  (image),
                                   gimp_image_get_height (image),
                                   GIMP_VIEW_SIZE_HUGE, GIMP_VIEW_SIZE_HUGE,
                                   FALSE, xres, yres,
                                   &width, &height, NULL);

  gtk_tooltip_set_icon (tooltip,
                        gimp_viewable_get_pixbuf (action->viewable,
                                                  action->context,
                                                  width, height));

  return TRUE;
}
Beispiel #4
0
static void
gtk_tooltip_reset (GtkTooltip *tooltip)
{
  gtk_tooltip_set_markup (tooltip, NULL);
  gtk_tooltip_set_icon (tooltip, NULL);
  gtk_tooltip_set_tip_area (tooltip, NULL);

  /* See if the custom widget is again set from the query-tooltip
   * callback.
   */
  tooltip->custom_was_reset = FALSE;
}
Beispiel #5
0
static gboolean
on_query_tooltip (GtkWidget *widget,
                  gint x, gint y, 
                  gboolean keyboard_mode, 
                  GtkTooltip *tooltip,
                  TaskItem *item)
{
  WnckWindow *window = item->priv->window;
  g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);

  gtk_tooltip_set_text (tooltip, wnck_window_get_name(window));
  gtk_tooltip_set_icon (tooltip, wnck_window_get_icon (window));

  return TRUE;
}
Beispiel #6
0
static gboolean
gnac_ui_query_tooltip_cb(GtkStatusIcon *status_icon,
                         gint           x,
                         gint           y,
                         gboolean       keyboard_mode,
                         GtkTooltip    *tooltip,
                         gpointer       user_data)
{
  GError *error = NULL;
  GFile *tooltip_file = g_file_new_for_uri(tooltip_path);
  LibgnacTags *tags = libgnac_metadata_extract(metadata, tooltip_file, &error);
  if (error) {
    libgnac_debug("Failed to extract metadata for %s: %s",
        tooltip_path, error->message);
    g_clear_error(&error);
  }
  g_object_unref(tooltip_file);

  const gchar *album = libgnac_metadata_tag_exists(tags, GST_TAG_ALBUM) ?
      g_value_get_string(LIBGNAC_METADATA_TAG_ALBUM(tags)) : NULL;
  const gchar *artist = libgnac_metadata_tag_exists(tags, GST_TAG_ARTIST) ?
      g_value_get_string(LIBGNAC_METADATA_TAG_ARTIST(tags)) : NULL;
  const gchar *title = libgnac_metadata_tag_exists(tags, GST_TAG_TITLE) ?
      g_value_get_string(LIBGNAC_METADATA_TAG_TITLE(tags)) : NULL;

  gchar *text;

  if (title)
  {
    text = g_markup_printf_escaped("  <b>%s</b>  \n"
        "  <span color=\"#888\">%s</span> %s  \n"
        "  <span color=\"#888\">%s</span> %s  ",
        title,
        /* Translators: title by artist from album */
        _("by"), artist ? artist : _("Unknown Artist"),
        /* Translators: title by artist from album */
        _("from"), album ? album : _("Unknown Album"));
  }
  else
  {
    gchar *name = gnac_utils_get_display_name(tooltip_path, NULL);
    if (name) {
      text = g_markup_printf_escaped("  <b>%s</b>  ", name);
    } else {
      text = g_strdup(tooltip_path);
    }
    g_free(name);
  }

  gtk_tooltip_set_markup(tooltip, text);
  g_free(text);

  /* check wether we have a cover to display */
  if (libgnac_metadata_tag_exists(tags, GST_TAG_IMAGE)) {
    GdkPixbuf *pixbuf = g_value_get_object(LIBGNAC_METADATA_TAG_IMAGE(tags));
    pixbuf = gnac_ui_utils_scale_pixbuf(pixbuf, 64, 64);
    pixbuf = gnac_ui_utils_add_border_to_pixbuf(pixbuf);
    gtk_tooltip_set_icon(tooltip, pixbuf);
    g_object_unref(pixbuf);
  }

  return TRUE;
}