source: projects/synaptic/trunk/gtk/rgfindwindow.cc @ 280

Revision 280, 3.7 KB checked in by yasumichi, 15 years ago (diff)

first import

Line 
1/* rgfindwindow.cc
2 *
3 * Copyright (c) 2003 Michael Vogt
4 *
5 * Author: Michael Vogt <mvo@debian.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23#include "config.h"
24
25#include <cassert>
26
27#include "rgfindwindow.h"
28#include "rgmisc.h"
29
30#include "i18n.h"
31
32
33string RGFindWindow::getFindString()
34{
35   GtkWidget *entry;
36   string s;
37
38   entry = glade_xml_get_widget(_gladeXML, "entry_find");
39   const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
40
41   return text;
42}
43
44void RGFindWindow::selectText()
45{
46   GtkWidget *entry = glade_xml_get_widget(_gladeXML, "entry_find");
47   gtk_widget_grab_focus(entry);
48   gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
49}
50
51int RGFindWindow::getSearchType()
52{
53   int searchType;
54   GtkWidget *omenu = glade_xml_get_widget(_gladeXML, "optionmenu_where");
55   assert(omenu);
56   searchType = gtk_option_menu_get_history(GTK_OPTION_MENU(omenu));
57
58   return searchType;
59}
60
61
62void RGFindWindow::doFind(GtkWindow *widget, void *data)
63{
64   //cout << "RGFindWindow::doFind()"<<endl;
65   RGFindWindow *me = (RGFindWindow *) data;
66
67   GtkWidget *combo = glade_xml_get_widget(me->_gladeXML, "combo_find");
68   const gchar *str = gtk_entry_get_text(GTK_ENTRY(me->_entry));
69
70   if(strlen(str) == 0)
71      return;
72
73   me->_prevSearches = g_list_prepend(me->_prevSearches, g_strdup(str));
74   gtk_combo_set_popdown_strings(GTK_COMBO(combo), me->_prevSearches);
75
76   doClose(widget, data);
77   gtk_dialog_response(GTK_DIALOG(((RGFindWindow *) data)->window()),
78                       GTK_RESPONSE_OK);
79}
80
81void RGFindWindow::doClose(GtkWindow *widget, void *data)
82{
83   //cout << "void RGFindWindow::doClose()" << endl; 
84   RGFindWindow *w = (RGFindWindow *) data;
85
86   w->hide();
87}
88
89void RGFindWindow::cbEntryChanged(GtkWindow *widget, void *data)
90{
91   RGFindWindow *me = (RGFindWindow *) data;
92
93   if( strlen(gtk_entry_get_text(GTK_ENTRY(me->_entry))) >0 )
94      gtk_widget_set_sensitive(me->_findB, TRUE);
95   else
96      gtk_widget_set_sensitive(me->_findB, FALSE);
97}
98
99
100RGFindWindow::RGFindWindow(RGWindow *win)
101: RGGladeWindow(win, "find"), _prevSearches(0)
102{
103   //cout << " RGFindWindow::RGFindWindow(RGWindow *win) "<< endl;
104
105   glade_xml_signal_connect_data(_gladeXML,
106                                 "on_button_find_clicked",
107                                 G_CALLBACK(doFind), this);
108
109   glade_xml_signal_connect_data(_gladeXML,
110                                 "on_entry_find_activate",
111                                 G_CALLBACK(doFind), this);
112
113   glade_xml_signal_connect_data(_gladeXML,
114                                 "on_button_close_clicked",
115                                 G_CALLBACK(doClose), this);
116
117   GtkWidget *combo = glade_xml_get_widget(_gladeXML, "combo_find");
118   gtk_combo_set_value_in_list(GTK_COMBO(combo), FALSE, FALSE);
119
120   _entry = glade_xml_get_widget(_gladeXML, "entry_find");
121   assert(_entry);
122   g_signal_connect(G_OBJECT(_entry), "changed", 
123                   G_CALLBACK(cbEntryChanged), this);
124   _findB = glade_xml_get_widget(_gladeXML, "button_find");
125   assert(_findB);
126   gtk_widget_set_sensitive(_findB, FALSE);
127
128   setTitle(_("Find"));
129   skipTaskbar(true);
130}
Note: See TracBrowser for help on using the repository browser.