svnno****@sourc*****
svnno****@sourc*****
Thu Apr 12 14:20:19 JST 2007
Revision: 3166 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3166 Author: makeinu Date: 2007-04-12 14:20:18 +0900 (Thu, 12 Apr 2007) Log Message: ----------- Now kz_notebook_open_new_tab_at_pos*() return instered position instead of sibling tab. Add kz_notebook_get_sibling_embed() and kz_notebook_get_sibling_tab_label(). Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/ext/ruby/kz-rb-notebook.c kazehakase/trunk/src/kz-notebook.c kazehakase/trunk/src/kz-notebook.h kazehakase/trunk/src/kz-window.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-12 04:15:00 UTC (rev 3165) +++ kazehakase/trunk/ChangeLog 2007-04-12 05:20:18 UTC (rev 3166) @@ -1,3 +1,10 @@ +2007-04-12 Takuro Ashie <ashie****@homa*****> + + * src/kz-notebook.[ch]: Now kz_notebook_open_new_tab_at_pos*() return + instered position instead of sibling tab. + Add kz_notebook_get_sibling_*(). + * src/kz-window.c, ext/ruby/kz-rb-notebook.c: Follow the change. + 2007-04-12 Łukasz Krotowski <lukas****@gmail*****> * src/kz-notebook.c: kz_notebook_open_new_tab_at_pos() returns NULL only Modified: kazehakase/trunk/ext/ruby/kz-rb-notebook.c =================================================================== --- kazehakase/trunk/ext/ruby/kz-rb-notebook.c 2007-04-12 04:15:00 UTC (rev 3165) +++ kazehakase/trunk/ext/ruby/kz-rb-notebook.c 2007-04-12 05:20:18 UTC (rev 3166) @@ -40,7 +40,7 @@ KzNotebook *notebook; KzEmbed *embed; KzTabLabel *label; - KzTabLabel *sibling_label; + gint inserted_pos; rb_scan_args(argc, argv, "21", &rb_embed, &rb_label, &pos); @@ -48,13 +48,13 @@ embed = RVAL2KZEMB(rb_embed); label = RVAL2KZTL(rb_label); if (NIL_P(pos)) { - sibling_label = kz_notebook_open_new_tab(notebook, embed, label); + inserted_pos = kz_notebook_open_new_tab(notebook, embed, label); } else { - sibling_label = kz_notebook_open_new_tab_at_pos(notebook, embed, label, - NUM2INT(pos)); + inserted_pos = kz_notebook_open_new_tab_at_pos(notebook, embed, label, + NUM2INT(pos)); } - return GOBJ2RVAL(sibling_label); + return INT2NUM(inserted_pos); } static VALUE Modified: kazehakase/trunk/src/kz-notebook.c =================================================================== --- kazehakase/trunk/src/kz-notebook.c 2007-04-12 04:15:00 UTC (rev 3165) +++ kazehakase/trunk/src/kz-notebook.c 2007-04-12 05:20:18 UTC (rev 3166) @@ -410,37 +410,30 @@ return pos; } -KzTabLabel * +gint kz_notebook_open_new_tab_at_pos (KzNotebook *notebook, KzEmbed *embed, KzTabLabel *label, gint pos) { - GtkWidget *sibembed; - KzTabLabel *sibtab = NULL; KzNotebookPrivate *priv = KZ_NOTEBOOK_GET_PRIVATE(notebook); + gint inserted_pos; - gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), - GTK_WIDGET(embed), - GTK_WIDGET(label), - pos); + inserted_pos = gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), + GTK_WIDGET(embed), + GTK_WIDGET(label), + pos); /* add to this notebook's history */ priv->open_hist = g_list_prepend(priv->open_hist, embed); - sibembed = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), pos); - sibtab = KZ_TAB_LABEL(gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), - sibembed)); - return sibtab; + return inserted_pos; } -KzTabLabel * +gint kz_notebook_open_new_tab (KzNotebook *notebook, KzEmbed *embed, KzTabLabel *label) { gint pos; - KzTabLabel *sibtab = NULL; pos = get_insert_tab_position(notebook); - sibtab = kz_notebook_open_new_tab_at_pos(notebook, embed, label, pos); - - return sibtab; + return kz_notebook_open_new_tab_at_pos(notebook, embed, label, pos); } gboolean @@ -725,3 +718,48 @@ return gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); } + +KzEmbed * +kz_notebook_get_sibling_embed (KzNotebook *notebook, KzEmbed *embed) +{ + gint pos; + GtkWidget *sibembed; + + g_return_val_if_fail(KZ_IS_NOTEBOOK(notebook), NULL); + g_return_val_if_fail(KZ_IS_EMBED(embed), NULL); + + pos = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), GTK_WIDGET(embed)); + if (pos < 0) + return NULL; + pos++; + if (pos >= gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook))) + return NULL; + + sibembed = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), pos); + + if (sibembed) + return KZ_EMBED(sibembed); + else + return NULL; +} + +KzTabLabel * +kz_notebook_get_sibling_tab_label (KzNotebook *notebook, KzTabLabel *label) +{ + KzEmbed *sibembed; + GtkWidget *widget; + + g_return_val_if_fail(KZ_IS_NOTEBOOK(notebook), NULL); + g_return_val_if_fail(KZ_IS_TAB_LABEL(label), NULL); + g_return_val_if_fail(KZ_IS_EMBED(label->kzembed), NULL); + + sibembed = kz_notebook_get_sibling_embed(notebook, label->kzembed); + if (!sibembed) + return NULL; + + widget = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), GTK_WIDGET(sibembed)); + if (widget) + return KZ_TAB_LABEL(widget); + else + return NULL; +} Modified: kazehakase/trunk/src/kz-notebook.h =================================================================== --- kazehakase/trunk/src/kz-notebook.h 2007-04-12 04:15:00 UTC (rev 3165) +++ kazehakase/trunk/src/kz-notebook.h 2007-04-12 05:20:18 UTC (rev 3166) @@ -34,23 +34,43 @@ KZ_NOTEBOOK_CLOSE_FORWARD } KzNotebookCloseCondition; -GType kz_notebook_get_type (void) G_GNUC_CONST; -GtkWidget *kz_notebook_new (KzWindow *kz); -KzTabLabel *kz_notebook_open_new_tab (KzNotebook *notebook, KzEmbed *embed, KzTabLabel *label); -KzTabLabel *kz_notebook_open_new_tab_at_pos(KzNotebook *notebook, KzEmbed *embed, KzTabLabel *label, gint pos); -gboolean kz_notebook_close_tab (KzNotebook *notebook, GtkWidget *widget); -gboolean kz_notebook_close_tabs (KzNotebook *notebook, KzNotebookCloseCondition condition, gint pos); -gboolean kz_notebook_close_all_tab (KzNotebook *notebook); -gboolean kz_notebook_move_tab (KzNotebook *src_notebook, KzNotebook *dest_notebook, GtkWidget *widget); -void kz_notebook_next_tab (KzNotebook *notebook); -void kz_notebook_prev_tab (KzNotebook *notebook); -GtkWidget *kz_notebook_reorder_tab (KzNotebook *notebook, GtkWidget *widget, gint pos); -gboolean kz_notebook_scroll_tab (KzNotebook *notebook, GdkScrollDirection direction); -GtkWidget *kz_notebook_get_nth_page (KzNotebook *notebook, gint page_num); -gint kz_notebook_page_num (KzNotebook *notebook, GtkWidget *child); -gint kz_notebook_get_current_page (KzNotebook *notebook); -void kz_notebook_set_current_page (KzNotebook *notebook, gint page_num); -gint kz_notebook_get_n_pages (KzNotebook *notebook); +GType kz_notebook_get_type (void) G_GNUC_CONST; +GtkWidget *kz_notebook_new (KzWindow *kz); +gint kz_notebook_open_new_tab (KzNotebook *notebook, + KzEmbed *embed, + KzTabLabel *label); +gint kz_notebook_open_new_tab_at_pos (KzNotebook *notebook, + KzEmbed *embed, + KzTabLabel *label, + gint pos); +gboolean kz_notebook_close_tab (KzNotebook *notebook, + GtkWidget *widget); +gboolean kz_notebook_close_tabs (KzNotebook *notebook, + KzNotebookCloseCondition condition, + gint pos); +gboolean kz_notebook_close_all_tab (KzNotebook *notebook); +gboolean kz_notebook_move_tab (KzNotebook *src_notebook, + KzNotebook *dest_notebook, + GtkWidget *widget); +void kz_notebook_next_tab (KzNotebook *notebook); +void kz_notebook_prev_tab (KzNotebook *notebook); +GtkWidget *kz_notebook_reorder_tab (KzNotebook *notebook, + GtkWidget *widget, + gint pos); +gboolean kz_notebook_scroll_tab (KzNotebook *notebook, + GdkScrollDirection direction); +GtkWidget *kz_notebook_get_nth_page (KzNotebook *notebook, + gint page_num); +gint kz_notebook_page_num (KzNotebook *notebook, + GtkWidget *child); +gint kz_notebook_get_current_page (KzNotebook *notebook); +void kz_notebook_set_current_page (KzNotebook *notebook, + gint page_num); +gint kz_notebook_get_n_pages (KzNotebook *notebook); +KzEmbed *kz_notebook_get_sibling_embed (KzNotebook *notebook, + KzEmbed *embed); +KzTabLabel *kz_notebook_get_sibling_tab_label (KzNotebook *notebook, + KzTabLabel *label); G_END_DECLS Modified: kazehakase/trunk/src/kz-window.c =================================================================== --- kazehakase/trunk/src/kz-window.c 2007-04-12 04:15:00 UTC (rev 3165) +++ kazehakase/trunk/src/kz-window.c 2007-04-12 05:20:18 UTC (rev 3166) @@ -842,12 +842,12 @@ gtk_widget_show_all(GTK_WIDGET(kzembed)); gtk_widget_show(GTK_WIDGET(kztab)); - sibtab = kz_notebook_open_new_tab(KZ_NOTEBOOK(kz->notebook), kzembed, kztab); + kz_notebook_open_new_tab(KZ_NOTEBOOK(kz->notebook), kzembed, kztab); + sibtab = kz_notebook_get_sibling_tab_label(KZ_NOTEBOOK(kz->notebook), kztab); /* insert tab bookmark */ - if(sibtab) - kz_bookmark_insert_before(kz->tabs, - kztab->history, - sibtab->history); + kz_bookmark_insert_before(kz->tabs, + kztab->history, + sibtab ? sibtab->history : NULL); kz_window_set_embed_callbacks(kz, kzembed);