/** * Callback function to select next page. * \param widget Widget (button). */ static void imp_ldif_next( GtkWidget *widget ) { gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(impldif_dlg.notebook) ); if( pageNum == PAGE_FILE_INFO ) { /* Goto attributes stuff */ if( imp_ldif_file_move() ) { gtk_notebook_set_page( GTK_NOTEBOOK(impldif_dlg.notebook), PAGE_ATTRIBUTES ); imp_ldif_message(); gtk_widget_set_sensitive( impldif_dlg.btnPrev, TRUE ); } else { gtk_widget_set_sensitive( impldif_dlg.btnPrev, FALSE ); } } else if( pageNum == PAGE_ATTRIBUTES ) { /* Goto finish stuff */ if( imp_ldif_field_move() ) { gtk_notebook_set_page( GTK_NOTEBOOK(impldif_dlg.notebook), PAGE_FINISH ); imp_ldif_finish_show(); } } }
/** * Callback function to cancel HTML file selection dialog. * \param widget Widget (button). * \param data User data. */ static void export_html_cancel( GtkWidget *widget, gpointer data ) { gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) ); if( pageNum != PAGE_FINISH ) { exphtml_dlg.cancelled = TRUE; } gtk_main_quit(); }
/* Remove a page from the notebook */ void remove_book (GtkButton *button, GtkNotebook *notebook) { gint page; page = gtk_notebook_current_page(notebook); gtk_notebook_remove_page (notebook, page); /* Need to refresh the widget -- This forces the widget to redraw itself. */ gtk_widget_draw(GTK_WIDGET(notebook), NULL); }
/* Response signal handler. This function is needed because GtkDialog's * handler for this signal closes the dialog and we don't want that, we * want to change pages and, dimm certain response buttons. Overriding the * virtual function would not work because that would be called after the * signal handler implemented by GtkDialog. * FIXME: There is a much saner way to do that [MDK] */ static void response (HildonWizardDialog *wizard_dialog, gint response_id, gpointer unused) { HildonWizardDialogPrivate *priv = HILDON_WIZARD_DIALOG_GET_PRIVATE (wizard_dialog); GtkNotebook *notebook = priv->notebook; gint current = 0; gint last = gtk_notebook_get_n_pages (notebook) - 1; gboolean is_first, is_last; g_assert (priv); current = gtk_notebook_current_page (notebook); switch (response_id) { case HILDON_WIZARD_DIALOG_PREVIOUS: --current; is_last = (current == last); is_first = (current == 0); make_buttons_sensitive (wizard_dialog, !is_first, !is_first, !is_last); gtk_notebook_prev_page (notebook); /* go to previous page */ break; case HILDON_WIZARD_DIALOG_NEXT: if (!priv->forward_function || (*priv->forward_function) (priv->notebook, current, priv->forward_function_data)) { ++current; is_last = (current == last); is_first = (current == 0); make_buttons_sensitive (wizard_dialog, !is_first, !is_first, !is_last); gtk_notebook_next_page (notebook); /* go to next page */ } break; case HILDON_WIZARD_DIALOG_FINISH: return; } current = gtk_notebook_get_current_page (notebook); is_last = current == last; is_first = current == 0; /* Don't let the dialog close */ g_signal_stop_emission_by_name (wizard_dialog, "response"); /* New page number may appear in the title, update it */ if (priv->autotitle) create_title (wizard_dialog); }
/** * Callback function to select previous page. * \param widget Widget (button). */ static void imp_ldif_prev( GtkWidget *widget ) { gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(impldif_dlg.notebook) ); if( pageNum == PAGE_ATTRIBUTES ) { /* Goto file page stuff */ gtk_notebook_set_page( GTK_NOTEBOOK(impldif_dlg.notebook), PAGE_FILE_INFO ); gtk_widget_set_sensitive( impldif_dlg.btnPrev, FALSE ); } imp_ldif_message(); }
/** * Select and display status message appropriate for the page being displayed. */ static void export_html_message( void ) { gchar *sMsg = NULL; gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) ); if( pageNum == PAGE_FILE_INFO ) { sMsg = _( "Please specify output directory and file to create." ); } else if( pageNum == PAGE_FORMAT ) { sMsg = _( "Select stylesheet and formatting." ); } else if( pageNum == PAGE_FINISH ) { sMsg = _( "File exported successfully." ); } export_html_status_show( sMsg ); }
/** * Select and display status message appropriate for the page being displayed. */ static void imp_ldif_message( void ) { gchar *sMsg = NULL; gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(impldif_dlg.notebook) ); if( pageNum == PAGE_FILE_INFO ) { sMsg = _( "Please specify address book name and file to import." ); } else if( pageNum == PAGE_ATTRIBUTES ) { sMsg = _( "Select and rename LDIF field names to import." ); } else if( pageNum == PAGE_FINISH ) { sMsg = _( "File imported." ); } imp_ldif_status_show( sMsg ); }
/** * Callback function to select previous page. * \param widget Widget (button). */ static void export_html_prev( GtkWidget *widget ) { gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) ); if( pageNum == PAGE_FORMAT ) { /* Goto file page stuff */ gtk_notebook_set_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FILE_INFO ); gtk_widget_set_sensitive( exphtml_dlg.btnPrev, FALSE ); } else if( pageNum == PAGE_FINISH ) { /* Goto format page */ gtk_notebook_set_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT ); gtk_widget_set_sensitive( exphtml_dlg.btnNext, TRUE ); } export_html_message(); }
/** * Callback function to select previous page. * \param widget Widget (button). */ static void export_html_next( GtkWidget *widget ) { gint pageNum; pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) ); if( pageNum == PAGE_FILE_INFO ) { /* Goto format page */ if( exp_html_move_file() ) { gtk_notebook_set_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT ); gtk_widget_set_sensitive( exphtml_dlg.btnPrev, TRUE ); } export_html_message(); } else if( pageNum == PAGE_FORMAT ) { /* Goto finish page */ if( exp_html_move_format() ) { gtk_notebook_set_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FINISH ); exp_html_finish_show(); exporthtml_save_settings( _exportCtl_ ); export_html_message(); } } }
/** * Callback function of the conversation window's key-press event. */ static gboolean key_press_func(GtkWidget *widget, GdkEventKey *event, HybridConversation *conv) { gint current_page; gint pages; GSList *pos; HybridChatWindow *chat; if (event->state & GDK_CONTROL_MASK) { /* CTRL+W close the chat tab. */ if (event->keyval == GDK_w) { /* find the current chat panel. */ current_page = gtk_notebook_current_page( GTK_NOTEBOOK(conv->notebook)); for (pos = conv->chat_buddies; pos; pos = pos->next) { chat = (HybridChatWindow*)pos->data; if (current_page == gtk_notebook_page_num( GTK_NOTEBOOK(conv->notebook), chat->vbox)) { close_tab(chat); return TRUE; } } hybrid_debug_error("conv", "FATAL, can't find chat panel"); return FALSE; } /* CTRL+Q close the window. */ if (event->keyval == GDK_q) { gtk_widget_destroy(conv->window); return TRUE; } /* CTRL+TAB move to next page. */ if (event->keyval == GDK_Tab) { pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(conv->notebook)); if (pages == 1) { return TRUE; } else { current_page = gtk_notebook_current_page( GTK_NOTEBOOK(conv->notebook)); if (pages - 1 == current_page) { gtk_notebook_set_current_page(GTK_NOTEBOOK(conv->notebook), 0); } else { gtk_notebook_next_page(GTK_NOTEBOOK(conv->notebook)); } } return TRUE; } } return FALSE; }
static void message_send(HybridConversation *conv) { GtkTextBuffer *send_tb; GtkTextIter start_iter; GtkTextIter stop_iter; GtkTextView *textview; GSList *pos; HybridChatWindow *chat; gint current_page; gchar *text; HybridBuddy *buddy; HybridAccount *account; HybridModule *module; HybridIMOps *ops; /* find the current chat panel. */ current_page = gtk_notebook_current_page(GTK_NOTEBOOK(conv->notebook)); for (pos = conv->chat_buddies; pos; pos = pos->next) { chat = (HybridChatWindow*)pos->data; if (current_page == gtk_notebook_page_num( GTK_NOTEBOOK(conv->notebook), chat->vbox)) { goto chat_found; } } hybrid_debug_error("conv", "FATAL, can't find chat panel"); return; chat_found: textview = GTK_TEXT_VIEW(chat->sendtext); send_tb = gtk_text_view_get_buffer(textview); gtk_text_buffer_get_start_iter(send_tb, &start_iter); gtk_text_buffer_get_end_iter(send_tb, &stop_iter); text = gtk_text_buffer_get_text(send_tb, &start_iter, &stop_iter, TRUE); if (*text == '\0') { /* Yes, nothing was input, just return. */ return; } gtk_text_buffer_delete(send_tb, &start_iter, &stop_iter); account = chat->account; /* Add message to the textview. */ text_ops->append(chat->textview, account, NULL, text, time(NULL)); hybrid_logs_write(chat->logs, account->nickname, text, TRUE); /* Call the protocol hook function. */ if (IS_SYSTEM_CHAT(chat)) { buddy = chat->data; module = account->proto; ops = module->info->im_ops; if (chat->typing_source) { g_source_remove(chat->typing_source); chat->typing_source = 0; chat->is_typing = FALSE; } if (ops->chat_send_typing) { ops->chat_send_typing(account, buddy, INPUT_STATE_ACTIVE); } if (ops->chat_send) { ops->chat_send(account, buddy, text); } } if (IS_USER_DEFINED_CHAT(chat)) { if (chat->callback) { chat->callback(account, text); } } }
void hybrid_conv_got_message(HybridAccount *account, const gchar *buddy_id, const gchar *message, time_t time) { HybridConversation *conv; HybridChatWindow *chat; HybridBuddy *buddy; gchar *msg; gchar *notify_msg; GdkPixbuf *pixbuf; gint current_page; gint chat_page; msg = hybrid_strip_html(message); g_return_if_fail(account != NULL); g_return_if_fail(buddy_id != NULL); g_return_if_fail(message != NULL); if (!(buddy = hybrid_blist_find_buddy(account, buddy_id))) { hybrid_debug_error("conv", "buddy doesn't exist."); g_free(msg); return; } if (!(chat = hybrid_conv_find_chat(buddy_id))) { /* Well, we haven't find an existing chat panel so far, so create one. */ chat = hybrid_chat_window_create(account, buddy->id, HYBRID_CHAT_PANEL_SYSTEM); } /* check whether the chat window is active. */ conv = chat->parent; if (gtk_window_is_active(GTK_WINDOW(conv->window))) { current_page = gtk_notebook_current_page(GTK_NOTEBOOK(conv->notebook)); chat_page = gtk_notebook_page_num(GTK_NOTEBOOK(conv->notebook), chat->vbox); if (current_page == chat_page) { goto just_show_msg; } } /* change the callback function of the status icon's activate signal. */ hybrid_status_icon_blinking(buddy); /* notify. */ notify_msg = g_strdup_printf(_("%s said:"), buddy->name && *buddy->name ? buddy->name : buddy->id); pixbuf = hybrid_create_round_pixbuf(buddy->icon_data, buddy->icon_data_length, 48); hybrid_notify_popup(pixbuf, notify_msg, msg); g_object_unref(pixbuf); g_free(notify_msg); chat->unread ++; hybrid_chat_window_update_tips(chat); just_show_msg: hybrid_sound_play_file(SOUND_DIR"newmessage.wav"); text_ops->append(chat->textview, buddy->account, buddy, msg, time); hybrid_logs_write(chat->logs, buddy->name, msg, FALSE); g_free(msg); }
void close_current_page( GtkButton *button, GtkNotebook *notebook) { gint page = gtk_notebook_current_page (notebook); gtk_notebook_remove_page (notebook, page); }