Exemple #1
0
static void
draw_radio (GtkWidget     *widget,
            cairo_t       *cr,
            gint           x,
            gint           y,
            GtkStateFlags  state,
            gint          *width,
            gint          *height)
{
  GtkStyleContext *button_context;
  GtkStyleContext *check_context;
  gint contents_x, contents_y, contents_width, contents_height;

  /* This information is taken from the GtkRadioButton docs, see "CSS nodes" */
  button_context = get_style (NULL, "radiobutton");
  check_context = get_style (button_context, "radio");

  gtk_style_context_set_state (check_context, state);

  *width = *height = 0;
  query_size (button_context, width, height);
  query_size (check_context, width, height);

  draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (check_context, cr, x, y, *width, *height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);

  g_object_unref (check_context);
  g_object_unref (button_context);

}
Exemple #2
0
static void
draw_progress (GtkWidget *widget,
               cairo_t   *cr,
               gint       x,
               gint       y,
               gint       width,
               gint       position,
               gint      *height)
{
  GtkStyleContext *bar_context;
  GtkStyleContext *trough_context;
  GtkStyleContext *progress_context;

  /* This information is taken from the GtkProgressBar docs, see "CSS nodes" */
  bar_context = get_style (NULL, "progressbar.horizontal");
  trough_context = get_style (bar_context, "trough");
  progress_context = get_style (trough_context, "progress.left");

  *height = 0;
  query_size (bar_context, NULL, height);
  query_size (trough_context, NULL, height);
  query_size (progress_context, NULL, height);

  draw_style_common (bar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (progress_context, cr, x, y, position, *height, NULL, NULL, NULL, NULL);

  g_object_unref (progress_context);
  g_object_unref (trough_context);
  g_object_unref (bar_context);
}
Exemple #3
0
static void
draw_menubar (GtkWidget     *widget,
              cairo_t       *cr,
              gint           x,
              gint           y,
              gint           width,
              gint          *height)
{
  GtkStyleContext *frame_context;
  GtkStyleContext *border_context;
  GtkStyleContext *menubar_context;
  GtkStyleContext *hovered_menuitem_context;
  GtkStyleContext *menuitem_context;
  gint contents_x, contents_y, contents_width, contents_height;
  gint item_width;

  /* Menubar background is the same color as our base background, so use a frame */
  frame_context = get_style (NULL, "frame");
  border_context = get_style (frame_context, "border");

  /* This information is taken from the GtkMenuBar docs, see "CSS nodes" */
  menubar_context = get_style (NULL, "menubar");
  hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
  menuitem_context = get_style (menubar_context, "menuitem");

  *height = 0;
  query_size (frame_context, NULL, height);
  query_size (border_context, NULL, height);
  query_size (menubar_context, NULL, height);
  query_size (hovered_menuitem_context, NULL, height);
  query_size (menuitem_context, NULL, height);

  draw_style_common (frame_context, cr, x, y, width, *height,
                     NULL, NULL, NULL, NULL);
  draw_style_common (border_context, cr, x, y, width, *height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
                     NULL, NULL, NULL, NULL);
  item_width = contents_width / 3;
  draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
                     NULL, NULL, NULL, NULL);
  draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
                     NULL, NULL, NULL, NULL);

  g_object_unref (menuitem_context);
  g_object_unref (hovered_menuitem_context);
  g_object_unref (menubar_context);
  g_object_unref (border_context);
  g_object_unref (frame_context);
}
Exemple #4
0
static void
draw_notebook (GtkWidget     *widget,
               cairo_t       *cr,
               gint           x,
               gint           y,
               gint           width,
               gint           height)
{
  GtkStyleContext *notebook_context;
  GtkStyleContext *header_context;
  GtkStyleContext *tabs_context;
  GtkStyleContext *tab1_context, *tab2_context;
  GtkStyleContext *stack_context;
  gint header_height;
  gint contents_x, contents_y, contents_width, contents_height;

  /* This information is taken from the GtkNotebook docs, see "CSS nodes" */
  notebook_context = get_style (NULL, "notebook.frame");
  header_context = get_style (notebook_context, "header.top");
  tabs_context = get_style (header_context, "tabs");
  tab1_context = get_style (tabs_context, "tab:checked");
  tab2_context = get_style (tabs_context, "tab:hover");
  stack_context = get_style (notebook_context, "stack");

  header_height = 0;
  query_size (notebook_context, NULL, &header_height);
  query_size (header_context, NULL, &header_height);
  query_size (tabs_context, NULL, &header_height);
  query_size (tab1_context, NULL, &header_height);
  query_size (tab2_context, NULL, &header_height);

  draw_style_common (notebook_context, cr, x, y, width, height, NULL, NULL, NULL, NULL);
  draw_style_common (header_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
  draw_style_common (tabs_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
  draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
                     NULL, NULL, NULL, NULL);
  draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
                     NULL, NULL, NULL, NULL);

  g_object_unref (stack_context);
  g_object_unref (tabs_context);
  g_object_unref (tab1_context);
  g_object_unref (tab2_context);
  g_object_unref (header_context);
  g_object_unref (notebook_context);
}
Exemple #5
0
static void
draw_horizontal_scrollbar (GtkWidget     *widget,
                           cairo_t       *cr,
                           gint           x,
                           gint           y,
                           gint           width,
                           gint           position,
                           GtkStateFlags  state,
                           gint          *height)
{
  GtkStyleContext *scrollbar_context;
  GtkStyleContext *contents_context;
  GtkStyleContext *trough_context;
  GtkStyleContext *slider_context;
  gint slider_width;

  /* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
  scrollbar_context = get_style (NULL, "scrollbar.horizontal.bottom");
  contents_context = get_style (scrollbar_context, "contents");
  trough_context = get_style (contents_context, "trough");
  slider_context = get_style (trough_context, "slider");

  gtk_style_context_set_state (scrollbar_context, state);
  gtk_style_context_set_state (contents_context, state);
  gtk_style_context_set_state (trough_context, state);
  gtk_style_context_set_state (slider_context, state);

  *height = 0;
  query_size (scrollbar_context, NULL, height);
  query_size (contents_context, NULL, height);
  query_size (trough_context, NULL, height);
  query_size (slider_context, NULL, height);

  gtk_style_context_get (slider_context,
                         "min-width", &slider_width, NULL);

  draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (contents_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL, NULL, NULL, NULL);

  g_object_unref (slider_context);
  g_object_unref (trough_context);
  g_object_unref (contents_context);
  g_object_unref (scrollbar_context);
}
Exemple #6
0
static void
draw_scale (GtkWidget *widget,
            cairo_t   *cr,
            gint       x,
            gint       y,
            gint       width,
            gint       position,
            gint      *height)
{
  GtkStyleContext *scale_context;
  GtkStyleContext *contents_context;
  GtkStyleContext *trough_context;
  GtkStyleContext *slider_context;
  GtkStyleContext *highlight_context;
  gint contents_x, contents_y, contents_width, contents_height;
  gint trough_height, slider_height;

  scale_context = get_style (NULL, "scale.horizontal");
  contents_context = get_style (scale_context, "contents");
  trough_context = get_style (contents_context, "trough");
  slider_context = get_style (trough_context, "slider");
  highlight_context = get_style (trough_context, "highlight.top");

  *height = 0;
  query_size (scale_context, NULL, height);
  query_size (contents_context, NULL, height);
  query_size (trough_context, NULL, height);
  query_size (slider_context, NULL, height);
  query_size (highlight_context, NULL, height);

  draw_style_common (scale_context, cr, x, y, width, *height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  /* Scale trough defines its size querying slider and highlight */
  trough_height = 0;
  query_size (trough_context, NULL, &trough_height);
  slider_height = 0;
  query_size (slider_context, NULL, &slider_height);
  query_size (highlight_context, NULL, &slider_height);
  trough_height += slider_height;
  draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  draw_style_common (highlight_context, cr, contents_x, contents_y,
                     contents_width / 2, contents_height,
                     NULL, NULL, NULL, NULL);
  draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
                     NULL, NULL, NULL, NULL);

  g_object_unref (scale_context);
  g_object_unref (contents_context);
  g_object_unref (trough_context);
  g_object_unref (slider_context);
  g_object_unref (highlight_context);
}
Exemple #7
0
static int mysqlfs_getattr(const char *path, struct stat *stbuf)
{
    int ret;
    MYSQL *dbconn;
#ifdef STATUSDIR
    char buf[8 * 1024];
#endif

    // This is called far too often
    log_printf(LOG_D_CALL, "mysqlfs_getattr(\"%s\")\n", path);

#ifdef STATUSDIR
    if (0 == strncmp (path, status_pathname, len_status_pathname))
    {
        char *a = (char *) path + len_status_pathname;

        log_printf(LOG_D_CALL, "%s(\"%s\")(@%d)\n", __FUNCTION__, path, __LINE__);
        stbuf->st_mode = S_IRUSR|S_IXUSR | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH;
        stbuf->st_nlink = 1;

        if (0 == *a)
            stbuf->st_mode |= S_IFDIR;
        else
        {
            stbuf->st_mode |= S_IFREG;
            if (0 == strcmp ("/txt", a))
                stbuf->st_size = snprint_status (buf, sizeof(buf), theopts, inode_status_txt);
            else if (0 == strcmp ("/xml", a))
                stbuf->st_size = snprint_status (buf, sizeof(buf), theopts, inode_status_xml);
            else
                stbuf->st_size = 0;
        }

        return 0;
    }
#endif

    /* fixme: move memset() above STATUSDIR ? */
    memset(stbuf, 0, sizeof(struct stat));

    if ( (0 < theopts->osxnospotlight) && (0 == strcmp (path, "/.metadata_never_index")))
    {
        stbuf->st_mode = S_IRUSR|S_IRGRP|S_IROTH|S_IFREG;	/* file w/ mode 0444 */
        stbuf->st_nlink = 1;
        stbuf->st_size = sizeof(PACKAGE_STRING);	/* I need some bogus content for a read() operation */

        return 0;
    }

    if ((dbconn = pool_get()) == NULL)
      return -EMFILE;

    ret = query_getattr(dbconn, path, stbuf);

    if(ret){
        if (ret != -ENOENT)
            log_printf(LOG_ERROR, "Error: query_getattr()\n");
        pool_put(dbconn);
        return ret;
    }else{
        long inode = query_inode(dbconn, path);
        if(inode < 0){
            log_printf(LOG_ERROR, "Error: query_inode()\n");
            pool_put(dbconn);
            return inode;
        }

        stbuf->st_size = query_size(dbconn, inode);
    }

    pool_put(dbconn);

    return ret;
}
Exemple #8
0
static void
draw_spinbutton (GtkWidget *widget,
                 cairo_t   *cr,
                 gint       x,
                 gint       y,
                 gint       width,
                 gint      *height)
{
  GtkStyleContext *spin_context;
  GtkStyleContext *entry_context;
  GtkStyleContext *up_context;
  GtkStyleContext *down_context;
  GtkIconTheme *icon_theme;
  GtkIconInfo *icon_info;
  GdkPixbuf *pixbuf;
  GdkTexture *texture;
  gint icon_width, icon_height, icon_size;
  gint button_width;
  gint contents_x, contents_y, contents_width, contents_height;

  /* This information is taken from the GtkSpinButton docs, see "CSS nodes" */
  spin_context = get_style (NULL, "spinbutton.horizontal:focus");
  entry_context = get_style (spin_context, "entry:focus");
  up_context = get_style (spin_context, "button.up:focus:active");
  down_context = get_style (spin_context, "button.down:focus");

  *height = 0;
  query_size (spin_context, NULL, height);
  query_size (entry_context, NULL, height);
  query_size (up_context, NULL, height);
  query_size (down_context, NULL, height);
  button_width = *height;

  draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);

  icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));

  gtk_style_context_get (up_context,
                         "min-width", &icon_width, "min-height", &icon_height, NULL);
  icon_size = MIN (icon_width, icon_height);
  icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
  pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL);
  texture = gdk_texture_new_for_pixbuf (pixbuf);
  g_object_unref (icon_info);
  draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_render_icon (up_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
  g_object_unref (pixbuf);
  g_object_unref (texture);

  gtk_style_context_get (down_context,
                         "min-width", &icon_width, "min-height", &icon_height, NULL);
  icon_size = MIN (icon_width, icon_height);
  icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
  pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL);
  texture = gdk_texture_new_for_pixbuf (pixbuf);
  g_object_unref (icon_info);
  draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_render_icon (down_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
  g_object_unref (pixbuf);
  g_object_unref (texture);

  g_object_unref (down_context);
  g_object_unref (up_context);
  g_object_unref (entry_context);
  g_object_unref (spin_context);
}
Exemple #9
0
static void
draw_combobox (GtkWidget *widget,
               cairo_t   *cr,
               gint       x,
               gint       y,
               gint       width,
               gboolean   has_entry,
               gint      *height)
{
  GtkStyleContext *combo_context;
  GtkStyleContext *box_context;
  GtkStyleContext *button_context;
  GtkStyleContext *button_box_context;
  GtkStyleContext *entry_context;
  GtkStyleContext *arrow_context;
  gint contents_x, contents_y, contents_width, contents_height;
  gint button_width;
  gint arrow_width, arrow_height, arrow_size;

  /* This information is taken from the GtkComboBox docs, see "CSS nodes" */
  combo_context = get_style (NULL, "combobox:focus");
  box_context = get_style (combo_context, "box.horizontal.linked");
  if (has_entry)
    {
      const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL };

      entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
      button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
    }
  else
    {
      const char *siblings[2] = { "button.combo" , NULL };

      button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
    }
  button_box_context = get_style (button_context, "box.horizontal");
  arrow_context = get_style (button_box_context, "arrow");

  *height = 0;
  query_size (combo_context, NULL, height);
  query_size (box_context, NULL, height);
  if (has_entry)
    query_size (entry_context, NULL, height);
  query_size (button_context, NULL, height);
  query_size (button_box_context, NULL, height);
  query_size (arrow_context, NULL, height);

  gtk_style_context_get (arrow_context,
                         "min-width", &arrow_width, "min-height", &arrow_height, NULL);
  arrow_size = MIN (arrow_width, arrow_height);

  draw_style_common (combo_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  draw_style_common (box_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
  if (has_entry)
    {
      button_width = *height;
      draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL, NULL, NULL, NULL);
      draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
                         &contents_x, &contents_y, &contents_width, &contents_height);
    }
  else
    {
      button_width = width;
      draw_style_common (button_context, cr, x, y, width, *height,
                         &contents_x, &contents_y, &contents_width, &contents_height);
    }

  draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
                     NULL, NULL, NULL, NULL);
  draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
                     NULL, NULL, NULL, NULL);
  gtk_render_arrow (arrow_context, cr, G_PI / 2,
                    contents_x + contents_width - arrow_size,
                    contents_y + (contents_height - arrow_size) / 2, arrow_size);

  g_object_unref (arrow_context);
  if (has_entry)
    g_object_unref (entry_context);
  g_object_unref (button_context);
  g_object_unref (combo_context);
}
Exemple #10
0
static void
draw_menu (GtkWidget *widget,
           cairo_t   *cr,
           gint       x,
           gint       y,
           gint       width,
           gint      *height)
{
  GtkStyleContext *menu_context;
  GtkStyleContext *menuitem_context;
  GtkStyleContext *hovermenuitem_context;
  GtkStyleContext *hoveredarrowmenuitem_context;
  GtkStyleContext *arrowmenuitem_context;
  GtkStyleContext *checkmenuitem_context;
  GtkStyleContext *disabledarrowmenuitem_context;
  GtkStyleContext *disabledcheckmenuitem_context;
  GtkStyleContext *radiomenuitem_context;
  GtkStyleContext *disablemenuitem_context;
  GtkStyleContext *disabledradiomenuitem_context;
  GtkStyleContext *separatormenuitem_context;
  gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
  gint contents_x, contents_y, contents_width, contents_height;
  gint menu_x, menu_y, menu_width, menu_height;
  gint arrow_width, arrow_height, arrow_size;
  gint toggle_x, toggle_y, toggle_width, toggle_height;

  /* This information is taken from the GtkMenu docs, see "CSS nodes" */
  menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
  hovermenuitem_context = get_style (menu_context, "menuitem:hover");
  hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
  menuitem_context = get_style (menu_context, "menuitem");
  arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
  disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
  disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
  checkmenuitem_context = get_style (menuitem_context, "check:checked");
  disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
  separatormenuitem_context = get_style (menu_context, "separator:disabled");
  radiomenuitem_context = get_style (menuitem_context, "radio:checked");
  disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");

  *height = 0;
  query_size (menu_context, NULL, height);
  menuitem1_height = 0;
  query_size (hovermenuitem_context, NULL, &menuitem1_height);
  query_size (hoveredarrowmenuitem_context, NULL, &menuitem1_height);
  *height += menuitem1_height;
  menuitem2_height = 0;
  query_size (menu_context, NULL, &menuitem5_height);
  query_size (menuitem_context, NULL, &menuitem2_height);
  query_size (arrowmenuitem_context, NULL, &menuitem2_height);
  query_size (disabledarrowmenuitem_context, NULL, &menuitem2_height);
  *height += menuitem2_height;
  menuitem3_height = 0;
  query_size (menu_context, NULL, &menuitem5_height);
  query_size (menuitem_context, NULL, &menuitem3_height);
  query_size (checkmenuitem_context, NULL, &menuitem3_height);
  query_size (disabledcheckmenuitem_context, NULL, &menuitem3_height);
  *height += menuitem3_height;
  menuitem4_height = 0;
  query_size (menu_context, NULL, &menuitem5_height);
  query_size (separatormenuitem_context, NULL, &menuitem4_height);
  *height += menuitem4_height;
  menuitem5_height = 0;
  query_size (menu_context, NULL, &menuitem5_height);
  query_size (menuitem_context, NULL, &menuitem5_height);
  query_size (radiomenuitem_context, NULL, &menuitem5_height);
  query_size (disabledradiomenuitem_context, NULL, &menuitem5_height);
  *height += menuitem5_height;

  draw_style_common (menu_context, cr, x, y, width, *height,
                     &menu_x, &menu_y, &menu_width, &menu_height);

  /* Hovered with right arrow */
  gtk_style_context_get (hoveredarrowmenuitem_context,
                         "min-width", &arrow_width, "min-height", &arrow_height, NULL);
  arrow_size = MIN (arrow_width, arrow_height);
  draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI / 2,
                    contents_x + contents_width - arrow_size,
                    contents_y + (contents_height - arrow_size) / 2, arrow_size);

  /* Left arrow sensitive, and right arrow insensitive */
  draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_style_context_get (arrowmenuitem_context,
                         "min-width", &arrow_width, "min-height", &arrow_height, NULL);
  arrow_size = MIN (arrow_width, arrow_height);
  gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2,
                    contents_x,
                    contents_y + (contents_height - arrow_size) / 2, arrow_size);
  gtk_style_context_get (disabledarrowmenuitem_context,
                         "min-width", &arrow_width, "min-height", &arrow_height, NULL);
  arrow_size = MIN (arrow_width, arrow_height);
  gtk_render_arrow (disabledarrowmenuitem_context, cr, G_PI / 2,
                    contents_x + contents_width - arrow_size,
                    contents_y + (contents_height - arrow_size) / 2, arrow_size);


  /* Left check enabled, sensitive, and right check unchecked, insensitive */
  draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_style_context_get (checkmenuitem_context,
                         "min-width", &toggle_width, "min-height", &toggle_height, NULL);
  draw_style_common (checkmenuitem_context, cr,
                     contents_x,
                     contents_y,
                     toggle_width, toggle_height,
                     &toggle_x, &toggle_y, &toggle_width, &toggle_height);
  gtk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
  gtk_style_context_get (disabledcheckmenuitem_context,
                         "min-width", &toggle_width, "min-height", &toggle_height, NULL);
  draw_style_common (disabledcheckmenuitem_context, cr,
                     contents_x + contents_width - toggle_width,
                     contents_y,
                     toggle_width, toggle_height,
                     &toggle_x, &toggle_y, &toggle_width, &toggle_height);
  gtk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);

  /* Separator */
  draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
                     menu_width, menuitem4_height,
                     NULL, NULL, NULL, NULL);

  /* Left check enabled, sensitive, and right check unchecked, insensitive */
  draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
                     menu_width, menuitem5_height,
                     &contents_x, &contents_y, &contents_width, &contents_height);
  gtk_style_context_get (radiomenuitem_context,
                         "min-width", &toggle_width, "min-height", &toggle_height, NULL);
  draw_style_common (radiomenuitem_context, cr,
                     contents_x,
                     contents_y,
                     toggle_width, toggle_height,
                     &toggle_x, &toggle_y, &toggle_width, &toggle_height);
  gtk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
  gtk_style_context_get (disabledradiomenuitem_context,
                         "min-width", &toggle_width, "min-height", &toggle_height, NULL);
  draw_style_common (disabledradiomenuitem_context, cr,
                     contents_x + contents_width - toggle_width,
                     contents_y,
                     toggle_width, toggle_height,
                     &toggle_x, &toggle_y, &toggle_width, &toggle_height);
  gtk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);

  g_object_unref (menu_context);
  g_object_unref (menuitem_context);
  g_object_unref (hovermenuitem_context);
  g_object_unref (hoveredarrowmenuitem_context);
  g_object_unref (arrowmenuitem_context);
  g_object_unref (checkmenuitem_context);
  g_object_unref (disabledarrowmenuitem_context);
  g_object_unref (disabledcheckmenuitem_context);
  g_object_unref (radiomenuitem_context);
  g_object_unref (disablemenuitem_context);
  g_object_unref (disabledradiomenuitem_context);
  g_object_unref (separatormenuitem_context);
}
Exemple #11
0
varargs int wear_armour(int silent) {
   object owner = environment(this_object());
   object obj;
   int tlayer = 0;
   set_target(this_object());
   if (worn) {
      if (!silent)
         msg("You are already wearing ~targ!");
      return 0;
   }
   if (!owner->query_is_living())
      return 0;
   if (!owner->query_has_bp(query_body_parts())) {
      if (!silent)
         msg("You lack the required appendages to wear ~targ!");
      return 0;
   }

   // returns non-zero if base requirements are not met
   if (this_object()->query_requirements_met(this_player()) != 0)
      return 0;

   if (this_object()->query_broken()) {
      if (!silent)
         msg("You can't wear ~targ, it's broken!");
      return 0;
   }
   //debug("size = "+query_size()+", flex = "+query_flexible());
   // check if they're wearing anything already
   foreach ( obj : all_inventory(owner) ) {
      if (obj->query_is_apparel() && obj->query_worn()) {
         if (obj->query_body_parts() & query_body_parts()) {
            int osize = obj->query_size();
            int oflex = obj->query_flexible();
            int ocloth = obj->query_cloth();
            int small;

            if (ocloth) {
               if (oflex && osize > query_size()) {
                  // flexible cloth
                  small = 1;
            } else if (!oflex && osize > query_size() - 3) {
                  // rigid cloth
                  small = 1;
               }
            } else {
               if (oflex && osize > query_size() - 5) {
                  // flexible metal (example: chainmail)
                  small = 1;
               }

               // can't wear rigid clothing over other rigid clothing.
               if (!oflex && !query_flexible()) {
                  small = 1;
               }
            }
            if (small) {
               msg("You can't wear ~targ over your "+obj->query_name()+".");
               return 0;
            }
            if (obj->query_layer() > tlayer)
               tlayer = obj->query_layer();
         }
      }
   }
   layer = tlayer + 1;
   // returns true if on_wear() has been defined, so false means we need
   // to manually wear the item for them
   if (this_object()->on_wear() == 0) {
      if (!silent) {
         owner->msg_local("~Name ~verbwear ~targ.");
      }
      set_worn(1);
      owner->recalc();
      return 1;
   }
}