示例#1
0
文件: main.c 项目: briskgreen/duoyi
void add_dic_selection(GtkWidget *win,GtkWidget *hbox,SelectionData *data)
{
	GtkWidget *vbox;
	GtkWidget *frame;
	GtkWidget *button;
	GtkWidget *image;
	GSList *group;

	int i;
	/*提供的翻译词典名称*/
	char *name[]={"百度翻译","必应翻译","金山词霸","有道翻译"};
	/*词典的图标*/
	char *path[]={"img/baidu.png","img/bing.png","img/king.png","img/youdao.png"};
	/*各回调函数*/
	callback func[]={duoyi_baidu_select,duoyi_bing_select,
	duoyi_king_select,duoyi_youdao_select};

	/*添加边框*/
	frame=gtk_frame_new("选择网络词典");
	gtk_box_pack_start(GTK_BOX(hbox),frame,FALSE,FALSE,5);
	vbox=gtk_box_new(GTK_ORIENTATION_VERTICAL,10);
	gtk_container_add(GTK_CONTAINER(frame),vbox);
	gtk_container_set_border_width(GTK_CONTAINER(vbox),0x10);

	button=gtk_radio_button_new(NULL);
	image=gtk_image_new_from_file(path[0]);
	gtk_button_set_image(GTK_BUTTON(button),image);
	gtk_button_set_label(GTK_BUTTON(button),name[0]);
	gtk_button_set_image_position(GTK_BUTTON(button),GTK_POS_TOP);
	gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,0);

	g_signal_connect(G_OBJECT(button),"pressed",
				G_CALLBACK(func[0]),data);
	/*如果默认词典是百度,发送一个clicked信号*/
	if(data->select == 0)
		gtk_button_clicked(GTK_BUTTON(button));

	for(i=1;i != 4;++i)
	{
		group=gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
		image=gtk_image_new_from_file(path[i]);
		button=gtk_radio_button_new(group);
		/*添加图标*/
		gtk_button_set_image(GTK_BUTTON(button),image);
		/*添加名称*/
		gtk_button_set_label(GTK_BUTTON(button),name[i]);
		gtk_button_set_image_position(GTK_BUTTON(button),GTK_POS_TOP);

		gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,0);
		g_signal_connect(G_OBJECT(button),"pressed",
				G_CALLBACK(func[i]),data);

		/*设置显示词典*/
		if(i == data->select)
			gtk_button_clicked(GTK_BUTTON(button));
	}
}
示例#2
0
static void
scan_start (unsigned int timestamp)
{
  ScanState *state = scan_state();
  switch (state->timer_state)
    {
    case SCAN_IDLE:
      state->timer_state = SCAN_LINES;
      state->scan_column = 0;
      state->scan_row = 0;
      g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 600, increment_scan, state, NULL);
      select_line (state->scan_row);
      break;
    case SCAN_LINES_DONE:
      state->timer_state = SCAN_KEYS;
      g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 600, increment_scan, state, NULL);
      deselect_line (state->scan_row);
      select_key (state->scan_row, state->scan_column);
      break;
    case SCAN_KEYS_DONE:
      gtk_button_clicked (buttons[state->scan_row][state->scan_column]);
      deselect_key (state->scan_row, state->scan_column);
      state->timer_state = SCAN_IDLE;
      break;
    default:
      g_print("unexpected state for 'scan start'\n");
    }
}
示例#3
0
void FloatingWindow::focus_set(bool active)
// Sets the focus of the window.
{
  // Bail out if there's no focus change.
  if (active == focused) {
    return;
  }
  // Store whether focused.
  focused = active;
  // If we focus, then grab the widget that was focused last.
  if (active) {
    if (last_focused_widget) {
      gtk_widget_grab_focus (last_focused_widget);
    }
  }
  // Update title bar.
  title_set (focused);
  // Set the window on top of any others that share same intersection.
  // It has been observed that widgets that are last added to the layout are shown on top of any others.
  // Therefore remove the window from the layout, and add it again so that it becomes the last one added.
  if (active) {
    // The following works to set the window above others, but the by-effects are undesirable,
    // therefore it is better at this stage to not do that.
    // One of the by-effects is that the selection in the editor gets lost.
    // Another one is that the comboboxes get greyed out.
    // g_object_ref (G_OBJECT (vbox_window));
    // gtk_container_remove (GTK_CONTAINER (layout), vbox_window);
    // gtk_layout_put (GTK_LAYOUT (layout), vbox_window, my_gdk_rectangle.x, my_gdk_rectangle.y);
    // g_object_unref (G_OBJECT (vbox_window));
  }
  // If we got focus, then alert the other windows.
  if (active) {
    gtk_button_clicked(GTK_BUTTON(focus_in_signal_button));
  }
}
static void
on_row_activated (GtkWidget *box, GtkWidget *row, GtkWidget *widget)
{
    GtkWidget *button = get_button_for_row (row);

    gtk_button_clicked (GTK_BUTTON (button));
}
示例#5
0
bool _HYButton::_ProcessOSEvent (Ptr vEvent)
{
	_HY_GTK_UI_Message *theMessage = (_HY_GTK_UI_Message*)vEvent;

	if(buttonControl&&isEnabled)
	{
		switch (theMessage->theEvent->type)
		{
			case GDK_KEY_PRESS:
			{
				GdkEventKey * kpe = (GdkEventKey*)theMessage->theEvent;
				
				gint 	keyCode = kpe->keyval;
			
				bool	good	= false;
				
				if (buttonKind == HY_BUTTON_OK)
					good = (keyCode==GDK_Return || keyCode==GDK_KP_Enter);
				else
					if (buttonKind == HY_BUTTON_CANCEL)
						good = keyCode==GDK_Escape;
						
				if (good) 
				{
					gtk_button_clicked (GTK_BUTTON(buttonControl));
					return true;
				}
			}
		}
	}
					
	return _HYPlatformComponent::_ProcessOSEvent (vEvent);		
}
示例#6
0
void WindowMerge::on_editors_changed()
// This function is called shortly after any of the Editors changed.
{
  // See whether to load new text.
  bool loadtext = true;
  if (current_master_project.empty())
    loadtext = false;;
  if (current_edited_project.empty())
    loadtext = false;;

  // Set buttons' sensitivity.
  gtk_widget_set_sensitive(button_previous, loadtext);
  gtk_widget_set_sensitive(button_merge, loadtext);
  gtk_widget_set_sensitive(button_next, loadtext);

  // If no loading, clear text and bail out.
  if (!loadtext) {
    display_changes_gui->clear ();
    return;
  }
  // Signal to get the text from the editors.
  gtk_button_clicked(GTK_BUTTON(editors_get_text_button));

  // Show the comparison.
  show_comparison();
}
示例#7
0
/**
 * force the assistant to go to the next page
 *
 * \param assistant
 *
 * \return
 * */
