home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / yagirc-0.51.tar.gz / yagirc-0.51.tar / yagirc-0.51 / gui_menu.c < prev    next >
C/C++ Source or Header  |  1998-05-09  |  4KB  |  161 lines

  1. /*
  2.  
  3.  gui_menu.c : Menu commands
  4.  
  5.     Copyright (C) 1998 Timo Sirainen
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. #include <stdio.h>
  23.  
  24. #include "os.h"
  25. #include "gui.h"
  26. #include "irc.h"
  27. #include "version.h"
  28. #include "commands.h"
  29.  
  30. /* add menuitem to menu */
  31. void add_popup(GtkWidget *menu, char *label, void *func, void *data)
  32. {
  33.     GtkWidget *menu_item;
  34.  
  35.     g_return_if_fail(menu != NULL);
  36.  
  37.     if (label != NULL)
  38.         menu_item = gtk_menu_item_new_with_label(label);
  39.     else
  40.         menu_item = gtk_menu_item_new();
  41.  
  42.     gtk_menu_append(GTK_MENU (menu), menu_item);
  43.  
  44.     if (func != NULL)
  45.     {
  46.         gtk_signal_connect_object(GTK_OBJECT(menu_item), "activate",
  47.                                   GTK_SIGNAL_FUNC(func),
  48.                                   (GtkObject *) data);
  49.     }
  50.     else
  51.         gtk_widget_set_sensitive(menu_item, FALSE);
  52.  
  53.     gtk_widget_show(menu_item);
  54. }
  55.  
  56. /* add submenu to menu */
  57. void add_popup_sub(GtkWidget *menu, char *label, GtkWidget *submenu)
  58. {
  59.     GtkWidget *menu_item;
  60.  
  61.     g_return_if_fail(menu != NULL);
  62.     g_return_if_fail(label != NULL);
  63.  
  64.     menu_item = gtk_menu_item_new_with_label(label);
  65.  
  66.     gtk_menu_append(GTK_MENU(menu), menu_item);
  67.     gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu);
  68.     gtk_widget_show(menu_item);
  69. }
  70.  
  71.  
  72. void menu_irc_connect(GtkWidget *widget, gpointer *data)
  73. {
  74.     SETUP_SERVER_REC *server;
  75.     char *tmp;
  76.  
  77.     if (servers == NULL)
  78.     {
  79.         /* no selected servers in list.. */
  80.         return;
  81.     }
  82.  
  83.     while (gtk_events_pending())
  84.         gtk_main_iteration();
  85.  
  86.     server = (SETUP_SERVER_REC *) g_list_first(servers)->data;
  87.     tmp = (char *) g_malloc(strlen(server->name)+20);
  88.     sprintf(tmp, "%s:%d", server->name, server->port);
  89.     irccmd_server(tmp);
  90.     g_free(tmp);
  91. }
  92.  
  93. void menu_irc_disconnect(GtkWidget *widget, gpointer *data)
  94. {
  95.     irccmd_disconnect("");
  96. }
  97.  
  98. void menu_irc_setup(GtkWidget *widget, gpointer *data)
  99. {
  100.     gui_setup();
  101. }
  102.  
  103. void menu_irc_quit(GtkWidget *widget, gpointer *data)
  104. {
  105.     gtk_main_quit();
  106. }
  107.  
  108. void menu_command_join(GtkWidget *widget, gpointer *data)
  109. {
  110.     if (cserver != NULL)
  111.         gui_join_dialog(cserver);
  112. }
  113.  
  114. void menu_command_part(GtkWidget *widget, gpointer *data)
  115. {
  116.     irccmd_part("");
  117. }
  118.  
  119. void menu_window_new(GtkWidget *widget, gpointer *data)
  120. {
  121.     char tmp[4] = "NEW";
  122.  
  123.     irccmd_window(tmp);
  124. }
  125.  
  126. void menu_window_new_hidden(GtkWidget *widget, gpointer *data)
  127. {
  128.     char tmp[9] = "NEW HIDE";
  129.  
  130.     irccmd_window(tmp);
  131. }
  132.  
  133. void menu_window_close(GtkWidget *widget, gpointer *data)
  134. {
  135.     char tmp[6] = "CLOSE";
  136.  
  137.     irccmd_window(tmp);
  138. }
  139.  
  140. void menu_window_connect(GtkWidget *widget, gpointer *data)
  141. {
  142.     gui_connect_dialog();
  143. }
  144.  
  145. void menu_help_about(GtkWidget *widget, gpointer *data)
  146. {
  147. #ifdef USE_GNOME
  148.     GtkWidget *about;
  149.     gchar *authors[] = { "Timo Sirainen <a@sicom.fi>", NULL };
  150.  
  151.     about = gnome_about_new("yagIRC", IRC_VERSION_NUMBER,
  152.                             /* copyrigth notice */
  153.                             "(C) 1998 Timo Sirainen",
  154.                             authors,
  155.                             /* another comments */
  156.                             "Yet Another GTK+ based IRC client",
  157.                             NULL);
  158.     gtk_widget_show(about);
  159. #endif
  160. }
  161.