Logo Search packages:      
Sourcecode: papaya version File versions  Download package

interface.c

/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>

#include <gnome.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

void on_request_lists_selected(GtkMenuItem * item, gpointer data);

static GtkItemFactoryEntry menu_items[] = {
  { "/_File", NULL, NULL, 0, "<Branch>" },
  { "/File/Exit", NULL, (GtkItemFactoryCallback)gtk_main_quit, 0, NULL },

  { "/_Connection", NULL, NULL, 0, "<Branch>" },
  { "/Connection/Connect", NULL, (GtkItemFactoryCallback)connect_selected, 0, NULL},
  { "/Connection/Disconnect", NULL, (GtkItemFactoryCallback)disconnect_selected, 0, NULL},
  { "/Connection/List", NULL, (GtkItemFactoryCallback)list_selected, 0, NULL},

  { "/C_ommands", NULL, NULL, 0, "<Branch>" },
  { "/Commands/Request Connection Lists", NULL, (GtkItemFactoryCallback)on_request_lists_selected, 0, NULL },

  { "/_Help", NULL, NULL, 0, "<LastBranch>" },
  { "/Help/About", NULL, NULL, 0, NULL },
};

void get_main_menu(GtkWidget * window, GtkWidget **menubar) {

  GtkItemFactory * item_factory;
  GtkAccelGroup * accel_group;
  gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
  
  accel_group = gtk_accel_group_new ();
  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
                                       accel_group);
  
  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  
  if (menubar)
    *menubar = gtk_item_factory_get_widget (item_factory, "<main>");
}


GtkWidget*
create_chat_window (void)
{
  GtkWidget *chat_window;
  GtkWidget *vbox1;
  GtkWidget *chat_menubar;
  GtkWidget *scrolledwindow1;

  chat_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_object_set_data (GTK_OBJECT (chat_window), "chat_window", chat_window);
  gtk_window_set_title (GTK_WINDOW (chat_window), _("Papaya Chat Window"));
  gtk_window_set_default_size (GTK_WINDOW (chat_window), 440, 200);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (chat_window), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (chat_window), vbox1);

  get_main_menu(chat_window, &chat_menubar);
  gtk_object_set_data (GTK_OBJECT (chat_window), "chat_menubar", chat_menubar);
  gtk_widget_show (chat_menubar);

  gtk_box_pack_start(GTK_BOX(vbox1), chat_menubar, FALSE, FALSE, 0);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow1);
  gtk_object_set_data_full (GTK_OBJECT (chat_window), "scrolledwindow1", scrolledwindow1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

  chat_output = gtk_text_new (NULL, NULL);
  gtk_widget_ref (chat_output);
  gtk_object_set_data_full (GTK_OBJECT (chat_window), "chat_output", chat_output,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (chat_output);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), chat_output);
  gtk_widget_realize (chat_output);
  gtk_text_insert (GTK_TEXT (chat_output), NULL, NULL, NULL,
                   _("Welcome to the Papaya chat plugin.\n\n"), 36);

  chat_input = gtk_entry_new ();
  gtk_widget_ref (chat_input);
  gtk_object_set_data_full (GTK_OBJECT (chat_window), "chat_input", chat_input,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (chat_input);
  gtk_box_pack_start (GTK_BOX (vbox1), chat_input, FALSE, FALSE, 0);

  gtk_signal_connect (GTK_OBJECT (chat_input), "activate",
                      GTK_SIGNAL_FUNC (on_chat_input_activate),
                      NULL);

  return chat_window;
}

GtkWidget*
create_chat_connect_window (void)
{
  GtkWidget *chat_connect_window;
  GtkWidget *vbox1;
  GtkWidget *label3;
  GtkWidget *table1;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *hbuttonbox1;
  GtkWidget *connection_ok;
  GtkWidget *connection_cancel;

  chat_connect_window = gtk_window_new (GTK_WINDOW_DIALOG);
  gtk_object_set_data (GTK_OBJECT (chat_connect_window), "chat_connect_window", chat_connect_window);
  gtk_window_set_title (GTK_WINDOW (chat_connect_window), _("Make Connection"));
  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (chat_connect_window), vbox1);
  gtk_container_set_border_width (GTK_CONTAINER (vbox1), 3);

  label3 = gtk_label_new (_("Connect to which host and port?"));
  gtk_widget_ref (label3);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "label3", label3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label3);
  gtk_box_pack_start (GTK_BOX (vbox1), label3, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT);
  gtk_misc_set_alignment (GTK_MISC (label3), 4.47035e-08, 0.5);
  gtk_misc_set_padding (GTK_MISC (label3), 0, 7);

  table1 = gtk_table_new (2, 2, FALSE);
  gtk_widget_ref (table1);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "table1", table1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
  gtk_table_set_row_spacings (GTK_TABLE (table1), 2);
  gtk_table_set_col_spacings (GTK_TABLE (table1), 5);

  host_entry = gtk_entry_new ();
  gtk_widget_ref (host_entry);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "host_entry", host_entry,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (host_entry);
  gtk_table_attach (GTK_TABLE (table1), host_entry, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  port_entry = gtk_entry_new ();
  gtk_widget_ref (port_entry);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "port_entry", port_entry,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (port_entry);
  gtk_table_attach (GTK_TABLE (table1), port_entry, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label1 = gtk_label_new (_("Host"));
  gtk_widget_ref (label1);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "label1", label1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label1);
  gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  label2 = gtk_label_new (_("Port"));
  gtk_widget_ref (label2);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "label2", label2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label2);
  gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_ref (hbuttonbox1);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "hbuttonbox1", hbuttonbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, FALSE, 0);
  gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox1), 0, 0);

  connection_ok = gnome_stock_button (GNOME_STOCK_BUTTON_OK);
  gtk_widget_ref (connection_ok);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "connection_ok", connection_ok,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (connection_ok);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), connection_ok);
  GTK_WIDGET_SET_FLAGS (connection_ok, GTK_CAN_DEFAULT);

  connection_cancel = gnome_stock_button (GNOME_STOCK_BUTTON_CANCEL);
  gtk_widget_ref (connection_cancel);
  gtk_object_set_data_full (GTK_OBJECT (chat_connect_window), "connection_cancel", connection_cancel,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (connection_cancel);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), connection_cancel);
  GTK_WIDGET_SET_FLAGS (connection_cancel, GTK_CAN_DEFAULT);

  gtk_signal_connect (GTK_OBJECT (connection_ok), "clicked",
                      GTK_SIGNAL_FUNC (on_connection_ok_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (connection_cancel), "clicked",
                      GTK_SIGNAL_FUNC (on_connection_cancel_clicked),
                      NULL);


  return chat_connect_window;
}

void output_append(char * s) {
  gtk_text_insert(chat_output, NULL, NULL, NULL, s, -1);
}

Generated by  Doxygen 1.6.0   Back to index