void gsb_assistant_next_page ( GtkWidget *assistant )
{
    GtkWidget * button_next;

    button_next = g_object_get_data ( G_OBJECT (assistant), "button_next" );
    gtk_button_clicked ( GTK_BUTTON (button_next));
}
static char *handle_item(struct osc_plugin *plugin, const char *attrib,
			 const char *value)
{
	int i;

	if (MATCH_ATTRIB(SYNC_RELOAD)) {
		if (value) {
			for (i = 0; i < ARRAY_SIZE(attrs); i++)
				update_widget(builder, &attrs[i]);
			gtk_button_clicked(GTK_BUTTON(gtk_builder_get_object(builder,
					"initialize")));
		} else {
			return "1";
		}
	} else {
		if (value) {
			printf("Unhandled tokens in ini file,\n"
				"\tSection %s\n\tAtttribute : %s\n\tValue: %s\n",
				"FMComms2 Advanced", attrib, value);
			return "FAIL";
		}
	}

	return NULL;
}
static void update_widget(GtkBuilder *builder, struct w_info *item)
{
	GtkWidget *widget;
	int val;
	long long value;

	widget = GTK_WIDGET(gtk_builder_get_object(builder, item->name));
	val = iio_device_debug_attr_read_longlong(dev, item->name, &value);

	/* check for errors, in case there is a kernel <-> userspace mismatch */
	if (val < 0) {
		printf("%s:%s: error accessing '%s' (%s)\n",
			__FILE__, __func__, item->name, strerror(-val));
		gtk_widget_hide(widget);
		return;
	}

	val = (int) value;
	switch (item->type) {
		case CHECKBOX:
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), !!val);
			break;
		case BUTTON:
			if (val)
				gtk_button_clicked(GTK_BUTTON(widget));
			break;
		case SPINBUTTON:
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), val);
			break;
		case COMBOBOX:
			gtk_combo_box_set_active(GTK_COMBO_BOX(widget), val);
			break;
	}

}
示例#10
0
void
mate_volume_control_button_set_active (MateVolumeControlButton *button,
					gboolean active)
{
  if (button->active != active)
    gtk_button_clicked (GTK_BUTTON (button));
}
static void
emoticon_tool_button_set_current_emoticon (EEmoticonChooser *chooser,
                                           EEmoticon *emoticon)
{
	EEmoticonToolButtonPrivate *priv;
	GList *list, *iter;

	priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (chooser);

	list = gtk_container_get_children (GTK_CONTAINER (priv->table));

	for (iter = list; iter != NULL; iter = iter->next) {
		GtkWidget *item = iter->data;
		EEmoticon *candidate;

		candidate = g_object_get_data (G_OBJECT (item), "emoticon");
		if (candidate == NULL)
			continue;

		if (e_emoticon_equal (emoticon, candidate)) {
			gtk_button_clicked (GTK_BUTTON (item));
			break;
		}
	}

	g_list_free (list);
}
示例#12
0
void WindowMerge::on_button_merge()
{
  // Settings.
  extern Settings * settings;
  
  // Save all editors.
  gtk_button_clicked(GTK_BUTTON(save_editors_button));

  // Ask what to do.
  ustring book_chapter = books_id_to_english(book) + " " + convert_to_string(chapter);
  vector < ustring > labels;
  labels.push_back(_("Merge ") + book_chapter + _(" of project ") + current_edited_project + _(" and ") + current_master_project);
  labels.push_back(_("Merge ") + book_chapter + _(" of project ") + current_edited_project + _(" and ") + current_master_project + ",\n" + _("and approve of each change as compared to project ") + current_master_project);
  labels.push_back(_("Copy ") + book_chapter + _(" of project ") + current_master_project + _(" to project ") + current_edited_project);
  labels.push_back(_("Copy everything of project ") + current_master_project + _(" to project ") + current_edited_project);
  RadiobuttonDialog dialog(_("Select action"), _("Select the type of merge or copy to be done"), labels, settings->session.merge_action, false);
  if (dialog.run() != GTK_RESPONSE_OK)
    return;
  // Store action taken.
  settings->session.merge_action = dialog.selection;
  // Take the selected action.
  switch (dialog.selection) {
  case 0:
    {
      merge_edited_into_master(false);
      break;
    }
  case 1:
    {
      merge_edited_into_master(true);
      break;
    }
  case 2:
    {
      copy_master_to_edited_chapter(book, chapter, true);
      break;
    }
  case 3:
    {
      copy_master_to_edited_all();
      break;
    }
  }

  // Reload the editors.
  gtk_button_clicked(GTK_BUTTON(reload_editors_button));
}
示例#13
0
static void
gimp_controller_list_row_activated (GtkTreeView        *tv,
                                    GtkTreePath        *path,
                                    GtkTreeViewColumn  *column,
                                    GimpControllerList *list)
{
  if (gtk_widget_is_sensitive (list->add_button))
    gtk_button_clicked (GTK_BUTTON (list->add_button));
}
示例#14
0
void WindowMerge::on_button_next_previous(bool next)
// This function looks for the next (or previous) chapter that differs
// in the two projects.
{
  // Variables that control the loop.
  bool change_found = false;
  bool more_chapters_available = true;
  unsigned int new_chapter = chapter;
  unsigned int new_book = book;
  do {
    // Look for next (or previous) chapter.
    vector < unsigned int >chapters = project_get_chapters(current_edited_project, new_book);
    if (chapters.empty())
      break;
    unsigned int index = 0;
    for (unsigned int i = 0; i < chapters.size(); i++) {
      if (new_chapter == chapters[i])
        index = i;
    }
    if (next) {
      if (index == (chapters.size() - 1)) {
        if (!cross_book_boundaries(true, new_book, new_chapter)) {
          more_chapters_available = false;
        }
      } else {
        new_chapter = chapters[++index];
      }
    } else {
      if (index == 0) {
        if (!cross_book_boundaries(false, new_book, new_chapter)) {
          more_chapters_available = false;
        }
      } else {
        new_chapter = chapters[--index];
      }
    }
    // See whether this chapter differs.
    vector < ustring > master_chapter_data = project_retrieve_chapter(current_master_project, new_book, new_chapter);
    vector < ustring > edited_chapter_data = project_retrieve_chapter(current_edited_project, new_book, new_chapter);
    if (master_chapter_data.size() != edited_chapter_data.size())
      change_found = true;
    for (unsigned int i = 0; i < master_chapter_data.size(); i++) {
      if (!change_found) {
        if (master_chapter_data[i] != edited_chapter_data[i])
          change_found = true;
      }
    }
  } while (!change_found && more_chapters_available);
  // Deal with whether a change was found.
  if (change_found) {
    book = new_book;
    chapter = new_chapter;
    gtk_button_clicked(GTK_BUTTON(new_reference_button));
  } else {
    gtkw_dialog_info(NULL, _("No more differing chapters found"));
  }
}
示例#15
0
static void
entry_alias_activated(GtkEntry *entry, RingMainWindow *win)
{
    RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win);

    const gchar *alias = gtk_entry_get_text(GTK_ENTRY(entry));
    if (strlen(alias) > 0)
        gtk_button_clicked(GTK_BUTTON(priv->button_account_creation_next));
}
示例#16
0
static void
gimp_controller_list_activate_item (GimpContainerView  *view,
                                    GimpViewable       *viewable,
                                    gpointer            insert_data,
                                    GimpControllerList *list)
{
  if (gtk_widget_is_sensitive (list->edit_button))
    gtk_button_clicked (GTK_BUTTON (list->edit_button));
}
示例#17
0
/**
 * g_paste_ui_header_show_prefs:
 * @self: the #GPasteUiHeader
 *
 * Show the prefs pane
 */
