Exemplo n.º 1
0
static gint
luaH_notebook_index(lua_State *L, widget_t *w, luakit_token_t token)
{
    /* handle numerical index lookups */
    if (token == L_TK_UNKNOWN && lua_isnumber(L, 2))
        return luaH_notebook_atindex(L, w, (gint)luaL_checknumber(L, 2));

    switch(token)
    {
      LUAKIT_WIDGET_INDEX_COMMON(w)

      /* push class methods */
      PF_CASE(COUNT,        luaH_notebook_count)
      PF_CASE(CURRENT,      luaH_notebook_current)
      PF_CASE(GET_TITLE,    luaH_notebook_get_title)
      PF_CASE(INDEXOF,      luaH_notebook_indexof)
      PF_CASE(INSERT,       luaH_notebook_insert)
      PF_CASE(REMOVE,       luaH_notebook_remove)
      PF_CASE(SET_TITLE,    luaH_notebook_set_title)
      PF_CASE(SWITCH,       luaH_notebook_switch)
      PF_CASE(REORDER,      luaH_notebook_reorder)

      case L_TK_CHILDREN:
        return luaH_widget_get_children(L, w);

      /* push boolean properties */
      PB_CASE(SHOW_TABS,    gtk_notebook_get_show_tabs(GTK_NOTEBOOK(w->widget)))
      PB_CASE(SHOW_BORDER,  gtk_notebook_get_show_border(GTK_NOTEBOOK(w->widget)))

      default:
        break;
    }
    return 0;
}
Exemplo n.º 2
0
static GtkWidget*
get_label_from_notebook_page (GailNotebookPage *page)
{
  GtkWidget *child;
  GtkNotebook *notebook;

  notebook = page->notebook;
  if (!notebook)
    return NULL;

  if (!gtk_notebook_get_show_tabs (notebook))
    return NULL;

  child = gtk_notebook_get_nth_page (notebook, page->index);
  if (child == NULL) return NULL;
  g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);

  child = gtk_notebook_get_tab_label (notebook, child);

  if (GTK_IS_LABEL (child))
    return child;

  if (GTK_IS_CONTAINER (child))
    child = find_label_child (GTK_CONTAINER (child));

  return child;
}
Exemplo n.º 3
0
void
aurora_get_parent_bg (const GtkWidget *widget, AuroraRGB *color)
{
	GtkStateType state_type;
	const GtkWidget *parent;
	GdkColor *gcolor;
	gboolean stop;
	GtkShadowType shadow = GTK_SHADOW_NONE;
	
	if (widget == NULL)
		return;
	
	parent = widget->parent;
	stop = FALSE;
	
	while (parent && !stop)
	{
		stop = FALSE;

		stop |= !GTK_WIDGET_NO_WINDOW (parent);
		stop |= GTK_IS_NOTEBOOK (parent) &&
		        gtk_notebook_get_show_tabs (GTK_NOTEBOOK (parent)) &&
		        gtk_notebook_get_show_border (GTK_NOTEBOOK (parent));

		if (GTK_IS_FRAME(parent))
		{
			shadow = gtk_frame_get_shadow_type(GTK_FRAME(parent));
			stop |= (shadow != GTK_SHADOW_NONE);
		}
		else if (GTK_IS_TOOLBAR (parent))
		{
			gtk_widget_style_get (GTK_WIDGET (parent), "shadow-type", &shadow, NULL);
			
			stop |= (shadow != GTK_SHADOW_NONE);
		}

		if (!stop)
			parent = parent->parent;
	}

	if (parent == NULL)
		return;
	
	state_type = GTK_WIDGET_STATE (parent);
	
	gcolor = &parent->style->bg[state_type];
	
	aurora_gdk_color_to_rgb (gcolor, &color->r, &color->g, &color->b);
    
    if (GTK_IS_FRAME (parent) && shadow != GTK_SHADOW_NONE) {
         if (shadow == (GTK_SHADOW_IN || GTK_SHADOW_ETCHED_IN))
         	aurora_shade (color, color, 0.97);
         else
            aurora_shade (color, color, 1.04);
    }
}
Exemplo n.º 4
0
int
clip_GTK_NOTEBOOKGETSHOWTABS(ClipMachine * cm)
{
	C_widget     *cntb = _fetch_cw_arg(cm);

	CHECKCWID(cntb,GTK_IS_NOTEBOOK);
	_clip_retl(cm, gtk_notebook_get_show_tabs(GTK_NOTEBOOK(cntb->widget)));
	return 0;
err:
	return 1;
}
Exemplo n.º 5
0
/* toggle the visibility of the notebook tab */
static void tab_togglebar(struct window *w) {

  if(gtk_notebook_get_show_tabs(GTK_NOTEBOOK(w->notebook))) {
    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), FALSE);
  }
  else {
    if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(w->notebook)) != 1)  {
      gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), TRUE); 
    }
  }
}
static GtkWidget *
get_label_from_notebook_page (GtkNotebookPageAccessible *page)
{
  GtkWidget *child;
  GtkNotebook *notebook;

  notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook));
  if (!notebook)
    return NULL;

  if (!gtk_notebook_get_show_tabs (notebook))
    return NULL;

  child = gtk_notebook_get_tab_label (notebook, page->child);

  if (GTK_IS_LABEL (child))
    return child;

  if (GTK_IS_CONTAINER (child))
    child = find_label_child (GTK_CONTAINER (child));

  return child;
}
void ui_playlist_notebook_edit_tab_title(GtkWidget *ebox)
{
    if (!gtk_notebook_get_show_tabs(UI_PLAYLIST_NOTEBOOK))
        return;

    if (ebox == NULL || !GTK_IS_EVENT_BOX(ebox))
    {
        GtkWidget *page = gtk_notebook_get_nth_page(UI_PLAYLIST_NOTEBOOK, aud_playlist_get_active());
        ebox = gtk_notebook_get_tab_label(UI_PLAYLIST_NOTEBOOK, page);
    }

    GtkWidget *label = g_object_get_data(G_OBJECT(ebox), "label");
    GtkWidget *entry = g_object_get_data(G_OBJECT(ebox), "entry");
    gtk_widget_hide(label);

    gchar * title = aud_playlist_get_title (aud_playlist_get_active ());
    gtk_entry_set_text ((GtkEntry *) entry, title);
    str_unref (title);
    gtk_widget_grab_focus(entry);
    gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
    gtk_widget_show(entry);

    ui_playlist_notebook_tab_title_editing = ebox;
}
Exemplo n.º 8
0
static void
gail_notebook_real_notify_gtk (GObject           *obj,
                               GParamSpec        *pspec)
{
  GtkWidget *widget;
  AtkObject* atk_obj;

  widget = GTK_WIDGET (obj);
  atk_obj = gtk_widget_get_accessible (widget);

  if (strcmp (pspec->name, "page") == 0)
    {
      gint page_num, old_page_num;
      gint focus_page_num = 0;
      gint old_focus_page_num;
      GailNotebook *gail_notebook;
      GtkNotebook *gtk_notebook;
     
      gail_notebook = GAIL_NOTEBOOK (atk_obj);
      gtk_notebook = GTK_NOTEBOOK (widget);
     
      if (gail_notebook->page_count < gtk_notebook_get_n_pages (gtk_notebook))
       check_cache (gail_notebook, gtk_notebook);
      /*
       * Notify SELECTED state change for old and new page
       */
      old_page_num = gail_notebook->selected_page;
      page_num = gtk_notebook_get_current_page (gtk_notebook);
      gail_notebook->selected_page = page_num;
      gail_notebook->focus_tab_page = page_num;
      old_focus_page_num = gail_notebook->focus_tab_page;

      if (page_num != old_page_num)
        {
          AtkObject *obj;

          if (old_page_num != -1)
            {
              obj = gail_notebook_ref_child (atk_obj, old_page_num);
              if (obj)
                {
                  atk_object_notify_state_change (obj,
                                                  ATK_STATE_SELECTED,
                                                  FALSE);
                  g_object_unref (obj);
                }
            }
          obj = gail_notebook_ref_child (atk_obj, page_num);
          if (obj)
            {
              atk_object_notify_state_change (obj,
                                              ATK_STATE_SELECTED,
                                              TRUE);
              g_object_unref (obj);
              /*
               * The page which is being displayed has changed but there is
               * no need to tell the focus tracker as the focus page will also 
               * change or a widget in the page will receive focus if the
               * Notebook does not have tabs.
               */
            }
          g_signal_emit_by_name (atk_obj, "selection_changed");
          g_signal_emit_by_name (atk_obj, "visible_data_changed");
        }
      if (gtk_notebook_get_show_tabs (gtk_notebook) &&
         (focus_page_num != old_focus_page_num))
        {
          if (gail_notebook->idle_focus_id)
            g_source_remove (gail_notebook->idle_focus_id);
          gail_notebook->idle_focus_id = gdk_threads_add_idle (gail_notebook_check_focus_tab, atk_obj);
        }
    }
  else
    GAIL_WIDGET_CLASS (gail_notebook_parent_class)->notify_gtk (obj, pspec);
}
Exemplo n.º 9
0
static gint
luaH_notebook_index(lua_State *L, luakit_token_t token)
{
    widget_t *w = luaH_checkudata(L, 1, &widget_class);

    switch(token)
    {
      case L_TK_DESTROY:
        lua_pushcfunction(L, luaH_widget_destroy);
        return 1;

      case L_TK_COUNT:
        lua_pushcfunction(L, luaH_notebook_count);
        return 1;

      case L_TK_INSERT:
        lua_pushcfunction(L, luaH_notebook_insert);
        return 1;

      case L_TK_APPEND:
        lua_pushcfunction(L, luaH_notebook_append);
        return 1;

      case L_TK_CURRENT:
        lua_pushcfunction(L, luaH_notebook_current);
        return 1;

      case L_TK_REMOVE:
        lua_pushcfunction(L, luaH_notebook_remove);
        return 1;

      case L_TK_INDEXOF:
        lua_pushcfunction(L, luaH_notebook_indexof);
        return 1;

      case L_TK_ATINDEX:
        lua_pushcfunction(L, luaH_notebook_atindex);
        return 1;

      case L_TK_SWITCH:
        lua_pushcfunction(L, luaH_notebook_switch);
        return 1;

      case L_TK_SET_TITLE:
        lua_pushcfunction(L, luaH_notebook_set_title);
        return 1;

      case L_TK_GET_TITLE:
        lua_pushcfunction(L, luaH_notebook_get_title);
        return 1;

      case L_TK_SHOW_TABS:
        lua_pushboolean(L, gtk_notebook_get_show_tabs(
            GTK_NOTEBOOK(w->widget)));
        return 1;

      case L_TK_SHOW_BORDER:
        lua_pushboolean(L, gtk_notebook_get_show_border(
            GTK_NOTEBOOK(w->widget)));
        return 1;

      case L_TK_SHOW:
        lua_pushcfunction(L, luaH_widget_show);
        return 1;

      case L_TK_HIDE:
        lua_pushcfunction(L, luaH_widget_hide);
        return 1;

      case L_TK_FOCUS:
        lua_pushcfunction(L, luaH_widget_focus);
        return 1;

      default:
        break;
    }
    return 0;
}