G_PASTE_VISIBLE void
g_paste_ui_header_show_prefs (const GPasteUiHeader *self)
{
    g_return_if_fail (_G_PASTE_IS_UI_HEADER (self));

    const GPasteUiHeaderPrivate *priv = _g_paste_ui_header_get_instance_private (self);

    gtk_button_clicked (priv->settings);
}
示例#18
0
void FontButton::showFontDialog() {
	XOJ_CHECK_TYPE(FontButton);

	if (this->fontButton == NULL) {
		newItem();
	}

	gtk_button_clicked(GTK_BUTTON(this->fontButton));
}
示例#19
0
gboolean key_event(GtkWidget *widget, GdkEventKey *event)
{
    /* Activate search button with return key */
    if (event->keyval == GDK_KEY_Return) {
        gtk_button_clicked(app->search_button);
    }

    return FALSE;
}
static void
file_selection_file_button (GtkWidget *widget,
			    gint row, 
			    gint column, 
			    GdkEventButton *bevent,
			    gpointer user_data)
{
    gtk_button_clicked(GTK_BUTTON(GTK_FILE_SELECTION(user_data)->ok_button));
}
示例#21
0
/*
 * sends a click event for image capture button
 * args:
 *   pointer to function data
 *
 * asserts:
 *    none
 *
 * returns: FALSE
 */
static gboolean image_capture_toggle_button(gpointer *data)
{
	if(!CapImageButt)
		return FALSE;

	gtk_button_clicked(GTK_BUTTON(CapImageButt));
	
	return FALSE;
}
示例#22
0
文件: magus.c 项目: athy91/game
void login(GtkWidget *widget, gpointer data) {     //login function
	const gchar *login, *l_pass;
	char buffer[20];
	gchar full[64], temp[20];

	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (status))) {     //see if we're connected PS:Not the best way is used

		login = gtk_entry_get_text((GtkEntry *) logname);     //get name from input
		l_pass = gtk_entry_get_text((GtkEntry *) pass);     //get password from input

		send(sock, login, strlen(login) + 1, 0);     //send name to the server
		send(sock, l_pass, strlen(l_pass) + 1, 0);     //send password to the server

		rec = recv(sock, buffer, buffsize - 1, 0);     //receive answer

		if (strcmp(buffer, "TRUE")) {     //see if we were successful or not
			return;
		} else {
			recv(sock, (char *) &user, sizeof(caracter), 0);
			printf(
					"%s ;%c ;%d.%d.%d ;%d ;%d ;%s ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;"
							" Talents: ; Abilities: ; Techniques: ; Personality Traits: ; Reputation: ; Known Locations: ;",
					user.name, user.Gender, user.born.year, user.born.month,
					user.born.day, user.height, user.weight, user.House,
					user.str, user.dex, user.inte, user.vit, user.wis, user.sta,
					user.spd, user.cha, user.hly);

			g_stpcpy(full, user.House);
			g_strlcat(full, " ", 32);
			g_strlcat(full, user.name, 63);
			gtk_label_set_text((GtkLabel *) name, full);
			gtk_label_set_text((GtkLabel *) name, full);
			itoa(user.born.year, temp, 10);
			g_stpcpy(full, temp);
			g_strlcat(full, ".", 5);
			itoa(user.born.month, temp, 10);
			g_strlcat(full, temp, 7);
			g_strlcat(full, ".", 8);
			itoa(user.born.day, temp, 10);
			g_strlcat(full, temp, 10);
			gtk_label_set_text((GtkLabel *) born, full);
			gtk_label_set_text((GtkLabel *) gender,
					(user.Gender == 'F') ? "Female" : "Male");
			itoa(user.height, full, 10);
			gtk_label_set_text((GtkLabel *) height, full);
			itoa(user.weight, full, 10);
			gtk_label_set_text((GtkLabel *) weight, full);
			gtk_button_clicked((GtkButton *) cbutton);     //get some text
			gtk_widget_hide_all(logbox);     //exchange login fields with something else
			gtk_widget_show_all(gamebox);
			return;
		}
	} else {
		err("Please connect to the server");     //if we're not connected make an error message
	}
}
示例#23
0
static gboolean
confirm_overwrite_timeout_cb (gpointer data)
{
  struct confirm_overwrite_closure *closure;

  closure = data;
  gtk_button_clicked (GTK_BUTTON (closure->accept_button));

  return FALSE;
}
G_MODULE_EXPORT void
gw_addvocabularywindow_definitions_event_after_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{

    GwAddVocabularyWindow *window;
    GwAddVocabularyWindowPrivate *priv;
    GtkTextIter start, end;
    GtkTextBuffer *buffer;
    gboolean valid;
    gboolean activate;

    window = GW_ADDVOCABULARYWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_ADDVOCABULARYWINDOW));
    g_return_if_fail (window != NULL);
    priv = window->priv;

    if (priv->pasted == TRUE) { priv->pasted = FALSE; return; }

    buffer = gtk_text_view_get_buffer (priv->definitions_textview);
    gtk_text_buffer_get_start_iter (buffer, &start);
    gtk_text_buffer_get_end_iter (buffer, &end);

    if (priv->definitions_text != NULL) g_free (priv->definitions_text);
    priv->definitions_text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
    activate = (strchr (priv->definitions_text, '\n') != NULL);
    g_strstrip (priv->definitions_text);

    gchar *source_ptr, *target_ptr;
    source_ptr = target_ptr = priv->definitions_text;
    while (*target_ptr != '\0')
    {
      if (*target_ptr == '\n') target_ptr++;
      else if (source_ptr == target_ptr)
      {
        source_ptr = ++target_ptr;
      }
      else
      {
        *(source_ptr++) = *(target_ptr++);
      }
    }
    *source_ptr = '\0';

    valid = gw_addvocabularywindow_validate (window);

    if (activate)
    {
      G_GNUC_EXTENSION g_signal_handlers_block_by_func (widget, gw_addvocabularywindow_definitions_event_after_cb, data);
      gtk_text_buffer_set_text (buffer, priv->definitions_text, -1);
      G_GNUC_EXTENSION g_signal_handlers_unblock_by_func (widget, gw_addvocabularywindow_definitions_event_after_cb, data);
      if (valid)
      {
        gtk_button_clicked (priv->add_button);
      }
    }
}
示例#25
0
/**
 * gtk_toggle_tool_button_set_active:
 * @button: a #GtkToggleToolButton
 * @is_active: whether @button should be active
 * 
 * Sets the status of the toggle tool button. Set to %TRUE if you
 * want the GtkToggleButton to be 'pressed in', and %FALSE to raise it.
 * This action causes the toggled signal to be emitted.
 * 
 * Since: 2.4
 **/
void
gtk_toggle_tool_button_set_active (GtkToggleToolButton *button,
				   gboolean is_active)
{
  g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button));

  is_active = is_active != FALSE;

  if (button->priv->active != is_active)
    gtk_button_clicked (GTK_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button))));
}
static void
connection_double_clicked_cb (GtkTreeView *tree_view,
                              GtkTreePath *path,
                              GtkTreeViewColumn *column,
                              gpointer user_data)
{
	GtkButton *button = user_data;

	if (ce_polkit_button_get_actionable (CE_POLKIT_BUTTON (button)))
		gtk_button_clicked (button);
}
示例#27
0
/* Emits a GtkButton::clicked signal to the given GtkButton. */
int
clip_GTK_BUTTONCLICKED(ClipMachine * ClipMachineMemory)
{
    C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

    CHECKCWID(cbtn, GTK_IS_BUTTON);
    gtk_button_clicked(GTK_BUTTON(cbtn->widget));
    return 0;
err:
    return 1;
}
示例#28
0
static gboolean
video_area_button_press_cb (GtkWidget          *widget,
			    GdkEventButton     *event,
			    GthMediaViewerPage *self)
{
	if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
		gtk_button_clicked (GTK_BUTTON (GET_WIDGET ("button_play")));
		return TRUE;
	}

	return gth_browser_viewer_button_press_cb (self->priv->browser, event);
}
示例#29
0
void key_press (GtkWidget *widget,GdkEventKey *event,gpointer data)//find that key pressed is witch button then call(bt_clicked)
{
    for (int i = 0; i < NumberofButtons; i++)// Search all the buttons
    {
        if (event->keyval == bt_list[i].btLabel[0] && bt_list[i].btLabel[1] == (char) 0)
        {
            gtk_widget_grab_focus (bt_list[i].widget);
            gtk_button_clicked (GTK_BUTTON(bt_list[i].widget));
            return;
        }
    }
}
示例#30
0
static int lua_select(lua_State*L)
{
  dt_lua_snapshot_t index;
  luaA_to(L,dt_lua_snapshot_t,&index,1);
  dt_lib_module_t* module = lua_touserdata(L,lua_upvalueindex(1));
  dt_lua_lib_check_error(L,module);
  dt_lib_snapshots_t *d = (dt_lib_snapshots_t *)module->data;
  if(index >= d->num_snapshots || index < 0) {
    return luaL_error(L,"Accessing a non-existant snapshot");
  }
  dt_lib_snapshot_t *self = &d->snapshot[index];
  gtk_button_clicked(GTK_BUTTON(self->button));
  return 0;
}